Support N=33 in Shor's algorithm#161
Conversation
|
Thank you for the pull request! Could you tell us a bit why you think this change is necessary, i.e. why you would like to see the N=33 case? |
|
Thank you for your comment! Shor’s algorithm is fundamentally designed to work with a variety of composite numbers While the current library technically allows users to set To address this, I added a new |
|
Hi schrodinteq, The notebooks in the amazon-braket-algorithm-library are not meant to be comprehensive; rather they serve as an example and/or initial building block from which a user can construct their algorithms. As such, I think the N=15 case is sufficient for a simple demonstration. If you're interested in making this example more general, could I suggest implementing a more general modular exponentiation routine, e.g. along the lines in this paper https://arxiv.org/abs/2311.08555 ? That would indeed be a significant improvement to this notebook's applicability. |
|
Hi licedric, Understood — I’ll avoid adding a dedicated function for That said, I noticed that the notebook ( However, in the current implementation, when setting For example, when using if integer_a in [7, 8]:
mod_exp_amod15.cswap(x, aux_qubits[2], aux_qubits[3])
mod_exp_amod15.cswap(x, aux_qubits[1], aux_qubits[2])
mod_exp_amod15.cswap(x, aux_qubits[0], aux_qubits[1])However, the correct circuit for modular exponentiation in this case should look like: if integer_a == 8:
mod_exp_amod15.cnot(x, aux_qubits[3])If it would be helpful, I’d be happy to work on adding dedicated subroutines for Please let me know your thoughts. |
Issue #, if available:
Description of changes:
This PR adds support for modular exponentiation circuits for
N = 33in Shor's algorithm.Specifically:
A new subroutine
modular_exponentiation_amod33()is added.shors_algorithm()now callsmodular_exponentiation_amod33()whenN == 33.Although the current implementation does not appear to produce the expected nontrivial factors (i.e., 3 and 11) in practice, these additions allow users to run meaningful Shor factorization examples with
N = 33.Testing done:
Yes
Merge Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.