Skip to content

Add implementation for SelectTHC bloq - #1942

Open
arettig wants to merge 9 commits into
quantumlib:mainfrom
arettig:thc_select_rot
Open

Add implementation for SelectTHC bloq#1942
arettig wants to merge 9 commits into
quantumlib:mainfrom
arettig:thc_select_rot

Conversation

@arettig

@arettig arettig commented Aug 26, 2026

Copy link
Copy Markdown

Fixes #386. This adds the underlying QROAM and RealGivensRotationByPhaseGradient
bloqs to implement the SelectTHC bloq. Differences in Toffoli costs vs. the paper were
documented in a test.

This adds the underlying QROAM and RealGivensRotationByPhaseGradient
bloqs to implement the SelectTHC bloq. Tests comparing to the paper
toffoli counts were added as well.
Also updates jupyter notebook calls to THC.
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

The THCRotation bloq previously used an array of zeros if no
theta matrix was provided. This led to incorrect costs due to
QROAM optimization. QROAM is now run without data as well in
this case.
@arettig

arettig commented Aug 26, 2026

Copy link
Copy Markdown
Author

This adds the implementation for the THC select bloq laid out by @fdmalone. This caused some slight changes in the Toffoli counts for this bloq. The differences as best I can tell are the following:

  • QROAMClean - QROAMClean adjoint automatically uses the optimal block size, ignoring the kr1/kr2 parameters, which can change gate count. There are also some small optimizations for loading the data.
  • RealGivensRotationByPhaseGradient - We have to prepare the phase gradient state, adding some gates (a small number asymptotically).
  • CSWAP - The paper does not account for the swapping of the $\mu$ and $\nu$ registers as it could be combined with the PREPARE step, but it is included explicitly in the bloq.

@arettig
arettig marked this pull request as ready for review August 26, 2026 19:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements the THCRotations bloq, which rotates into the THC basis using a Givens rotation network. It adds the helper _leaf_tensor_to_givens_rotations to compute rotation angles from a THC leaf tensor, updates SelectTHC to integrate these rotations, and adds comprehensive tests and documentation. The reviewer feedback highlights critical issues regarding the handling of one-body terms when two_body_only is False. Specifically, num_terms in THCRotations should account for num_spatial one-body terms, and the bloq needs to accept nu_eq_mp1 to correctly offset the selection index. Additionally, SelectTHC currently lacks a mechanism to accept or compute one-body rotation angles when initialized with a leaf tensor eta for the full Hamiltonian.

Comment thread qualtran/bloqs/chemistry/thc/select_bloq.py Outdated
Comment thread qualtran/bloqs/chemistry/thc/select_bloq.py
The one body rotations when mu=nu+1 were missing, leading to the
one body hamiltonian being ignored. These were added in.
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.

THC select rotations implementation and costs

1 participant