Mutable SingletonGate
s are modified when passed through pickle serialization and deserialization
#10915
Labels
bug
Something isn't working
Environment
main
branch withSingletonGate
addition)What is happening?
pickle.load
's default procedure is to callcls.__new__(cls)
to generate an object. SinceSingletonGate
overrides__new__
and behaves differently based on the arguments to__new__
,pickle.load
will generate an immutable object even when the pickled object was mutable (sinceSingletonGate(*args, **kwargs)
pass the arguments to__new__
and__init__
butpickle.load
does not by default).How can we reproduce the issue?
This gives:
What should happen?
A mutable
SingletonGate
should pass through pickle and still have the same duration, condition, label, and unit.Any suggestions?
This is fixed in #10871. I Just wanted to make an issue about it to refer to.
This issue was discovered by a test in qiskit-experiments that used a conditional gate. When the circuits using the conditonal gate were transpiled on Linux, the circuits were passed through pickle as part of Python's multiprocessing and the conditional gate lost its condition.
The text was updated successfully, but these errors were encountered: