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

Deserializing a SingleQubitQPDGate results in a generic Instruction #444

Open
garrison opened this issue Oct 30, 2023 · 0 comments
Open
Labels
cutting QPD-based circuit cutting code qpd Related to quasi-probability decompositions serialization Related to serialization of our custom objects

Comments

@garrison
Copy link
Member

With #417 solved by #442, it is now possible to serialize a SingleQubitQPDGate. However, when it is unserialized by qpy, the result is of type Instruction rather than SingleQubitQPDGate. It should be a SingleQubitQPDGate after a serialization/deserialization round trip.

Here's a minimum working example:

import io
from qiskit import QuantumCircuit, qpy

from circuit_knitting.cutting import partition_problem

qc = QuantumCircuit(4)
qc.cx(1, 2)

partitioned_problem = partition_problem(circuit=qc, partition_labels="AABB")
qc = partitioned_problem.subcircuits["A"]

f = io.BytesIO()
qpy.dump(qc, f)
qc2 = qpy.load(io.BytesIO(f.getvalue()))[0]

print(type(qc.data[0].operation))
print(type(qc2.data[0].operation))

gives the following output

<class 'circuit_knitting.cutting.qpd.instructions.qpd_gate.SingleQubitQPDGate'>
<class 'qiskit.circuit.instruction.Instruction'>

This, of course, has some implications: the resulting instructions don't actually behave like SingleQubitQPDGates, even though they have the correct name.

We should find a way to fix this.

@garrison garrison added qpd Related to quasi-probability decompositions cutting QPD-based circuit cutting code serialization Related to serialization of our custom objects labels Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cutting QPD-based circuit cutting code qpd Related to quasi-probability decompositions serialization Related to serialization of our custom objects
Projects
None yet
Development

No branches or pull requests

1 participant