Skip to content

Fix sx resynthesis of negative angles in CommutativeCancellation (backport #16599)#16615

Merged
jakelishman merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16599
Jul 20, 2026
Merged

Fix sx resynthesis of negative angles in CommutativeCancellation (backport #16599)#16615
jakelishman merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16599

Conversation

@mergify

@mergify mergify Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

% maintains the sign of the left operand, so 0..(num_sx as i64 % 4) is an empty iterator for non-positive num_sx. If the calculated rotation angle was negative (such as from a chain of sxdg), non-identity, and we go down the sx-like synthesis path, we would miscompile.

This is a minimal fix to be backport stable, rather than a greater reworking.

Introduced in 91081cc: Add additional Z and X rotation gate handling to CommutativeCancellation (#16191)

Fix #16594

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

This is an automatic backport of pull request #16599 done by [Mergify](https://mergify.com).

…16599)

* Fix `sx` resynthesis of negative angles in `CommutativeCancellation`

`%` maintains the sign of the left operand, so `0..(num_sx as i64 % 4)`
is an empty iterator for non-positive `num_sx`.  If the calculated
rotation angle was negative (such as from a chain of `sxdg`),
non-identity, and we go down the `sx`-like synthesis path, we would
miscompile.

This is a minimal fix to be backport stable, rather than a greater
reworking.

Introduced in 91081cc: Add additional Z and X rotation gate handling
to CommutativeCancellation (#16191)

* Use `ddt` test parametrisaion

(cherry picked from commit 33d90a9)
@mergify
mergify Bot requested a review from a team as a code owner July 20, 2026 09:57
@mergify
mergify Bot requested a review from jakelishman July 20, 2026 09:57
@qiskit-bot

Copy link
Copy Markdown
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@github-actions github-actions Bot added this to the 2.5.1 milestone Jul 20, 2026
@github-actions github-actions Bot added Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler labels Jul 20, 2026
@jakelishman
jakelishman enabled auto-merge July 20, 2026 09:59
@jakelishman
jakelishman added this pull request to the merge queue Jul 20, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 29733301808

Coverage increased (+0.001%) to 87.634%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • 18 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

18 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/parse.rs 12 97.15%
crates/qasm2/src/lex.rs 5 92.29%
crates/qasm2/src/expr.rs 1 93.88%

Coverage Stats

Coverage Status
Relevant Lines: 128695
Covered Lines: 112780
Line Coverage: 87.63%
Coverage Strength: 999387.94 hits per line

💛 - Coveralls

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 20, 2026
@jakelishman
jakelishman added this pull request to the merge queue Jul 20, 2026
Merged via the queue into stable/2.5 with commit 7b6cb24 Jul 20, 2026
28 checks passed
@jakelishman
jakelishman deleted the mergify/bp/stable/2.5/pr-16599 branch July 20, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. mod: transpiler Issues and PRs related to Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants