Skip to content

Avoid panics in Quantum Shannon Decomposition Rust code (backport #15635) - #15802

Merged
Jake Lishman (jakelishman) merged 2 commits into
stable/2.3from
mergify/bp/stable/2.3/pr-15635
Mar 12, 2026
Merged

Jake Lishman (jakelishman) merged 2 commits into
stable/2.3from
mergify/bp/stable/2.3/pr-15635

Conversation

@mergify

@mergify mergify Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

close #15610 .

Since iterative Quantum Shannon Decomposition may provide imprecise matrices, and the rust code may panic when calcualting SVD or Schur decompositions, we use the Isometry decomposition in such cases.

Details and comments


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

@mergify
mergify Bot requested a review from a team as a code owner March 12, 2026 20:47
@mergify mergify Bot added the conflicts used by mergify when there are conflicts in a port label Mar 12, 2026
@mergify

mergify Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 02fef9b has failed:

On branch mergify/bp/stable/2.3/pr-15635
Your branch is up to date with 'origin/stable/2.3'.

You are currently cherry-picking commit 02fef9ba2.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   releasenotes/notes/fix-panic-qsd-and-use-isometry-df29b8304951a586.yaml
	modified:   test/python/circuit/test_controlled_gate.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   crates/synthesis/src/qsd.rs
	both modified:   qiskit/circuit/library/generalized_gates/unitary.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@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:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia

@github-actions github-actions Bot added Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. mod: synthesis Rust This PR or issue is related to Rust code in the repository labels Mar 12, 2026
@github-actions github-actions Bot added this to the 2.3.1 milestone Mar 12, 2026
* catch rust panic errors in qs_decomposition

* add try/catch in qs_decompsition, and fall to Isometry if needed

* add test, based on issue 15610

* formatting

* add release notes

* add Isometry to the test

* Improving error handling for QSD synthesis

* Fix misprint

* enhance failed matrix test

* Changing RuntimeError to QiskitError

* comment

* not discarding info for CircuitDataError

* tightening try-except blocks

* further fix to avoid infinite recursion

* Update release note

---------

Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit 02fef9b)
@jakelishman
Jake Lishman (jakelishman) force-pushed the mergify/bp/stable/2.3/pr-15635 branch from 5e35a1d to f267d5f Compare March 12, 2026 21:03
@jakelishman Jake Lishman (jakelishman) removed the conflicts used by mergify when there are conflicts in a port label Mar 12, 2026
@jakelishman
Jake Lishman (jakelishman) added this pull request to the merge queue Mar 12, 2026
@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23024350432

Details

  • 22 of 27 (81.48%) changed or added relevant lines in 2 files are covered.
  • 22 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.009%) to 88.371%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/synthesis/src/qsd.rs 8 10 80.0%
qiskit/circuit/library/generalized_gates/unitary.py 14 17 82.35%
Files with Coverage Reduction New Missed Lines %
crates/circuit/src/parameter/parameter_expression.rs 1 82.42%
crates/circuit/src/parameter/symbol_expr.rs 1 74.0%
crates/qasm2/src/expr.rs 1 93.82%
crates/qasm2/src/lex.rs 7 91.77%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 23021600454: -0.009%
Covered Lines: 96746
Relevant Lines: 109477

💛 - Coveralls

Merged via the queue into stable/2.3 with commit 13d4ef7 Mar 12, 2026
25 checks passed
@jakelishman
Jake Lishman (jakelishman) deleted the mergify/bp/stable/2.3/pr-15635 branch March 12, 2026 22:28
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: synthesis Rust This PR or issue is related to Rust code in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants