The surface code and decoders (MWPM, union-find, ML decoders)
For thirty years, every quantum error-correction experiment faced the same embarrassment: adding qubits to a code added more ways to fail than it removed. In 2024 Google’s Willow chip crossed the line. Growing a surface code from distance 3 to 5 to 7 cut the logical error rate by a factor of 2.14 at each step, and the distance-7 logical qubit outlived the best physical qubit on the chip by a factor of 2.4. This chapter explains the code that did it, and lets you run its decoder.
On the plate: a surface code on a torus. Tap edges to put errors on qubits; then decode.
The toric and surface codes
Alexei Kitaev proposed in 1997 to put qubits on the edges of a square lattice wrapped onto a torus. Each vertex check is the product of Z on its four edges, each plaquette check the product of X around its square. All checks are local and involve only four qubits, which suits a flat chip. An X error on one edge flips the two vertex checks at its ends: errors appear as pairs of defects, like particle–antiparticle pairs, and a chain of errors shows only its two endpoints. A logical error is a chain that wraps all the way around the torus, which no local check can see. The surface code, with boundaries instead of a torus, is what chips build: a distance- patch uses data and measure qubits. Established
Decode by matching
On an torus with 5, tap edges to flip qubits, or at rate 0.06. Then or .
The decoder sees only the defects. Minimum-weight perfect matching (MWPM), suggested by Eric Dennis, Kitaev, Andrew Landahl and John Preskill in 2002, pairs them so that the total length of connecting paths is smallest, assuming the likeliest explanation is the fewest errors. The plate solves it exactly for up to 16 defects. Correction plus error then forms closed loops; if a loop wraps around the torus, the decoder has caused a logical error. Try placing three errors in a row across a 5 × 5 torus. Nicolas Delfosse and Naomi Nickerson’s 2021 union-find decoder is nearly as accurate and runs in almost linear time. Speed matters: syndromes arrive every microsecond and must be decoded as fast as they come. Established
Threshold, and Willow
The plate’s Monte Carlo (from this book’s own MWPM decoder) shows logical failure against physical error rate for = 4 to 10. Below about 10% the curves fan downward as grows; above it they rise. That crossing is the threshold, about 10.3% for this idealized noise. With realistic circuit noise, including faulty measurements, the threshold is near 1%. Below threshold, each increase of the distance by 2 divides the logical error by a factor .
Google’s 2025 Nature paper reported and 0.143% error per cycle at distance 7, with a real-time decoder latency of 63 µs. Extrapolate to distance 27. In 2024 Google DeepMind’s AlphaQubit, a transformer network, decoded Google’s data with 6% fewer errors than tensor-network decoding and 30% fewer than correlated matching, but not yet fast enough for real time. Established for the measurements; Speculative for the extrapolation.
What you now have
The toric and surface codes, errors as defect pairs, logical errors as wrapping chains, minimum-weight matching and union-find, the threshold, Λ and the 2024–25 below-threshold experiment, and neural decoders.
· · ·
Three questions to carry with you.
And one to work out. A distance-27 surface code uses physical qubits. How many?
Sources: A. Yu. Kitaev, Ann. Phys. 303, 2 (2003) (arXiv 1997). E. Dennis, A. Kitaev, A. Landahl and J. Preskill, J. Math. Phys. 43, 4452 (2002). A. G. Fowler et al., Phys. Rev. A 86, 032324 (2012). N. Delfosse and N. H. Nickerson, Quantum 5, 595 (2021). O. Higgott, ACM Trans. Quantum Comput. 3, 16 (2022) (PyMatching). Google Quantum AI and collaborators, Nature 638, 920 (2025). J. Bausch et al., Nature 635, 834 (2024). Checked by code: toric-code MWPM Monte Carlo with crossing near 10%; 0.143% / 2.14¹⁰ = 7.1 × 10⁻⁷.