Qubits decohere and gates are imperfect, so a long computation needs a way to detect and undo errors without looking at the data. Classical codes copy bits and take a majority vote. Quantum states cannot be copied, and measuring them destroys them, so quantum error correction has to get the same protection from entanglement and indirect measurement. It is the reason people expect fault-tolerant machines to exist at all, and the reason they will need thousands of physical qubits per useful logical qubit.

Spread one qubit over many so a few mistakes can be spotted and fixed, like a team double-checking a sum. Image: Will Apodaca, CC BY-SA 4.0, via Wikimedia Commons.

Mental Model

  • Spread one logical qubit over many physical qubits, then measure parity checks (syndromes) that reveal where an error happened without revealing the encoded amplitudes.
  • No-cloning forbids copying , but it allows the entangled encoding .
  • Any single-qubit error is a combination of , , and , so correcting bit flips and phase flips corrects everything. Continuous errors get projected onto these discrete ones by the syndrome measurement.
  • Encoding only helps below a threshold: if physical error rates are too high, adding qubits adds more errors than it removes.

1. Why Classical Tricks Fail

The no-cloning theorem says no unitary maps to for every . So the repetition code “write the bit three times” cannot be applied to an unknown state. Reading out the qubits to compare them is no escape either, since a measurement collapses the superposition (Measurement and the Born Rule). Errors are also continuous, a small unwanted rotation rather than a clean flip, and there are two kinds to track: bit flips () and phase flips ().

2. The Three-Qubit Bit-Flip Code

Encode with two CNOTs from the data qubit onto two fresh qubits:

This is not three copies of the state. It is a GHZ-like entangled state, so no-cloning is respected. Now measure the two parities and , each with an ancilla. Each parity operator has eigenvalue on both and , so the measurement learns nothing about and . After an error on one qubit the two eigenvalues change as follows. I checked this with a Qiskit statevector for , .

ErrorFix
none+1+1none
-1+1apply
-1-1apply
+1-1apply

Applying the fix returns exactly . If each qubit flips independently with probability , the code fails when two or more flip, so the logical error rate is . At that is , about 34 times better. At it equals , and above that it is worse, a small-scale version of the threshold idea.

Common mistake

This code does nothing against errors. A phase flip on any one qubit gives , which all -parity checks accept.

3. The Phase-Flip Code

Apply Hadamards to all three qubits of the bit-flip code. The logical states become and , and a error acts as , which is a bit flip in this basis. The syndromes are and , and the table above holds with in place of (the same Qiskit check confirms it). The code now fixes one error and none of the errors.

4. Shor’s Nine-Qubit Code

Concatenate the two. Encode the qubit in the phase-flip code, then encode each of its three qubits in a bit-flip code. That gives nine physical qubits arranged as three blocks of three. Bit flips are caught inside each block, phase flips are caught by comparing blocks. A error is , so both layers act, and the code corrects any single-qubit error. This was the first proof that quantum error correction is possible (Shor, 1995). Better codes exist: the smallest that corrects an arbitrary single-qubit error uses five qubits.

5. Stabilizers in One Section

The checks above are an instance of a general pattern. A stabilizer code is defined by a group of commuting Pauli operators (the stabilizers). The code space is the set of states with for all . For the bit-flip code the group is generated by and .

An error that anticommutes with some flips that check’s measured value, so the list of outcomes is the syndrome. The decoder maps a syndrome to the most likely error and applies the inverse. An error that commutes with every stabilizer but is not itself in the group (a logical operator, like in the bit-flip code) is invisible and corrupts the data. The code distance is the weight of the smallest such operator, and the code corrects up to errors. Because stabilizer measurements are just Pauli measurements, hardware only needs a small gate set to run them.

6. The Surface Code

The surface code puts data qubits on a 2D grid with alternating -type and -type stabilizers on the faces, each touching four neighbors. That fits the nearest-neighbor connectivity of superconducting chips (Qubit Hardware Platforms). A distance- patch uses data qubits and measurement qubits, so in total: 17 for , 49 for , 241 for .

Below a threshold error rate , which is roughly 1% for the circuit-level noise models usually quoted (an approximate figure that depends on the noise model and decoder), the logical error rate falls as a rough scaling

With this gives at , at , and at . Real prefactors differ, so treat these as orders of magnitude. Each increase of by two multiplies the logical error rate by a constant factor below one, so the qubit overhead grows only polynomially with the target accuracy.

7. Overhead

Fault-tolerant algorithms need logical qubits plus extra space for gates and for distilling the non-Clifford gates (T gates) that stabilizer codes cannot perform directly. With a surface code at to 25 the cost is hundreds to over a thousand physical qubits per logical qubit. Factoring a large RSA number (Shor’s Algorithm) therefore points at millions of physical qubits, and current devices have hundreds to low thousands. Other codes with higher encoding rates are active research, but the connectivity they need is harder to build.

8. Mitigation vs Correction

Error mitigation runs the noisy circuit anyway and removes the bias in post-processing, for example by extrapolating to zero noise or by cancelling known noise channels. It needs no extra qubits, but its sampling cost grows exponentially with circuit size, and it gives expectation values, not a protected quantum state. Error correction keeps the state itself intact and scales polynomially, but only works below threshold and costs many qubits. Today’s experiments use mitigation. See Error Mitigation with Samplomatic for the lab version.