What should we add?
Users commonly split a QuantumCircuit at full-width barriers, run or inspect the resulting slices, then recombine those slices. If the circuit includes measurements, each measurement must remain connected to the same classical bit/register after slicing and recombination.
Problem
When slicing circuits that include measurements, the slicing/recombination flow should preserve:
- classical registers,
- classical bits,
- measurement cargs,
- and the mapping from each measured qubit to its original classical bit/register.
If this mapping is dropped or recreated incorrectly, the recombined circuit may no longer be semantically equivalent to the original measured circuit.
Expected behavior
Given a circuit such as:
from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit_addon_utils.slicing import combine_slices, slice_by_barriers
qreg = QuantumRegister(3, "q")
creg_a = ClassicalRegister(1, "a")
creg_b = ClassicalRegister(2, "b")
qc = QuantumCircuit(qreg, creg_a, creg_b)
qc.h(qreg[0])
qc.measure(qreg[0], creg_b[1])
qc.barrier()
qc.cx(qreg[0], qreg[1])
qc.measure(qreg[1], creg_a[0])
qc.measure(qreg[2], creg_b[0])
slices = slice_by_barriers(qc)
recombined = combine_slices(slices)
The recombined circuit should preserve the same measurement targets:
- q[0] -> b[1]
- q[1] -> a[0]
- q[2] -> b[0]
and should preserve the original classical-register structure.
What should we add?
Users commonly split a
QuantumCircuitat full-width barriers, run or inspect the resulting slices, then recombine those slices. If the circuit includes measurements, each measurement must remain connected to the same classical bit/register after slicing and recombination.Problem
When slicing circuits that include measurements, the slicing/recombination flow should preserve:
If this mapping is dropped or recreated incorrectly, the recombined circuit may no longer be semantically equivalent to the original measured circuit.
Expected behavior
Given a circuit such as:
The recombined circuit should preserve the same measurement targets:
and should preserve the original classical-register structure.