Skip to content

Add bloq for constant polynomial multiplication modulu in GF(2) #1516

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

Merged
merged 14 commits into from
Jan 24, 2025

Conversation

NoureldinYosri
Copy link
Contributor

@NoureldinYosri NoureldinYosri commented Jan 6, 2025

This PR is the first PR implementing https://arxiv.org/abs/1910.02849v2. specifically this PR implements Algorithm 1: $MULT_{f(x)}$ Which I renamed to MultiplyPolyByConstantMod.

The final construction implements polyomial multiplication in GF(2) with exactly $n^{log_2(3)}$ Toffolis as opposed to the $n^2$ construction we currently have.

@NoureldinYosri NoureldinYosri marked this pull request as ready for review January 7, 2025 00:28
@NoureldinYosri NoureldinYosri changed the title Add bloq for constant polynomial multiplication modulu in GF(2)" Add bloq for constant polynomial multiplication modulu in GF(2) Jan 8, 2025

@cached_property
def signature(self) -> 'Signature':
return Signature([Register('g', QBit(), shape=(self.n,))])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tanujkhattar I want to have an $n-1$ degree polynomial in GF(2) instead of a number in GF($2^n$). is there a way to do that? or do we want to use GF($2^n$) for consistancy?

@mpharrigan mpharrigan enabled auto-merge (squash) January 24, 2025 18:44
@mpharrigan mpharrigan merged commit d92bb1e into quantumlib:main Jan 24, 2025
8 checks passed
@tanujkhattar
Copy link
Collaborator

Ops, Me and @NoureldinYosri had a discussion offline on how to modify the PR to have the right signature for galois field arithmetic. Guess I should have left a review and blocked the PR.

@NoureldinYosri Can you please open a follow-up PR to accommodate the changes that we discussed offline ?

@NoureldinYosri
Copy link
Contributor Author

NoureldinYosri commented Jan 24, 2025

@tanujkhattar will do, it is worth mentioning that the disagreement is about the form of the input ... here I use polynomials (array of booleans) ... but the convention that qualtran adopted in the QGF dtype is of representing them as instanstances of galois.GF(...) which are essentially numbers

NoureldinYosri added a commit to NoureldinYosri/Qualtran that referenced this pull request Jan 28, 2025
…tumlib#1516)

* Fix bug in KaliskiStep3 and add tests for all steps

* cost

* Add bloq for constant polynomial multiplication modulu in GF(2)

* add notebook test

* nit

* mypy

* typo

* mypy

* typing

* fix all mypy

* fix typo
NoureldinYosri added a commit that referenced this pull request Mar 31, 2025
This is the final PR in the series #1554, #1533, and #1516. These PRs implemented the GF($2^n$) multiplication construction from https://arxiv.org/abs/1910.02849v2 which has a toffoli complexity of $n^{\log_2{3}}$
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