Skip to content

Conversation

@ddhawan11
Copy link
Contributor

@ddhawan11 ddhawan11 commented Nov 20, 2025

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]

@ddhawan11 ddhawan11 requested a review from Jaybsoni November 20, 2025 16:52
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@ddhawan11 ddhawan11 requested a review from soranjh November 20, 2025 17:03
@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.42%. Comparing base (10cbca2) to head (a715ead).
⚠️ Report is 1 commits behind head on qubitizeTHC_bugfix.

Files with missing lines Patch % Lines
pennylane/estimator/templates/select.py 87.50% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@soranjh soranjh left a 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.

Comment on lines 233 to 282
qrom_twobody = resource_rep(
# QROM to load rotation angles for 2-body integrals + 1-body integrals
qrom_full = resource_rep(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this is changed?

Copy link
Contributor Author

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.

Comment on lines 289 to 339
# 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})))
Copy link
Contributor

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.

Copy link
Contributor Author

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},
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@ddhawan11 ddhawan11 requested a review from soranjh November 27, 2025 15:39
Copy link
Contributor

@Jaybsoni Jaybsoni left a 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)
Copy link
Contributor

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.

Suggested change
num_givens_blocks = np.ceil((num_orb - 1) / batched_rotations)
num_givens_blocks = int(np.ceil((num_orb - 1) / batched_rotations))

Comment on lines 70 to 74
Total wires: 371.0
algorithmic wires: 58
allocated wires: 313.0
zero state: 313
any state: 0.0
Copy link
Contributor

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.

Suggested change
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'X': 268.0,
'X': 268,

Total gates : 2.534E+4
'Toffoli': 2.633E+3,
'CNOT': 1.440E+4,
'X': 804.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'X': 804.0,
'X': 804,

Comment on lines 54 to 55
used to trade-off extra wires for reduced circuit depth. Defaults to :code:`None`, which internally
determines the optimal depth.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Comment on lines 58 to 60
Resources:
The resources are calculated based on Figure 5 in `arXiv:2011.03494 <https://arxiv.org/abs/2011.03494>`_
Copy link
Contributor

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>`_.
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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

@ddhawan11 ddhawan11 changed the base branch from master to qubitizeTHC_bugfix December 4, 2025 14:49
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.

4 participants