Description
Currently, qubits that don't end in a measurement must be right-dressed at the end of a circuit to catch any virtual gates. This is treated as necessary so that, after the build() process, the template circuit bound with a randomization is logically equivalent to the input circuit.
Since this isn't an observable effect on the executed circuit (how could it be if the qubits are not measured?), we should reconsider this requirement. The upside to maintaining logical equivalence is that it's easier to check if everything is working just by looking at operator equivalence of the simulated circuit, though this is already broken today because we don't expect operator equivalence when measurements are present due to measurement twirling. The downside is that it can add overhead in some situations by inserting empty boxes to collect virtual gates: 1) these empty boxes actually require dressing gates to be implemented, and 2) users need to manually deselect them during mitigation to avoid their learning and gamma overhead.
Further,
- Everything above about "end of circuit" also applies to qubits directly before a reset operation.
- If we go all the way with this, we could maybe even completely deprecate the concept of right-dressing.
Acceptance criteria
If "reconsider" gets decided as "keep logical equivalence", then just close this issue.
Otherwise, circuits like this should be valid:
circuit = QuantumCircuit(5, 2)
with circuit.box([Twirl()]):
circuit.noop(range(5))
with circuit.box([Twirl()]):
circuit.cx(0, 1)
with circuit.box([Twirl()]):
circuit.measure([0,1], [0, 1])
The transpiler will need to be updated too, to either select whether or not to terminate with right-dressing, or if we deprecate right-dressing entirely, to not right-dress any more.
There are probably a laundry list of other things to do like update the docs as this is a fairly deep change.
Description
Currently, qubits that don't end in a measurement must be right-dressed at the end of a circuit to catch any virtual gates. This is treated as necessary so that, after the
build()process, the template circuit bound with a randomization is logically equivalent to the input circuit.Since this isn't an observable effect on the executed circuit (how could it be if the qubits are not measured?), we should reconsider this requirement. The upside to maintaining logical equivalence is that it's easier to check if everything is working just by looking at operator equivalence of the simulated circuit, though this is already broken today because we don't expect operator equivalence when measurements are present due to measurement twirling. The downside is that it can add overhead in some situations by inserting empty boxes to collect virtual gates: 1) these empty boxes actually require dressing gates to be implemented, and 2) users need to manually deselect them during mitigation to avoid their learning and gamma overhead.
Further,
Acceptance criteria
If "reconsider" gets decided as "keep logical equivalence", then just close this issue.
Otherwise, circuits like this should be valid:
The transpiler will need to be updated too, to either select whether or not to terminate with right-dressing, or if we deprecate right-dressing entirely, to not right-dress any more.
There are probably a laundry list of other things to do like update the docs as this is a fairly deep change.