Skip to content

Implement SparseObservable.evolve - #15561

Merged
Alexander Ivrii (alexanderivrii) merged 34 commits into
Qiskit:mainfrom
aaryav-3:evolve_sparseobservable
Mar 18, 2026
Merged

Alexander Ivrii (alexanderivrii) merged 34 commits into
Qiskit:mainfrom
aaryav-3:evolve_sparseobservable

Conversation

@aaryav-3

@aaryav-3 Aaryav (aaryav-3) commented Jan 13, 2026 •

Copy link
Copy Markdown

Summary

Fixes #13763
This PR adds support for efficient evolution of SparseObservable objects under conjugation by single-term operators via a new :meth:SparseObservable.evolve API.
The implementation introduces an efficient, deterministic conjugation based on a precomputed lookup table for single-qubit BitTerm conjugation. Support for partial and non-contiguous evolution through optional qargs has been added, and so has the edge-case to handle scalar (0-qubit) operators. (Identity)
Further work could be done to support evolution via Cliffords, and Pauli Lists (as these cannot be coerced to a :class:SparseObservable by default), and also support cross-term conjugations (for BitTerm Operators with num_terms > 1, i.e. a sum of terms) can be added in a later PR

  • I have added the tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

AI tool used: Claude Sonnet 4.5 (on Browser) for Lookup table generator script, and automated testing of the same.

@aaryav-3
Aaryav (aaryav-3) requested a review from a team as a code owner January 13, 2026 13:09
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jan 13, 2026
@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

@aaryav-3 Aaryav (aaryav-3) changed the title Evolve sparseobservable Evolve SparseObservable Jan 13, 2026
@coveralls

Coveralls (coveralls) commented Jan 13, 2026 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21390225658

Details

  • 135 of 148 (91.22%) changed or added relevant lines in 3 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 87.991%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/cext/src/exit_codes.rs 0 1 0.0%
crates/quantum_info/src/sparse_observable/mod.rs 120 132 90.91%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.82%
crates/qasm2/src/lex.rs 4 91.77%
Totals Coverage Status
Change from base Build 21389396184: 0.02%
Covered Lines: 100177
Relevant Lines: 113849

💛 - Coveralls

@Cryoris Julien Gacon (Cryoris) 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.

Thanks for the modifications! I didn't have a look at how the evolve logic is implemented yet, but here's already comments on the interface and some tests.

@Cryoris Julien Gacon (Cryoris) added Changelog: Added Add an "Added" entry in the GitHub Release changelog. mod: quantum info Related to the Quantum Info module (States & Operators) and removed Community PR PRs from contributors that are not 'members' of the Qiskit repo labels Jan 20, 2026

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.

I created a script to generate the table independently and compared it to the one in the PR - all seems good to me. I approve.

@Cryoris Julien Gacon (Cryoris) changed the title Evolve SparseObservable Implement SparseObservable.evolve Mar 18, 2026
- docs were failing
- remove some test dups and dangling comments
- more efficient qargs duplicate check

@Cryoris Julien Gacon (Cryoris) 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.

Thanks for the contribution Aaryav (@aaryav-3) and thanks for the review Gadi Aleksandrowicz (@gadial) 🙂 There's some minor improvements we can do on the error handling here but nothing to hold the feature off on.

@Cryoris
Julien Gacon (Cryoris) added this pull request to the merge queue Mar 18, 2026
@alexanderivrii
Alexander Ivrii (alexanderivrii) removed this pull request from the merge queue due to a manual request Mar 18, 2026
Merged via the queue into Qiskit:main with commit ff2ee35 Mar 18, 2026
25 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Qiskit 2.4 Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Added Add an "Added" entry in the GitHub Release changelog. mod: quantum info Related to the Quantum Info module (States & Operators)

Projects

Archived in project
Status: Done

Development

Successfully merging this pull request may close these issues.

Implement SparseObservable.evolve

7 participants