-
Notifications
You must be signed in to change notification settings - Fork 715
Update SelectTHC template to allow batching of Givens rotations #8682
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
base: qubitizeTHC_bugfix
Are you sure you want to change the base?
Conversation
|
Hello. You may have forgotten to update the changelog!
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## qubitizeTHC_bugfix #8682 +/- ##
======================================================
- Coverage 99.43% 99.42% -0.01%
======================================================
Files 588 588
Lines 62661 62653 -8
======================================================
- Hits 62307 62295 -12
- Misses 354 358 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
soranjh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dime10, please upgrade the explanation and name of the new argument.
| qrom_twobody = resource_rep( | ||
| # QROM to load rotation angles for 2-body integrals + 1-body integrals | ||
| qrom_full = resource_rep( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just changed some comments and variable names to avoid ambiguity.
| # Adjoint of QROM for one body integrals Eq. 35 in arXiv:2011.03494 | ||
| gate_list.append(GateCount(resource_rep(qre.Adjoint, {"base_cmpr_op": qrom_onebody}))) | ||
| # Adjoint of QROM for two body integrals only Eq. 35 in arXiv:2011.03494 | ||
| gate_list.append(GateCount(resource_rep(qre.Adjoint, {"base_cmpr_op": qrom_twobody}))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be careful with this changes. Currently, it is confusing why the changes are made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed some variable names for added clarity, this is not really changing the resources as the tests remain the same for the default version.
| 29, | ||
| 13, | ||
| 1, | ||
| {"algo_wires": 138, "auxiliary_wires": 388, "toffoli_gates": 7493}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we trust these reference numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to manually calculate them, there is not any reference which provides the exact numbers with batching. The reference that we cited provides a plot with degree of change with some degree of batching but no exact numbers.
Jaybsoni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left an initial review, I will read the paper and double check that the resource_decomp matches the results there as well in my next review.
| if batched_rotations == num_orb - 1: | ||
| restore_qrom = False | ||
|
|
||
| num_givens_blocks = np.ceil((num_orb - 1) / batched_rotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was causing the floats in the number of allocated qubits.
| num_givens_blocks = np.ceil((num_orb - 1) / batched_rotations) | |
| num_givens_blocks = int(np.ceil((num_orb - 1) / batched_rotations)) |
| Total wires: 371.0 | ||
| algorithmic wires: 58 | ||
| allocated wires: 313.0 | ||
| zero state: 313 | ||
| any state: 0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment below that fixes the typo causing the floats.
| Total wires: 371.0 | |
| algorithmic wires: 58 | |
| allocated wires: 313.0 | |
| zero state: 313 | |
| any state: 0.0 | |
| Total wires: 371 | |
| algorithmic wires: 58 | |
| allocated wires: 313 | |
| zero state: 313 | |
| any state: 0 |
| 'Hadamard': 6.406E+3 | ||
| 'Toffoli': 2.219E+3, | ||
| 'CNOT': 1.058E+4, | ||
| 'X': 268.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'X': 268.0, | |
| 'X': 268, |
| Total gates : 2.534E+4 | ||
| 'Toffoli': 2.633E+3, | ||
| 'CNOT': 1.440E+4, | ||
| 'X': 804.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'X': 804.0, | |
| 'X': 804, |
| used to trade-off extra wires for reduced circuit depth. Defaults to :code:`None`, which internally | ||
| determines the optimal depth. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| used to trade-off extra wires for reduced circuit depth. Defaults to :code:`None`, which internally | |
| determines the optimal depth. | |
| used to trade-off extra wires for reduced circuit depth. Defaults to :code:`None`, which determines | |
| the optimal depth. |
| Resources: | ||
| The resources are calculated based on Figure 5 in `arXiv:2011.03494 <https://arxiv.org/abs/2011.03494>`_ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to provide more information. For example I am not sure how the batched rotations are incorporated here? See the TrotterPauli template as an example.
| Resources: | ||
| The resources are calculated based on Figure 5 in `arXiv:2011.03494 <https://arxiv.org/abs/2011.03494>`_. | ||
| The resources are calculated based on Figure 5 in `arXiv:2011.03494 <https://arxiv.org/abs/2011.03494>`_ and | ||
| `arXiv:2501.06165 <https://arxiv.org/abs/2501.06165>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific section or figure I should be looking at? Fig 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added figure number.
| if batched_rotations == num_orb - 1: | ||
| restore_qrom = False | ||
|
|
||
| num_givens_blocks = np.ceil((num_orb - 1) / batched_rotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to cast this as int
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Context:
SelectTHC template is modified to allow more flexibility to the user.
Description of the Change:
SelectTHC template is modified to take in another keyword argument,
batched_rotations, that allows trade-off between T-gates and qubits by allowing batching of Givens rotations in the Select circuit.Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-103101]