From b14f1b472b0b9bb494877f7466533ed6be5d3bf6 Mon Sep 17 00:00:00 2001 From: Frankie Papa Date: Sat, 28 Sep 2024 00:38:13 -0700 Subject: [PATCH] Maked intermediate additions unsigned in ModAdd (#1424) --- qualtran/bloqs/mod_arithmetic/mod_addition.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qualtran/bloqs/mod_arithmetic/mod_addition.py b/qualtran/bloqs/mod_arithmetic/mod_addition.py index 31f66a847..efe224946 100644 --- a/qualtran/bloqs/mod_arithmetic/mod_addition.py +++ b/qualtran/bloqs/mod_arithmetic/mod_addition.py @@ -115,7 +115,7 @@ def build_composite_bloq(self, bb: 'BloqBuilder', x: Soquet, y: Soquet) -> Dict[ x = bb.join(x_split[1:], dtype=QMontgomeryUInt(bitsize=self.bitsize)) # Add constant -p to the y register. - y = bb.add(AddK(bitsize=self.bitsize + 1, k=-1 * self.mod, signed=True, cvs=()), x=y) + y = bb.add(AddK(bitsize=self.bitsize + 1, k=-1 * self.mod, signed=False, cvs=()), x=y) # Controlled addition of classical constant p if the sign of y after the last addition is # negative. @@ -125,7 +125,7 @@ def build_composite_bloq(self, bb: 'BloqBuilder', x: Soquet, y: Soquet) -> Dict[ sign_split = bb.split(sign) sign_split, y = bb.add( - AddK(bitsize=self.bitsize, k=self.mod, signed=True, cvs=(1,)), x=y, ctrls=sign_split + AddK(bitsize=self.bitsize, k=self.mod, signed=False, cvs=(1,)), x=y, ctrls=sign_split ) sign = bb.join(sign_split)