← Back to section · Quantum Computing

The Surface Code in Depth: Lattices, Stabilizers and Lattice Surgery

Why the surface code looks like a chessboard: the layout of data and measure qubits, X- and Z-type stabilizers, the geometric meaning of code distance, and computing between logical qubits with lattice surgery.

Published 22 November 2026 · 5 min read · PQ Frontier

The Surface Code in Depth: Lattices, Stabilizers and Lattice Surgery
AI-generated site artwork
Video explainer · Quantum Error Correction

Our overview article explains why the surface code became the leading approach; this one goes a layer deeper into its construction. All of the surface code’s magic comes from a plain geometric arrangement: qubits laid out on a board, where local interactions around each cell combine to protect one logical qubit through global topology.

Building the board: data qubits and measure qubits

In the widely used rotated surface-code layout, data qubits sit on the vertices (equivalently, the edges) of a square lattice, roughly d2d^2 of them; beside each face and each vertex sits an ancilla qubit that measures a stabilizer. The ancillas come in two kinds: one measures Z-type stabilizers — the product of Z operators on the four data qubits around a face; the other measures X-type stabilizers — the product of X operators around a vertex. Along the boundaries the stabilizers involve only two or three qubits and have lower weight.

In every error-correction round, all ancillas couple to their neighbouring data qubits and are measured at once, producing a string of ±1 outcomes — that round’s syndrome. The crucial point is that these measurements only ask “is the product plus or minus”, never the state of any single qubit, so the encoded logical information is never peeked at. A single round of measurement is itself noisy, so the syndrome is measured for dd consecutive rounds, bringing the time direction into the code as well: errors become clusters of “events” in a three-dimensional spacetime, and the decoder’s job is to pair up and resolve those events correctly.

Distance: the length of a chain

The distance dd is the surface code’s central parameter, and its geometric meaning is very concrete. An undetectable logical error corresponds to a chain of errors running from one boundary of the board to the opposite one (or connecting a specific pair of boundaries); the shortest such chain contains exactly dd errors. A distance-dd code therefore corrects any pattern of (d−1)/2(d-1)/2 errors — as long as fewer than half the links of a spanning chain are in error, the decoder can tell the true chain apart from its complement.

This also explains how the logical error rate scales with distance: below threshold, at physical error rate pp, it falls roughly as (p/pth)(d+1)/2(p/p_{th})^{(d+1)/2}. Every increment of dd by 2 multiplies the logical error rate by a fixed factor below 1 — the geometric origin of the “error rate roughly halves per step of distance” behaviour seen in Google’s 2024 Willow demonstration. The cost is equally concrete: qubit count grows as d2d^2 and the number of rounds as dd. Protection from the surface code is never free; it is simply well accounted.

Boundaries are the logic: X_L and Z_L

Logical operators have explicit shapes in the surface code: logical Z is a chain of Z errors connecting one pair of boundaries, logical X a chain of X errors connecting the other pair. The two chains cross at a single data qubit, so they anticommute — exactly the Pauli algebra of one qubit. Preparing and measuring logical states also happens along the boundaries: initializing every data qubit of a patch to ∣0⟩|0\rangle yields logical ∣0⟩|0\rangle, and measuring the data qubits one by one with classical post-processing performs a logical Z measurement.

This “the information lives in relations between boundaries, and no local disturbance can reach it” structure is what topological protection means: no pattern of fewer than dd local errors can change the logical state. An error has to span the entire board to do damage.

Lattice surgery: computing between logical qubits

The surface code’s weak spot is that transversal gates are unnatural: there is no simple logical CNOT inside a single patch. The mainstream solution is lattice surgery. Two adjacent patches are merged along a shared boundary: measuring a row of joint stabilizers along that boundary amounts to a joint Pauli measurement on the two logical qubits; the patches are then split again, and the boundary data gathered during the merge determines a measurement-dependent correction. Combined with single-qubit logical preparation and measurement, one joint measurement plus one single-qubit measurement implements a logical CNOT.

Lattice surgery is priced in rounds of the code distance: one logical operation takes about dd rounds of syndrome measurement to protect. This sets the clock speed of a surface-code machine — the logical gate rate depends not on how fast the physical gates are, but on the syndrome cycle time multiplied by dd. It is also why decoding must keep up with a syndrome stream arriving roughly every microsecond: every step of a lattice-surgery operation waits for the decoder to confirm that the previous slab of spacetime holds no unresolved errors.

Variants and floor plans: how many logical qubits per board?

The description above is the most regular form: an unrotated planar code with one logical qubit per patch. Engineering practice uses several important variants. The rotated surface code turns the lattice by 45 degrees and reaches the same distance with roughly half the physical qubits; it is the mainstream form in current experiments — the distance-3/5/7 codes on Willow are all rotated versions. The older defect-based route instead “punches holes” in a full board: disabling stabilizer measurements in a small region makes the hole’s boundary define a logical qubit, so one large board can hold many logical qubits. As lattice surgery matured, the defect route gave way to the “one patch per logical qubit, surgery for connections” floor plan, whose boundary behaviour is cleaner and whose decoding graphs are more regular.

The layout choice propagates into every detail of decoding and wiring: the rotated code’s stabilizer weight distribution and boundary shapes set the directions of hook errors and the edge weights of the decoding graph, while the space between patches must be reserved for surgery merge regions and magic-state factories. The floor plan of a real machine therefore looks like a city: data regions are the boards, surgery channels are the streets, and factories occupy whole districts — the surface code’s geometry extends from the construction of a single code all the way to the layout of the whole machine.

Summary

The surface code divides the problem into four jobs: geometry protects (distance and topology), local measurements gather evidence (stabilizers), classical decoding reaches the verdict (chain matching), and lattice surgery computes. None of the pieces is mysterious on its own; together they form the only complete scheme so far verified on real hardware to get more accurate as it grows. Understanding this construction is the prerequisite for everything that follows about decoders, logical gates and resource overheads.

Tags: surface codestabilizerslattice surgery