Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 39 ยท Noise and Error Correction

Stabilizer Codes, the Steane Code and Surface Codes

Learn the stabilizer formalism, decode the 7-qubit Steane code with Pauli syndromes, and see how surface codes scale error protection with distance.

Shor's nine-qubit code showed that quantum error correction is possible, but it is wasteful and awkward to reason about. The stabilizer formalism, introduced by Daniel Gottesman, gives a compact way to describe most useful codes. Instead of listing code states, you list a set of Pauli operators that leave every code state unchanged. Errors are then detected by checking which of those operators they anticommute with.

This lesson explains stabilizers, works through the 7-qubit Steane code, and then introduces the surface code, the leading candidate for large-scale quantum computers.

Stabilizers in one paragraph

A Pauli string is a tensor product of I, X, Y, Z, such as XZZXI. Two Pauli strings either commute or anticommute. A stabilizer group S is a set of mutually commuting Pauli strings (not containing -I). The code space is the set of states that every element of S leaves unchanged (eigenvalue +1). If a code uses n physical qubits and the group has n - k independent generators, it encodes k logical qubits. This is written [[n, k, d]], with d the distance: the smallest weight of an error that acts non-trivially on the encoded data. A code corrects floor((d-1)/2) arbitrary errors.

Detecting an error E: measure each generator g. If E commutes with g you get +1; if they anticommute you get -1. The list of results is the syndrome. Importantly, measuring generators never touches the logical information.

Examples you have already met: the 3-qubit bit-flip code has generators ZZI and IZZ and is [[3, 1, 1]] against general errors (but distance 3 against X errors only). Shor's code is [[9, 1, 3]].

The Steane code [[7, 1, 3]]

The Steane code is built from the classical Hamming code. Take the parity-check matrix H of the Hamming code, whose columns are the numbers 1 to 7 in binary:

Text
H = 0 0 0 1 1 1 1
    0 1 1 0 0 1 1
    1 0 1 0 1 0 1

There are six stabilizer generators: each row of H as a product of X operators and again as a product of Z operators. For example, the first row gives IIIXXXX and IIIZZZZ. Because it uses X-only and Z-only generators, it is a CSS code (Calderbank-Shor-Steane): X errors are caught by the Z generators and vice versa.

The beautiful property: a single X error on qubit i flips the syndrome bits that match the binary digits of i + 1. Read the syndrome as a binary number and you get the qubit position directly.

Python Decode every single-qubit error of the Steane code

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The Steane code needs only 7 qubits (against Shor's 9) and is a standard textbook example. It also has useful transversal gates: Hadamard, S and CNOT act on each physical qubit separately, so an error on one qubit cannot spread through the gate.

Why not just make bigger and bigger codes?

Bigger distance means better protection but also more qubits, more complex syndrome circuits and more places for new errors to enter. The measurement process itself is noisy. A practical code needs:

  • Local checks: stabilizers that involve only a few nearby qubits, since hardware usually has only nearest-neighbor connections.
  • A high threshold: the highest physical error rate at which increasing the distance still helps.
  • Efficient decoding: a fast classical algorithm that turns the syndrome history into a correction.

The surface code

The surface code places data qubits on the vertices of a square grid and ancilla qubits on faces and vertices. Two kinds of stabilizers, each touching four neighboring data qubits:

  • Plaquette (Z-type) checks detect X errors.
  • Star (X-type) checks detect Z errors.

A distance-d rotated surface code uses d^2 data qubits and d^2 - 1 ancillas, about 2d^2 - 1 in total, to store one logical qubit. Errors appear as pairs of flipped syndrome bits at the ends of an error chain. A decoder pairs up the flagged syndromes (minimum-weight perfect matching is the classic method) and applies the correction along the shortest chain. The code fails only if an error chain stretches across the whole lattice, which needs at least d errors in a row.

flowchart TB
    A["Data qubits on a grid"] --> B["Measure X and Z stabilizers repeatedly"]
    B --> C["Syndrome history (flagged checks)"]
    C --> D["Decoder: match flagged checks"]
    D --> E["Track corrections in software"]
    E --> B

Surface-code cycle: measure, decode, track corrections, repeat every microsecond or so.

Key facts:

  • The threshold is around 1% for circuit-level noise with good decoders, which is near today's best hardware.
  • Below threshold, the logical error rate falls roughly as (p / p_th)^((d+1)/2). Each increase of d by 2 multiplies protection by a constant factor.
  • Only nearest-neighbor gates in 2D are needed, which suits superconducting chips.
  • Logical gates other than Clifford ones (like T) need extra resources, usually magic state distillation, which can dominate the total qubit count.
  • Experimental teams have shown that going from distance 3 to 5 to 7 reduces the logical error rate, evidence that the machines are below threshold.
Python Scaling: how many physical qubits for a logical qubit?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

These estimates explain the headline numbers: with 0.1% physical error, one very reliable logical qubit (error 1e-12) costs about a thousand physical qubits, and a useful algorithm with thousands of logical qubits needs millions. Lowering the physical error rate (from 0.3% to 0.03%) shrinks that overhead dramatically.

Other code families

  • Color codes allow more transversal gates in 2D.
  • Quantum LDPC codes (including recent "bivariate bicycle" codes) promise much higher rates, encoding many logical qubits per block, but need longer-range connections.
  • Bosonic codes (cat codes, GKP codes) encode a qubit in an oscillator mode to get hardware-level protection before adding a conventional code.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does [[n, k, d]] mean?

    The notation counts physical qubits, logical qubits and code distance.
  2. 2. How is an error detected in the stabilizer formalism?

    Generators the error anticommutes with return -1; the list of results is the syndrome.
  3. 3. In the Steane code, a single X error gives syndrome 101 (binary). Which qubit has the error (counting from 1)?

    The syndrome is the binary number of the qubit position: 101 is 5.
  4. 4. What happens to the surface code's logical error rate as distance grows, below threshold?

    p_L scales like (p/p_th)^((d+1)/2), so every step of 2 in d multiplies the protection.
  5. 5. Why is the surface code popular for hardware?

    Locality and a threshold near 1% match superconducting chips, though the overhead is large.

Summary

  • A stabilizer code is defined by commuting Pauli generators; errors are found from the pattern of anticommutation (the syndrome).
  • The Steane code [[7,1,3]] uses the Hamming code, and its syndrome literally spells the position of a single error.
  • The surface code uses local checks on a 2D grid, tolerates roughly 1% physical error, and gets exponentially better with distance at a cost of about 2d^2 qubits.
  • Overhead is huge today, which is why error mitigation is used on current, noisy machines.

Next: NISQ Devices and Error Mitigation