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

qpy.dump fails for circuit with large PauliLinbdladError #13458

Open
aeddins-ibm opened this issue Nov 19, 2024 · 0 comments
Open

qpy.dump fails for circuit with large PauliLinbdladError #13458

aeddins-ibm opened this issue Nov 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@aeddins-ibm
Copy link
Contributor

Environment

  • Qiskit version: 1.3.0rc1
  • Python version: 3.11
  • Operating system: macos

What is happening?

Similar to #13457.

I'd like to use qpy to save to disk a QuantumCircuit to which a many-qubit PauliLindbladError has been appended (as a 'quantum_channel' instruction).

qpy.dump tries to access the definition attribute of the 'quantum_channel' instruction, which tries to express the error channel as a Kraus object, which involves constructing the object as a SuperOp, which requires some astronomical amount of memory. Since appending PauliLindbladError seems like a nicely portable means of constructing a noisy circuit, it would be convenient if the noisy circuit could be saved to disk.

How can we reproduce the issue?

from qiskit import qpy
from qiskit_aer.noise.errors import PauliLindbladError

qc = QuantumCircuit(20)
qc.cx(0,1)
qc.cx(0,1)
qc.append(PauliLindbladError(generators=['X'+'I'*19],rates=[0.1]),range(20))

with open('circuit_filename','wb') as f:
    qpy.dump(qc, f)

Out:

ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.

What should happen?

Would be nice to be able to add large error channels (such as appending PauliLindbladError) to a circuit, and save/load that circuit using qpy.

Any suggestions?

I'm not sure if this should be fixed in Qiskit (don't have qpy unpack the definition of the 'quantum_channel' instruction's operation?), or in Aer (change the definition of the 'quantum_channel' to be a sequence of sparse Pauli channels instead of one huge channel?), or somewhere else. I'm not very familiar with qpy, but naively I'd wonder if it's possible to avoid looking at the channel's definition and just leave the instructions in their original forms, which seems desirable. OTOH, apparently any attempt to access the definition will raise this error, which seems like a more general problem independent of qpy specifically.

Whatever the means, it would be nice to have a way to compactly save a QuantumCircuit containing sparse Pauli-Lindblad noise.

@aeddins-ibm aeddins-ibm added the bug Something isn't working label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant