Project: A Full QEC Demo
A single error-correcting gate is not error correction — a real demo runs the full cycle: encode a logical qubit, let an error strike, extract a syndrome without disturbing the encoded information, and apply the correction the syndrome names. This capstone wires all four stages together for the three-qubit bit-flip code, the simplest code that actually fixes an error.
The code and its codewords
The bit-flip code spreads one logical qubit across three physical qubits:
A general logical state is encoded from a prepared data qubit by two CNOTs. Here we encode the logical :
built by H(0); CX(0,1); CX(0,2).
Syndrome extraction without measurement collapse
The stabilizers are and . Rather than measuring the data qubits (which would collapse the superposition), we copy each parity onto a fresh ancilla with CNOTs:
Each ancilla flips once per data qubit involved in its check. The encoded superposition is left intact because the parity of a valid codeword is identical across both branches and — the ancilla learns only the error, not the logical amplitude.
A worked round
Inject on the middle data qubit. It participates in both checks, so both ancillas flip, giving syndrome . The decoder for this code maps "flip qubit 1," and applying again restores the codeword:
Try it
Build the four stages — encode, inject , extract the syndrome, correct — on the 5-qubit register. The grader checks the final statevector: the data block back in and the ancillas holding the syndrome .
Sign in on the full site to ask questions and join the discussion.