Checkpoint: Run a QEC Cycle
This checkpoint puts the whole module together: take a genuine quantum superposition, protect it, damage it, and bring it back — all without ever learning what the logical state was. If your circuit works, you have implemented a complete quantum-error-correction cycle.
The cycle, end to end
A QEC cycle has four stages, and you have built each one separately in this module:
- Encode. Map the data qubit onto a logical codeword with the encoder
( then
cx(0,1); cx(0,2)for ). - Error. Noise strikes — here a single on qubit 2, the kind the bit-flip code is built to survive.
- Extract / decode. Run the encoder in reverse to gather the logical amplitude back onto the data qubit and expose the error as a syndrome on the partners.
- Correct. Use the syndrome to apply the recovery — a Toffoli vote that flips the data qubit only when both partners disagree with it.
Why it has to be coherent
The input is , an equal superposition. A scheme that measured an individual data qubit would collapse it and destroy the logical information. The decode-and-vote recovery uses only unitary gates, so by linearity it acts the same on as on the basis states: the logical amplitudes pass through untouched while the error is undone. This is the essence of QEC — repairing a state you are not allowed to look at.
What success looks like
After the cycle, qubit 0 is back in and qubits 1 and 2 hold the leftover syndrome of the corrected error. The full three-qubit statevector is therefore deterministic: two amplitudes of that differ only in the qubit-0 bit. That is the signature of a perfectly recovered logical .
Try it
Implement the four-step cycle: encode , inject on qubit 2, decode, and correct. The grader checks the recovered statevector — get the logical back onto qubit 0.
When the cycle is correct, the statevector shows exactly two populated amplitudes (indices 1 =
001 and 5 = 101), each , differing only in the qubit-0 bit. The logical
has survived a bit-flip error — a full QEC cycle, working.
Sign in on the full site to ask questions and join the discussion.