Skip to content

Create a notebook for quantum modular arithmetic #1531

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

NoureldinYosri
Copy link
Contributor

@NoureldinYosri NoureldinYosri commented Jan 28, 2025

No description provided.

@NoureldinYosri NoureldinYosri force-pushed the writeup branch 2 times, most recently from 8351cca to 476afec Compare January 28, 2025 22:32
@mpharrigan
Copy link
Collaborator

neat! isn't there a helper function you introduced that will automatically exhaustively test classical gates?

Would probably be neat to have a small, exhaustive and large, fuzzed example for each

maybe the "leading order" symbolics helper can be factored out into the sympy support utils

@mpharrigan
Copy link
Collaborator

What about clearly segregating the "reference data" from the checks.

add1 = {
  bloq: ModAdd(bitsize=8, mod=3),
  domain: {'x': range(3), 'y': range(3)},
  tof: sympify('4*n'),  # Ref 1, Fig 8, "mod add"
  exhaustive: True
}

add2 = {
  bloq: ModAdd(bitsize=2048, mod=13*15),
  ...
  exhaustive: False
}

...

for data in [add1, add2, ...]:
  check_classical(add1) 
      # >> checking ModAdd(bitsize=8, mod=3)....
      # >> exhaustive classical action ✓
  check_cost(add1)
      # >> reference cost: 4n
      # >> computed toffli cost: 4n + 32 + lg(mod)
      # >> leading order cost: 4n ✓

@mpharrigan
Copy link
Collaborator

Is there a straightforward way to get the classical domain from the bloq? Ideally you could just query the classical domain from the data types but e.g. for mod add there are additional restrictions. Should we be using a bounded quint here?

It would also be nice if the constructors always took consistent-ish attributes so we could always have one example where we pass in a the same, small qdtype with exhaustive checking and one example where we pass in the same, large qdtype with fuzz testing

@tanujkhattar
Copy link
Collaborator

tanujkhattar commented Jan 29, 2025

A passing comment -- We should also consider using the QGF(q) type where q is a prime for mod arithmetic. QGF is the correct general type for arbitrary prime and extension fields. We should prefer that over bounded QUINT.

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