Skip to content

Fix factor of 2 in Rz operator in trotter_export_to_qgates_test.py#1380

Merged
arettig merged 3 commits into
quantumlib:mainfrom
arettig:trotter_qasm2
Jun 26, 2026
Merged

Fix factor of 2 in Rz operator in trotter_export_to_qgates_test.py#1380
arettig merged 3 commits into
quantumlib:mainfrom
arettig:trotter_qasm2

Conversation

@arettig

@arettig arettig commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #721 (supersedes #1343). A factor of 2 error in Rz gates is corrected when outputting a Trotter decomposition to QASM (for both the controlled and uncontrolled versions). The corresponding tests are also corrected.

A factor of 2 discrepancy between the definition of the Rz(theta)
operator is corrected when exporting to QASM format.
@arettig arettig added the priority/before-1.7.2 Things to do before the next release label Jun 25, 2026

@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 updates the coefficient calculations for the C-Phase and Rz gates generated in pauli_exp_to_qasm within trotter_exp_to_qgates.py. Specifically, it doubles the coefficient for the Rz gate when no ancilla is used, and flips the signs for C-Phase and Rz gates when an ancilla is used. Corresponding unit tests in trotter_exp_to_qgates_test.py have been updated to reflect these new coefficient values. No review comments were provided, so there is no feedback to address.

@mhucka

mhucka commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

It's weird how Gemini Code Assist is all over some PRs, and other ones it just kinda wipes its hands and says "eh, not my concern."

@mhucka mhucka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for doing this. I have some comments that are not critical, so I approved the PR and will leave it to you to address them (or not) before merging.

Comment thread src/openfermion/circuits/trotter_exp_to_qgates.py Outdated
arettig added 2 commits June 25, 2026 22:51
Implemented suggested changes to eliminate redundant code and avoid
copying of lists.
@arettig arettig added this pull request to the merge queue Jun 25, 2026
Merged via the queue into quantumlib:main with commit badaddf Jun 26, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/before-1.7.2 Things to do before the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angle of rotation in trotterize_exp_qubop_to_qasm is off by a factor of 2

2 participants