You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a deepcopy of a circuit object using a clbit as a standalone bit as the condition for a control flow operation results in the deepcopied circuit being invalid so that qasm3 or qpy serialization, and visualization will fail because the internal state of the circuit is corrupted and not valid in the copy.
It should print the visualization of the circuit. This will stack trace though during the circuit to dag conversion. You can also replace print(copy_qc) with something like:
import io
from qiskit.qpy import dump
with io.BytesIO() as fd:
dump(copy_qc, fd)
this will also fail on a lookup of the clbit.
Any suggestions?
I think the special __deepcopy__ handling in the qiskit.circuit.Instruction class is not valid for the ControlFlowOp when the .condition attribute is a clbit. It might just be simplest to revert to the default deepcopy behavior for ControlFlowOp.
The text was updated successfully, but these errors were encountered:
It's the Bit instances that are the problem here, really - a deepcopy of an immutable object should return itself. If we make Bit.__deepcopy__ and __copy__ return self, it should all automatically fix itself.
The handling would fail for a deep-copied regular instruction with a single clbit condition as well, there's just not really any point in our tests where we'd try and and see the failure.
Environment
What is happening?
When running a deepcopy of a circuit object using a clbit as a standalone bit as the condition for a control flow operation results in the deepcopied circuit being invalid so that qasm3 or qpy serialization, and visualization will fail because the internal state of the circuit is corrupted and not valid in the copy.
How can we reproduce the issue?
What should happen?
It should print the visualization of the circuit. This will stack trace though during the circuit to dag conversion. You can also replace
print(copy_qc)
with something like:this will also fail on a lookup of the clbit.
Any suggestions?
I think the special
__deepcopy__
handling in theqiskit.circuit.Instruction
class is not valid for theControlFlowOp
when the.condition
attribute is a clbit. It might just be simplest to revert to the default deepcopy behavior forControlFlowOp
.The text was updated successfully, but these errors were encountered: