Syndrome Measurement
A naive fix for a qubit error would be to measure the data qubits directly, but that collapses any superposition you are protecting. Syndrome measurement avoids this: you copy the parity of the data into a fresh ancilla qubit and measure only the ancilla. The data qubits remain untouched, and the ancilla outcome tells you whether an error occurred.
The parity trick
Consider two data qubits. Their parity is the XOR of their bit values:
| q0 | q1 | parity | |----|----|--------| | 0 | 0 | 0 | | 1 | 1 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 |
Parity 0 means the qubits agree (no single-qubit bit-flip error in the repetition code). Parity 1 means they disagree (a bit flip has occurred on exactly one qubit).
Extracting parity with CNOTs
A CNOT gate controlled on qubit and targeting qubit performs
where is addition modulo 2 (XOR). To extract the parity of two data qubits and into an ancilla (initialised to ), apply two CNOTs in sequence:
The ancilla now holds — the parity — while and are completely unchanged. Measuring the ancilla reveals the syndrome without disturbing the data register.
Worked example
Suppose a bit-flip error strikes , leaving the data register in (q0 = 1, q1 = 0).
- Start: .
- CNOT: ancilla flips because . State becomes .
- CNOT: ancilla does not flip because . State stays .
Measuring the ancilla always yields (parity = 1, error detected), while the data register stays in — ready for a correction step.
Try it
The starter code flips to model an error. Add the two CNOTs that copy the parity into the ancilla . The grader checks the full 3-qubit probability distribution, which should put all weight on .
After your circuit runs, the Probabilities panel should show a single bar at (index 5), confirming that the ancilla correctly reports the error without collapsing the data qubits.
Sign in on the full site to ask questions and join the discussion.