Skip to content

Fix memory leak in Suzuki-Trotter synthesis (backport #16687) - #16739

Merged
Cryoris merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16687
Aug 11, 2026
Merged

Fix memory leak in Suzuki-Trotter synthesis (backport #16687)#16739
Cryoris merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-16687

Conversation

@mergify

@mergify mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This Pull request contains changes that will solve the #16677 issue .

The .leak() in file crates/circuit_library/src/suzuki_trotter.rs was only needed because sparse_term_evolution tied the returned iterator's lifetime to the input string. That tie is unnecessary as the function immediately copies everything it needs out of pauli (pauli.to_lowercase() and the derived owned paulis/indices) and never borrows from it afterwards. So I removed the lifetime bound from the crates/synthesis/src/pauli_evolution.rs file

Testing suzuki_trotter file :
cargo +nightly miri test -p qiskit-circuit-library suzuki_trotter::test::test_suzuki_trotter -- --nocapture

running 1 test
test suzuki_trotter::test::test_suzuki_trotter ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.50s

Other Testing results :
cargo test -p qiskit-synthesis — passed
cargo test -p qiskit-circuit-library — passed
cargo +nightly miri test -p qiskit-synthesis — no UB/memory issues
cargo +nightly miri test -p qiskit-circuit-library — no UB/memory issues

Fixes #16677

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 #16687 done by [Mergify](https://mergify.com).

* Refactor sparse_term_evolution function signature to remove lifetime parameter

* Added : Rust test as requested by Cryoris

* Added : Bugfix release notes as requested

* Shorten reno

* Update suzuki_trotter.rs

solution for linting error

* final lint issue resolved

* update : added unwrap to handle the return from add_dense_lable this resolves the linting error

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Julien Gacon <jules.gacon@googlemail.com>
(cherry picked from commit fbb33ad)
@mergify
mergify Bot requested a review from a team as a code owner August 11, 2026 15:40
@mergify
mergify Bot requested a review from raynelfss August 11, 2026 15:40
@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

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31508354574

Coverage increased (+0.07%) to 87.741%

Details

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

Uncovered Changes

No uncovered changes found.

Coverage Regressions

3 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/lex.rs 3 92.54%

Coverage Stats

Coverage Status
Relevant Lines: 128766
Covered Lines: 112981
Line Coverage: 87.74%
Coverage Strength: 997715.06 hits per line

💛 - Coveralls

@github-actions github-actions Bot added Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. Community PR PRs from contributors that are not 'members' of the Qiskit repo labels Aug 11, 2026
@github-actions github-actions Bot added this to the 2.5.2 milestone Aug 11, 2026
@Cryoris
Cryoris added this pull request to the merge queue Aug 11, 2026
Merged via the queue into stable/2.5 with commit ef2f2c7 Aug 11, 2026
32 of 33 checks passed
@Cryoris
Cryoris deleted the mergify/bp/stable/2.5/pr-16687 branch August 11, 2026 16:54
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. Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants