Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ModInv shim with KaliskiModInverse in ECAdd bloq #1485

Merged
merged 16 commits into from
Nov 5, 2024

Conversation

fpapa250
Copy link
Contributor

@fpapa250 fpapa250 commented Nov 1, 2024

Removes ModInv shim as it is no longer used
Replaces it with KaliskiModInverse bloq in ECAdd
Improves the gate count test to match toffoli count expected with bloq swap

@fpapa250
Copy link
Contributor Author

fpapa250 commented Nov 5, 2024

#1443 - this issue is fixed now because we use KaliskiModInverse for classical simulation instead of my hacky temp solution.

@fpapa250 fpapa250 marked this pull request as ready for review November 5, 2024 02:47
qualtran/bloqs/factoring/ecc/ec_add.py Outdated Show resolved Hide resolved
# toffoli cost for Kaliski Mod Inverse, n extra toffolis in ModNeg, 2n extra toffolis to do n
# 3-controlled toffolis in step 2. The expression is written with rationals because sympy
# comparison fails with floats.
assert total_toff == sympy.Rational(253, 2) * n**2 + sympy.Rational(391, 2) * n - 31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something that might help here or in the future: when comparing sympy expressions, the equality operator tests for the same literal expression. If you want to test for mathematical equality x = y you can test simplify(x-y)==0

Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweeeeeeeet

@mpharrigan mpharrigan merged commit 96b05e9 into quantumlib:main Nov 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants