You are reading without signing in. Sign in or continue as guest to take quizzes and keep XP.
Measuring in the middle
What changes when a measurement is followed by more gates, and why statevector tools step aside.
- Describe the state after a mid-circuit measurement as a branch, not a vector.
- Explain why QubitLab's State tab shows one statevector per branch.
- Reset and reuse a qubit.
Until now every measurement came last. Put one in the middle and the circuit splits: in the shots where the bit read 0 the remaining qubits are in one state, in the shots where it read 1 they are in another. There is no longer a single statevector for 'the circuit', only one per branch, weighted by how often that branch occurs.
One state per branch
Open the State tab. Two branch chips appear (c = 0 and c = 1, about 50% each); pick one to see the statevector of the untouched qubit for that branch.
OPENQASM 3.0; include "stdgates.inc"; qubit[2] q; bit[2] c; h q[0]; c[0] = measure q[0]; h q[1]; x q[0];
A measured qubit is not spent. `reset q[0];` returns it to |0⟩ whatever was read, so a short-lived helper qubit (an ancilla) can be used again and again. Many error-correction codes measure and reset the same ancillas thousands of times.
After a mid-circuit measurement, the best description of the register is…
Sign in to answer and earn XP; you will come back to this lesson.
Why can't the gate-by-gate debugger trace a dynamic circuit?
Sign in to answer and earn XP; you will come back to this lesson.
A mid-circuit measurement splits the run into branches. Reason per branch, simulate with shots, and reuse qubits with reset.
Up next: if / else on a measured bit