Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SparsePauliOp initialization with dense Y labels (backport #13580) #13611

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 6, 2025

Summary

Fixes #13522

"When a SparsePauliOp object is instantiated with a long string of Y's (greater than 100), the imaginary component of the coefficients is non-zero (but trivially small, ~1e-15). This results in errors when submitting jobs using qiskit-ibm-runtime which throws an error when using the SparsePauliOp as the expectation value to estimate."

The fix to the above problem involved using modular arithmetic to calculate coeffs for the SparsePauliOp when coeffs is None. This avoids the floating point error that occurs for instantiating heavy-weight SparsePauliOps.

Details and comments

Added a test method test_sparse_pauli_op_init_long_ys to ensure that the error causing PauliList ('Y"*100) results with the same coeffs as PauliList ("Y"*99)


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

* used modular arithmetic to fix floating point error in heavy-weight sparse_pauli_op

* fix comments

* reformatted

* added release notes and addressed comments

* addressed comments

* formatted

* addressed comments

* addressed comments

* addressed all comments

* formatted

(cherry picked from commit 136aaff)
@mergify mergify bot requested a review from a team as a code owner January 6, 2025 09:46
@qiskit-bot
Copy link
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 Changelog: Bugfix Include in the "Fixed" section of the changelog mod: quantum info Related to the Quantum Info module (States & Operators) Community PR PRs from contributors that are not 'members' of the Qiskit repo labels Jan 6, 2025
@Cryoris Cryoris enabled auto-merge January 6, 2025 09:53
@coveralls
Copy link

Pull Request Test Coverage Report for Build 12630239854

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.006%) to 88.947%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.2%
crates/qasm2/src/lex.rs 5 91.98%
Totals Coverage Status
Change from base Build 12422294534: 0.006%
Covered Lines: 79148
Relevant Lines: 88983

💛 - Coveralls

@Cryoris Cryoris added this pull request to the merge queue Jan 6, 2025
Merged via the queue into stable/1.3 with commit 768bd04 Jan 6, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: quantum info Related to the Quantum Info module (States & Operators)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants