Skip to content

QPY: Bug fix in Rust implementation of SparsePauliObservableElemPack - #16788

Open
gadial wants to merge 2 commits into
Qiskit:mainfrom
gadial:qpy_sparse_observable_fix
Open

QPY: Bug fix in Rust implementation of SparsePauliObservableElemPack#16788
gadial wants to merge 2 commits into
Qiskit:mainfrom
gadial:qpy_sparse_observable_fix

Conversation

@gadial

@gadial gadial commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug in the way Rust QPY serializes and deserializes SparsePauliObservableElemPack.

Fixes #16722

Details

When serializing SparsePauliObservableElemPack, there are several lists of elements being serialized. While Rust stored the lengths of the lists, Python stored the actual sizes of the serialized lists. It is possible to make sure Rust conforms to this serialization by dividing and multiplying by the correct factors (dependent on the known sizes of the stored elements).

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:

@gadial gadial added the mod: qpy Related to QPY serialization label Aug 18, 2026
@ShellyGarion ShellyGarion added the Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. label Aug 18, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 32117132256

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.04%) to 87.818%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 11 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

11 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/lex.rs 6 92.29%
crates/circuit/src/parameter/symbol_expr.rs 4 77.84%
crates/circuit/src/parameter/parameter_expression.rs 1 90.32%

Coverage Stats

Coverage Status
Relevant Lines: 129633
Covered Lines: 113841
Line Coverage: 87.82%
Coverage Strength: 995206.1 hits per line

💛 - Coveralls

@gadial
gadial marked this pull request as ready for review August 18, 2026 09:16
@gadial
gadial requested a review from a team as a code owner August 18, 2026 09:16
@gadial
gadial requested a review from Cryoris August 18, 2026 09:16
@qiskit-bot

Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core
  • @mtreinish

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: qpy Related to QPY serialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QPY SparseObservable Payload Implementations Diverge Between Rust and Python

4 participants