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

SparsePauliOp incorrectly sets non-zero imaginary component #13522

Open
kaelynj opened this issue Dec 3, 2024 · 2 comments · May be fixed by #13580
Open

SparsePauliOp incorrectly sets non-zero imaginary component #13522

kaelynj opened this issue Dec 3, 2024 · 2 comments · May be fixed by #13580
Assignees
Labels
bug Something isn't working mod: quantum info Related to the Quantum Info module (States & Operators)

Comments

@kaelynj
Copy link

kaelynj commented Dec 3, 2024

Environment

  • Qiskit version: 1.3.0
  • Python version: 3.11.7
  • Operating system: Fedora 40

What is happening?

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.

How can we reproduce the issue?

from qiskit.quantum_info import SparsePauliOp
# produces non-zero imaginary component
yyy = SparsePauliOp('Y'*100)
print(yyy.coeffs)
# correctly contains no imaginary component
yy = SparsePauliOp('Y'*99)
print(yy.coeffs)

What should happen?

A high-weight SparsePauliOp, when no coefficients are specified, should possess coeffcients = [1.0, 0.0]

Any suggestions?

No response

@kaelynj kaelynj added the bug Something isn't working label Dec 3, 2024
@kaelynj kaelynj changed the title Non-zero imaginary component Incorrectly set non-zero imaginary component in SparsePauliOp Dec 3, 2024
@kaelynj kaelynj changed the title Incorrectly set non-zero imaginary component in SparsePauliOp SparsePauliOp incorrectly sets non-zero imaginary component Dec 3, 2024
@trigpolynom
Copy link
Contributor

I'd like to take this on if that is okay

@ShellyGarion ShellyGarion added the mod: quantum info Related to the Quantum Info module (States & Operators) label Dec 15, 2024
@trigpolynom
Copy link
Contributor

trigpolynom commented Dec 18, 2024

Got a draft PR #13580. Mind taking a look at the approach to the fix? @kaelynj @ShellyGarion @Cryoris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: quantum info Related to the Quantum Info module (States & Operators)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants