Add additional Z and X rotation gate handling to CommutativeCancellation#16191
Open
mtreinish wants to merge 6 commits into
Open
Add additional Z and X rotation gate handling to CommutativeCancellation#16191mtreinish wants to merge 6 commits into
mtreinish wants to merge 6 commits into
Conversation
This commit expands the the handling of Z and X rotations to the commutative cancellation pass to cover missing gates that it could easily handle. In addition for the output rotation gates special handling is added for x and sx gates since we can easily emit those gates if appropriate when the x rotation angle aligns with using those gates.
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Collaborator
|
One or more of the following people are relevant to this code:
|
Coverage Report for CI Build 26666113959Coverage increased (+0.01%) to 87.567%Details
Uncovered Changes
Coverage Regressions7 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
Cryoris
reviewed
May 18, 2026
Collaborator
Cryoris
left a comment
There was a problem hiding this comment.
The logic LGTM, could you add some tests that emit circuits with the newly added X basis gates -- plus a reno?
Also in an offline discussion we noticed that commutative cancellation does not use the average gate fidelity as metric, even though it also removes identity-equivalent gates. Since that was pre-existing and this PR is adding support for additional gates in the existing framework, the gate fidelity fix should be in a follow up though.
3 tasks
This commit adds test coverage for the pass emitting X and SX gates. The global phase handling for this was incorrect because it was not correctly accounting for the phase difference between X/SX and RX. This would lead to the phase being tracked incorrectly because for the internal pass tracking it's all in terms of RX gates. So if the circuit was in terms of RX gates added and we emitted an X we'd be off because we didn't correct for the phase difference in the output circuit. This was also a problem if the circuit was in terms of X gates and we emit an X gate we had added the phase difference for the RX tracking but then we emitted the X gate and didn't need the phase correction. To address this we need to track the circuit gates and then on the output handle the correction according to the gate we're emitting. This is different from how Z angles are tracked because unlike the Z rotation gates, the other options for X gates are only for discrete angles. We would need similar handling if Z rotations could emit a Z gate but we don't support that currently so it's not an issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit expands the the handling of Z and X rotations to the
commutative cancellation pass to cover missing gates that it could
easily handle. In addition for the output rotation gates special
handling is added for x and sx gates since we can easily emit those
gates if appropriate when the x rotation angle aligns with using those
gates.
AI/LLM disclosure