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

Force at least one classical bit in qpd_measurements register #563

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions circuit_knitting/cutting/qpd/decompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def _decompose_qpd_measurements(
if instruction.operation.name.lower() == "qpd_measure"
]

# Create a classical register for the qpd measurement results. This is
# partly for convenience, partly to work around
# https://github.com/Qiskit/qiskit-aer/issues/1660.
reg = ClassicalRegister(len(qpd_measure_ids), name="qpd_measurements")
# Create a classical register for the qpd measurement results.
# We force at least one classical bit as a workaround to
# https://github.com/openqasm/qe-qasm/issues/37.
reg = ClassicalRegister(max(1, len(qpd_measure_ids)), name="qpd_measurements")
circuit.add_register(reg)

# Place the measurement instructions
Expand Down
6 changes: 3 additions & 3 deletions test/cutting/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ def test_decompose_qpd_instructions(self):
with self.subTest("Empty circuit"):
circ = QuantumCircuit()
new_circ = decompose_qpd_instructions(QuantumCircuit(), [])
circ.add_register(ClassicalRegister(0, name="qpd_measurements"))
circ.add_register(ClassicalRegister(1, name="qpd_measurements"))
self.assertEqual(circ, new_circ)
with self.subTest("No QPD circuit"):
circ = QuantumCircuit(2, 1)
circ.h(0)
circ.cx(0, 1)
circ.measure(1, 0)
new_circ = decompose_qpd_instructions(circ, [])
circ.add_register(ClassicalRegister(0, name="qpd_measurements"))
circ.add_register(ClassicalRegister(1, name="qpd_measurements"))
self.assertEqual(circ, new_circ)
with self.subTest("Single QPD gate"):
circ = QuantumCircuit(2)
Expand All @@ -165,7 +165,7 @@ def test_decompose_qpd_instructions(self):
qpd_gate = TwoQubitQPDGate(qpd_basis)
circ.data.append(CircuitInstruction(qpd_gate, qubits=[0, 1]))
decomp_circ = decompose_qpd_instructions(circ, [[0]], map_ids=[0])
circ_compare.add_register(ClassicalRegister(0, name="qpd_measurements"))
circ_compare.add_register(ClassicalRegister(1, name="qpd_measurements"))
self.assertEqual(decomp_circ, circ_compare)
with self.subTest("Incorrect map index size"):
with pytest.raises(ValueError) as e_info:
Expand Down