6  Chapter 4: Surface Code

7 Surface Code

TipLearning Objectives

After completing this chapter, you will be able to: - Describe the surface code lattice structure and stabilizer generators - Identify error chains and their corresponding syndromes - Explain how boundary conditions determine logical operators - Define the threshold theorem and its significance for fault tolerance - Compare code capacity, phenomenological, and circuit-level noise models

NotePrerequisites

This chapter assumes familiarity with: - Stabilizer formalism and CSS codes (Chapter 3) - Pauli operators and syndrome measurement - Basic graph theory (vertices, edges, paths)

The surface code is the most practically important topological quantum error-correcting code. First proposed by Kitaev [@kitaev2003] and developed extensively by Fowler et al. [@fowler2012], it has become the leading candidate for large-scale quantum computation due to its high threshold and 2D nearest-neighbor connectivity requirements. This chapter develops the surface code from first principles.

7.1 Topological Structure and Stabilizers

The surface code is defined on a 2D square lattice of physical qubits. The key insight is that topological properties of the lattice protect quantum information from local errors.

7.1.1 Lattice Layout

The surface code places qubits on the edges of a square lattice.

NoteDefinition: Surface Code Lattice

Consider a square lattice with: - Data qubits on each edge of the lattice - Ancilla qubits at each vertex (for Z-type measurements) and at each face center (for X-type measurements)

For an \(L \times L\) lattice with open boundaries, there are \(N = L^2\) data qubits encoding \(k = 2\) logical qubits.

The lattice structure naturally separates X-type and Z-type errors:

  • X errors are detected by measuring vertex stabilizers (product of Z on surrounding edges)
  • Z errors are detected by measuring face stabilizers (product of X on surrounding edges)

7.2 Example: Small Lattice Example

For a \(3 \times 3\) lattice with open boundaries: - 9 data qubits on edges - 4 vertex ancillas measuring \(Z_1 Z_2 Z_4 Z_5\) type operators - 4 face ancillas measuring \(X_1 X_2 X_4 X_5\) type operators

Total stabilizers: \(r = n - k = 9 - 2 = 7\) independent generators

7.2.1 Vertex and Face Stabilizers

The stabilizer generators come in two flavors, one for each Pauli basis.

NoteDefinition: Surface Code Stabilizers

For each vertex \(v\) of the lattice, define the Z-type stabilizer: \(A_v = \prod_{e \ni v} Z_e\)

For each face \(f\) of the lattice, define the X-type stabilizer: \(B_f = \prod_{e \in \partial f} X_e\)

The surface code stabilizer group is \(S = \langle \{A_v\}, \{B_f\} \rangle\).

All vertex stabilizers commute with all face stabilizers because each pair shares either 0 or 2 qubits (even overlap), ensuring \(\{A_v, B_f\} = 0\) never occurs.

TipIntuition

Think of the surface code like a tiled bathroom floor. Each tile (face) and each corner where tiles meet (vertex) acts as a local “error detector.” If someone cracks a tile edge (a qubit error), the two tiles sharing that edge both notice something is wrong — they report a defect. But tiles far away from the crack see nothing. This locality is what makes the surface code so practical: you only need to talk to your nearest neighbors to detect errors.

TipIntuition

Think of syndrome defects like puddles of water that form when it rains. A single error creates two small puddles (defects) — they’re always found in pairs, like footprints left by someone walking across a wet floor. When you see two puddles, you know something walked between them, but you don’t know exactly what — it could have been a direct path or a wandering route. The decoder’s job is like figuring out the most likely path someone took, given only where the puddles appeared.

ImportantProposition: Stabilizer Commutation

For any vertex \(v\) and face \(f\), the operators \(A_v\) and \(B_f\) commute: \([A_v, B_f] = 0\)

The overlap \(|\partial f \cap \partial v|\) is either 0 or 2, so \(A_v B_f = B_f A_v\).

Surface code lattice structure. Data qubits (circles) sit on edges. Vertex ancillas (squares) measure Z-type stabilizers. Face ancillas measure X-type stabilizers.

7.2.2 The Toric Code: Periodic Boundaries

The toric code is the surface code with periodic boundary conditions (torus topology).

NoteDefinition: Toric Code

The toric code on an \(L \times L\) lattice with periodic boundaries: - \(n = 2L^2\) data qubits (edges of wrapped lattice) - \(r = 2L^2\) stabilizer generators (\(L^2\) vertex + \(L^2\) face) - \(k = 2\) logical qubits (homotopy classes on torus)

Parameters: \([[2L^2, 2, L]]\)

The toric code distance \(d = L\) reflects the minimum length of a non-contractible loop—an error chain must stretch across the torus to become a logical operator.

7.3 Example: Toric Code [[4,2,2]]

For \(L = 2\): - \(n = 8\) qubits, \(k = 2\) logical qubits - Distance \(d = 2\) (shortest non-trivial loop)

For \(L = 4\): - \(n = 32\) qubits, \(k = 2\) logical qubits - Distance \(d = 4\)

NoteRemark

The toric code is a CSS code with structure: - X-type stabilizers from classical repetition codes on rows/columns - Z-type stabilizers from classical repetition codes on columns/rows

This connects to the CSS construction from Chapter 3.

7.4 Error Syndromes and Matching Problem

When errors occur, they create distinctive patterns in the stabilizer measurements. Understanding these patterns is key to decoding.

7.4.1 Error Chains and Syndrome Formation

Single-qubit errors create pairs of syndrome defects. Error chains create multiple defects.

ImportantProposition: Syndrome from Errors

For a Pauli error \(E\) on edges of the lattice: - Each \(Z\) error anticommutes with face stabilizers, creating defect endpoints - Each \(X\) error anticommutes with vertex stabilizers, creating defect endpoints

The syndrome is the set of stabilizers that anticommute with \(E\).

7.5 Example: Single Qubit Error

A Z error on edge \(e\) between vertices \(v_1\) and \(v_2\): - Commutes with all vertex stabilizers (even overlap at each vertex) - Anticommutes with the two faces sharing \(e\)

Syndrome: 2 face defects at the faces adjacent to \(e\)

7.6 Example: Error Chain

A chain of errors \(E = Z_1 Z_2 ... Z_m\): - Creates defects only at the endpoints of the chain - Internal edges share defects pairwise (canceling)

Syndrome: 2 defects for a chain, regardless of length

Error chain creates syndrome defects only at endpoints. The decoder must connect defects to identify the error.
WarningMisconception

“A longer error chain is harder to detect.” In fact, the syndrome only depends on the endpoints of the chain, not its length. A chain of 10 errors produces the same 2-defect syndrome as a single error between the same endpoints. What matters for correction is whether the decoder can identify the correct equivalence class of the error — two chains with the same endpoints are equivalent up to stabilizers and produce the same logical effect.

7.6.1 Worked Example: Syndrome Formation on a Distance-5 Code

Let us trace through syndrome formation on a distance-5 surface code step by step, showing exactly which stabilizers are violated by a specific error pattern and how defects appear only at chain endpoints.

Step 1: Set up the lattice. Consider a distance-5 planar code with \(n = 25\) data qubits arranged on a \(5 \times 5\) lattice of vertices. Each data qubit sits on an edge connecting two adjacent vertices. The stabilizers are: - Z-type (vertex): product of Z on all edges incident to that vertex - X-type (face): product of X on all edges surrounding that face

For this distance-5 code, there are 16 face stabilizers and 16 vertex stabilizers, giving \(r = 32\) generators protecting \(k = 1\) logical qubit. The code distance \(d = 5\) means any error chain shorter than 5 cannot be a logical operator.

Step 2: Apply an error chain. Suppose three \(Z\) errors occur on consecutive horizontal edges in the middle row: \(E = Z_1 Z_2 Z_3\)

These errors represent a chain connecting the left side of the lattice to the right side. This chain has weight 3, which is less than the distance 5, so it is detectable but does not yet cause a logical error.

Step 3: Identify which stabilizers anticommute. Each \(Z\) error anticommutes with the two face (X-type) stabilizers that share that edge: - \(Z_1\): anticommutes with faces \(f_\text{left}\) and \(f_2\) (the faces above and below edge 1) - \(Z_2\): anticommutes with faces \(f_2\) and \(f_3\) - \(Z_3\): anticommutes with faces \(f_3\) and \(f_\text{right}\)

The key insight is that each face stabilizer either anticommutes with 0, 1, or 2 of the errors in the chain.

Step 4: Cancel internal defects. Adjacent errors share faces, so internal defects cancel in pairs: - Face \(f_2\): anticommutes with both \(Z_1\) and \(Z_2\) \(\rightarrow\) overall commutes (even count = 0) - Face \(f_3\): anticommutes with both \(Z_2\) and \(Z_3\) \(\rightarrow\) overall commutes (even count = 0)

Only the faces at the endpoints retain odd parity: - \(f_\text{left}\): anticommutes with \(Z_1\) only \(\rightarrow\) defect - \(f_\text{right}\): anticommutes with \(Z_3\) only \(\rightarrow\) defect

This cancellation is why we only see defects at the chain endpoints — internal errors “pair up” their anticommutation effects.

Step 5: Read the syndrome. The syndrome contains exactly 2 defects, located at the two endpoints of the error chain: \(s = \{f_\text{left}, f_\text{right}\}\)

This is a key principle: any error chain produces defects only at its endpoints, regardless of chain length. A chain of 10 errors creates the same 2-defect syndrome as a chain of 2 errors, as long as they share the same endpoints.

Distance-5 surface code with error chain \(Z_1 Z_2 Z_3\) highlighted in red. The syndrome defects (red dots) appear only at the chain endpoints \(f_\text{left}\) and \(f_\text{right}\). Internal faces receive even parity (0) and report no defect.
NoteRemark

This example illustrates why the surface code is tolerant to long error chains: the syndrome only tells us about the endpoints, not the details of the path between them. The decoder must infer the most likely path connecting the defects. Two chains with the same endpoints are in the same homology class and have the same effect on the logical state — this is degeneracy, a key advantage of quantum codes.

7.6.2 Minimum Weight Perfect Matching

The standard surface code decoder uses minimum weight perfect matching (MWPM).

NoteDefinition: Matching Decoder

Given a set of syndrome defects, find a set of error chains connecting pairs such that: 1. Every defect is an endpoint of exactly one chain 2. The total weight (length) of all chains is minimized

The error recovery is then the product of all Pauli operators along these chains.

The MWPM algorithm runs in polynomial time using Blossom algorithm variants.

TipIntuition

Think of MWPM like a city road repair crew receiving reports of potholes (syndrome defects). They must pair up the reports and fix the road segments between each pair. The crew prefers to fix shorter segments because they’re cheaper — so they match nearby potholes first. If there are many potholes, they consider all possible pairings and choose the set of repairs that minimizes total road work. This is exactly what MWPM does: find the shortest total path connecting all defect pairs.

TipIntuition

Think of MWPM like a doctor trying to pair up symptoms to diagnose a disease. Each symptom (defect) must be “explained” by exactly one diagnosis (error chain). The doctor prefers explanations requiring fewer complications (shorter chains). By always choosing the simplest explanation that accounts for all symptoms, MWPM achieves optimal decoding for independent errors.

ImportantProposition: MWPM Optimality

For the surface code with independent errors: - MWPM is optimal for correcting errors up to distance \(d\) - The threshold occurs when error rate exceeds the percolation threshold - For i.i.d. errors, threshold is approximately 10-11%

7.7 Example: Matching Example

For 4 defects at positions \((1,2)\), \((1,5)\), \((3,2)\), \((3,5)\): - Option 1: Connect (1,2)-(1,5) and (3,2)-(3,5), total weight = 6 - Option 2: Connect (1,2)-(3,2) and (1,5)-(3,5), total weight = 4

MWPM chooses Option 2, correcting with 2 short chains

7.7.1 Worked Example: MWPM Decoding Step-by-Step

Let us walk through a complete MWPM decoding cycle on a distance-5 surface code, showing all possible matchings, explaining the geometric interpretation, and demonstrating why the minimum weight choice succeeds.

Step 1: Observe the syndrome. Four defects appear at lattice coordinates: \(D = \{d_1: (2,1), d_2: (2,4), d_3: (4,2), d_4: (4,3)\}\)

These are Z-type defects from face stabilizers, indicating X errors on the lattice edges between these faces. The decoder sees these four “charge” locations and must pair them up.

Step 2: Build the matching graph. For 4 defects, there are \((4-1)!! = 3\) ways to pair them perfectly. We compute all pairwise Manhattan distances (shortest path on the lattice):

\[ \begin{matrix} & d_1 & d_2 & d_3 & d_4 \\ d_1 & 0 & 3 & 3 & 4 \\ d_2 & 3 & 0 & 4 & 3 \\ d_3 & 3 & 4 & 0 & 1 \\ d_4 & 4 & 3 & 1 & 0 \end{matrix} \]

Each entry \(d(i,j)\) represents the minimum number of edges needed to connect defect \(i\) to defect \(j\).

Step 3: Enumerate all perfect matchings.

Matching A: Pair \((d_1, d_2)\) and \((d_3, d_4)\) - Distance \(d(d_1, d_2)\): \(|2-2| + |1-4| = 3\) (horizontal separation) - Distance \(d(d_3, d_4)\): \(|4-4| + |2-3| = 1\) (adjacent in same row) - Total weight: \(3 + 1 = 4\)

Matching B: Pair \((d_1, d_3)\) and \((d_2, d_4)\) - Distance \(d(d_1, d_3)\): \(|2-4| + |1-2| = 3\) (diagonal pairing) - Distance \(d(d_2, d_4)\): \(|2-4| + |4-3| = 3\) (diagonal pairing) - Total weight: \(3 + 3 = 6\)

Matching C: Pair \((d_1, d_4)\) and \((d_2, d_3)\) - Distance \(d(d_1, d_4)\): \(|2-4| + |1-3| = 4\) (long diagonal) - Distance \(d(d_2, d_3)\): \(|2-4| + |4-2| = 4\) (long diagonal) - Total weight: \(4 + 4 = 8\)

Step 4: Select minimum weight matching. MWPM chooses Matching A with total weight 4, as it minimizes the sum of path lengths.

Step 5: Construct correction chains. The decoder proposes X-type error chains connecting each matched pair: - Chain 1: Horizontal path from \((2,1)\) to \((2,4)\) — 3 edges - Chain 2: Short path from \((4,2)\) to \((4,3)\) — 1 edge

These chains, when applied as X operators, will anticommute with exactly those face stabilizers at the defect locations, clearing the syndrome.

Step 6: Verify correction success. The product of correction operators \(C = X_{(2,1)\rightarrow(2,4)} X_{(4,2)\rightarrow(4,3)}\) creates defects at \(\{d_1, d_2, d_3, d_4\}\) that exactly cancel the original syndrome defects. After correction, all stabilizers return to +1 eigenvalue. If the actual error was any chain homologous to the MWPM proposal, the logical state is preserved.

Four-panel illustration of MWPM decoding: (a) Syndrome with 4 defects at positions shown as red dots. (b) Complete matching graph with edge weights = Manhattan distances. (c) All 3 possible perfect matchings with total weights 4, 6, and 8. (d) MWPM selects minimum weight matching (weight 4) shown in bold lines.
NoteRemark

MWPM does not need to identify the exact error — only an error in the same equivalence class. If the actual error was a chain from \((2,1)\) to \((2,4)\) plus any number of stabilizer loops, MWPM’s correction still succeeds. This degeneracy is a key advantage of quantum codes over classical codes. Furthermore, the geometric structure of the lattice enables efficient computation: all pairwise distances can be precomputed in \(O(n^2)\) time, and the Blossom algorithm finds the minimum weight matching in polynomial time.

7.7.2 Geometric Matching and Lattice Distance

The matching problem has natural geometric structure.

NoteDefinition: Lattice Distance

The distance between two defects on the lattice is the length of the shortest path connecting them: \(d((x_1, y_1), (x_2, y_2)) = |x_1 - x_2| + |y_1 - y_2|\)

This Manhattan (L1) distance reflects the minimum number of errors needed to connect the defects.

ImportantProposition: Geometric Interpretation of Matching

Each defect pair in the matching corresponds to a proposed error chain connecting those two locations. The weight of the matching equals the total length of all proposed error chains. Minimizing this weight is equivalent to finding the most likely error configuration given the syndrome.

The geometric structure of the lattice enables efficient decoding:

  1. Precomputation: All pairwise distances can be computed in \(O(r^2)\) time where \(r\) is the number of syndrome defects.

  2. Graph construction: Build a complete graph with vertices = defects and edge weights = lattice distances.

  3. Matching: Apply the Blossom algorithm to find the minimum weight perfect matching in polynomial time \(O(r^3)\).

  4. Correction: Apply error chains along the matched paths.

7.8 Example: Geometric Weight Calculation

For a defect at position \((2,1)\) and another at \((5,4)\): \(d = |2-5| + |1-4| = 3 + 3 = 6\)

This means the minimum error chain connecting these defects has weight 6, requiring 6 physical qubit errors.

TipIntuition

The Manhattan distance arises because errors can only propagate along lattice edges - horizontally or vertically, not diagonally. A diagonal connection from \((0,0)\) to \((3,3)\) requires at least \(3+3=6\) horizontal and vertical moves, even though the Euclidean distance is \(\sqrt{18} \approx 4.2\). This reflects the underlying physics: errors occur on individual qubits, not in continuous space.

NoteRemark

The geometric structure enables efficient matching: - Precompute distances between all defect pairs - Build a complete graph with edge weights = distances - Find minimum weight perfect matching on this graph

This approach works because the surface code error model is local: each error creates defects at adjacent locations, so the most likely error chains are short. MWPM naturally favors these short chains.

7.8.1 Advanced Decoding: Weighted Matching and Soft Information

The basic MWPM assumes perfect syndrome measurement. In practice, syndrome extraction can include confidence weights.

NoteDefinition: Weighted MWPM

Assign each syndrome measurement a weight \(w_i\) representing measurement fidelity. Higher weight = more reliable measurement. The matching objective becomes:

\(\text{minimize} \sum_{(i,j) \text{ in matching}} (d(i,j) + w_i + w_j)\)

This favors matching defects from more reliable measurements.

NoteRemark

In circuit-level noise, measurement errors cause some syndrome bits to be unreliable. Weighted MWPM assigns lower confidence to measurements that differ from previous rounds (oscillating syndromes), improving logical error suppression.

7.8.2 Degeneracy and Logical Equivalence

A crucial feature of quantum decoding is degeneracy: multiple error chains can produce identical syndromes.

ImportantProposition: Degenerate Errors

Two errors \(E_1\) and \(E_2\) are degenerate if they differ by a stabilizer: \(E_1 = E_2 S\) for some \(S \in S\)

Degenerate errors: - Produce identical syndromes - Have identical effects on logical operators - Are indistinguishable by any measurement

MWPM implicitly handles degeneracy by finding any chain in the correct homology class.

7.9 Example: Degenerate Error Chain

Consider two error chains from boundary to boundary: - \(E_1\): takes the upper path through the lattice - \(E_2\): takes the lower path through the lattice

Both create the same 2-defect syndrome (at each boundary) and both implement the same logical operation. They are degenerate. MWPM may correct either, and both corrections succeed.

WarningMisconception

“More defects mean more errors.” In fact, the number of defects depends on the topology of errors, not just their weight. A single long error chain creates only 2 defects, while many small independent errors create many defects. The decoder must infer the actual error distribution from the syndrome pattern.

7.10 Boundary Conditions and Logical Qubits

Open boundary conditions reduce the number of logical qubits and enable practical devices.

7.10.1 Planar Code: Open Boundaries

The planar code uses open boundaries to encode just 1 logical qubit in a rectangular patch.

NoteDefinition: Planar Code

The planar code on an \(L \times L\) patch: - \(n = L^2 + (L-1)^2 = 2L^2 - 2L + 1\) data qubits - \(k = 1\) logical qubit - Distance \(d = L\) (minimum of width and height)

Boundary types: - Rough boundaries: Z-type stabilizers truncated - Smooth boundaries: X-type stabilizers truncated

The two boundary types determine which logical operators are allowed.

7.11 Example: Logical Operators

For a rectangular patch: - Logical \(Z_L\): chain of Z operators connecting top to bottom (rough boundaries) - Logical \(X_L\): chain of X operators connecting left to right (smooth boundaries)

The minimum weight of these chains gives the code distance.

Planar code with rough (red) and smooth (blue) boundaries. Logical Z connects top-to-bottom through rough boundaries. Logical X connects left-to-right through smooth boundaries.

7.11.1 Worked Example: Logical Operators and Boundary Conditions

Let us explicitly construct the logical operators on a distance-3 planar code and verify their properties, demonstrating how boundary types determine the logical operators and why minimum weight equals the distance.

Step 1: Define the lattice geometry. Consider a distance-3 planar code (a \(3 \times 3\) patch with open boundaries): - Top and bottom boundaries: rough (no Z stabilizers at boundary vertices) - Left and right boundaries: smooth (no X stabilizers at boundary faces)

The rough boundaries allow Z-type operators to terminate without detection, while smooth boundaries allow X-type operators to terminate. This perpendicular arrangement is essential.

Step 2: Construct logical \(\bar{Z}_L\). The logical Z operator is a chain of Z operators running from the top rough boundary to the bottom rough boundary. On our \(3 \times 3\) lattice: \(\bar{Z}_L = Z_1 Z_2 Z_3\)

where each \(Z_i\) is a Z operator on a vertical edge connecting adjacent rows. This chain has weight 3 — it uses 3 physical qubits.

Step 3: Verify \(\bar{Z}_L\) is a logical operator. A logical operator must: - Commute with all stabilizers - Be non-trivially implementable (not equal to a product of stabilizers)

For the vertical chain: - Commutes with all Z-type (vertex) stabilizers: same Pauli type, always commutes - Commutes with X-type (face) stabilizers: each internal face shares exactly 2 edges with the chain, so \(X \cdot Z \cdot Z = +1\) - At boundary faces: shares 1 edge, giving possibility of anticommutation — but this is where the chain terminates, so no stabilizer detects it

The chain cannot be written as a product of stabilizers (which would be a trivial operator), making it a valid logical operator.

Step 4: Construct logical \(\bar{X}_L\). The logical X operator is a horizontal chain from left smooth boundary to right smooth boundary: \(\bar{X}_L = X_1 X_2 X_3\)

This chain runs perpendicular to \(\bar{Z}_L\), using 3 physical X operators.

Step 5: Verify anticommutation. \(\bar{Z}_L \bar{X}_L = -\bar{X}_L \bar{Z}_L\)

Each vertical Z edge crosses exactly one horizontal X edge at lattice vertices. At each crossing, Z and X anticommute (\(Z X = - X Z\)). With 3 crossings in this \(3 \times 3\) code, the total phase is \((-1)^3 = -1\), confirming anticommutation.

Step 6: Minimum weight equals distance. - Weight of \(\bar{Z}_L\): 3 Z operators - Weight of \(\bar{X}_L\): 3 X operators - Any equivalent logical operator (same effect up to stabilizers) has weight at least 3

This confirms the code parameters: \([[9,1,3]]\) — 9 data qubits, 1 logical qubit, distance 3. The distance equals the minimum weight of any logical operator.

Planar code with rough (red) and smooth (green) boundaries. Logical \(Z_L\) (red dashed) runs vertically from top to bottom rough boundaries. Logical \(X_L\) (green dashed) runs horizontally from left to right smooth boundaries. These operators cross at right angles, anticommute, and have minimum weight equal to the code distance.
TipIntuition

Boundaries act like “half-stabilizers.” At a rough boundary, the Z stabilizers are missing, so a chain of Z operators can terminate there without being detected. This termination point is where logical operators begin or end. Smooth boundaries do the same for X operators. The two boundary types are perpendicular, preventing logical Z and X from both being trivial loops. This geometry is why the code distance equals the shortest path between boundaries of the same type.

7.11.2 Rough vs Smooth Boundaries in Detail

The distinction between rough and smooth boundaries is fundamental to understanding how the surface code encodes logical qubits.

NoteDefinition: Boundary Types

Rough boundaries (also called electric boundaries): - Truncate Z-type (vertex) stabilizers at the boundary - Allow Z operators to terminate without detection - Correspond to “dual” rough edges in the toric code language - Logical Z operators run between pairs of rough boundaries

Smooth boundaries (also called magnetic boundaries): - Truncate X-type (face) stabilizers at the boundary - Allow X operators to terminate without detection - Correspond to “primal” smooth edges in the toric code language - Logical X operators run between pairs of smooth boundaries

ImportantProposition: Boundary-Logical Correspondence

For a planar code patch: - There are exactly 2 rough boundaries (top and bottom) for Z logical operators - There are exactly 2 smooth boundaries (left and right) for X logical operators - The number of logical qubits equals \(k = 2 - b\), where \(b\) is the number of boundary pairs that are identified

More generally: each pair of rough boundaries supports one logical Z operator; each pair of smooth boundaries supports one logical X operator.

7.12 Example: Boundary Geometry

Consider a rectangular patch: - Top boundary: rough (no Z stabilizers at top vertices) - Bottom boundary: rough - Left boundary: smooth (no X stabilizers at left faces) - Right boundary: smooth

Then: - \(Z_L\) connects top-to-bottom (through rough boundaries) - \(X_L\) connects left-to-right (through smooth boundaries)

These operators cross at right angles and anticommute, giving \(k = 1\).

7.12.1 Physical Interpretation of Boundaries

Boundaries have direct physical meaning in implementations.

TipIntuition

Think of rough and smooth boundaries as different “wall types” for the anyon excitations of the code: - Rough boundaries condense (absorb) electric anyons (\(e\) \(Z\) violations) - Smooth boundaries condense magnetic anyons (\(e\) \(X\) violations)

When an error chain terminates at a rough boundary, it creates an electric anyon that can be absorbed by the boundary - this is why the error is not detected. Smooth boundaries do the same for magnetic anyons.

This boundary condition engineering is crucial for device design:

  1. Chip layout: Superconducting qubit have rough and arrays naturally smooth boundaries determined by the qubit connectivity.

  2. Selective encoding: Holes in the code create internal boundaries, enabling multiple logical qubits in a single code patch.

  3. Gate implementation: Moving logical qubits (braiding holes) requires careful boundary engineering.

NoteRemark

Different boundary types can be combined in a single device. For example, a “distance-5” patch with rough-top, rough-bottom, smooth-left, smooth-right encodes exactly one logical qubit. But adding a hole in the interior creates additional logical qubits through the hole encoding mechanism.

7.12.2 Hole Encoding and Flexible Qubits

Holes in the surface code lattice can encode additional logical qubits.

NoteDefinition: Hole Encoding

Create a hole by removing qubits from a region of the lattice. Each hole: - Provides a pair of logical operators encircling the hole - Encodes 1 additional logical qubit

The logical operators are: - \(Z_L\): operator chain around the hole - \(X_L\): operator chain connecting the hole to the boundary

This enables braiding operations: moving holes around each other performs logical gates via topological properties.

7.13 Example: Braiding Operations

Moving hole A around hole B: - Performs logical SWAP on encoded qubits - Depends only on path topology, not details - Fault-tolerant to local perturbations

7.13.1 Logical Qubit Initialization and Measurement

Logical states can be initialized and measured via boundary effects.

ImportantProposition: Logical Initialization
  • Logical \(|0\rangle_L\): Prepare all data qubits in \(|0\rangle\), measure all Z-type stabilizers to +1
  • Logical \(|+\rangle_L\): Prepare all data qubits in \(|+\rangle\), measure all X-type stabilizers to +1

The lattice boundaries enforce the logical state.

NoteRemark

The ability to initialize and measure logical states using only local operations is crucial for fault-tolerant computation. This is not always possible with other topological codes.

7.14 Threshold and Fault Tolerance

The surface code’s high threshold is its most important practical advantage.

7.14.1 The Threshold Theorem

The threshold theorem guarantees that below a critical error rate, arbitrarily accurate quantum computation is possible.

ImportantTheorem: Threshold Theorem for Surface Code

For a surface code with physical error rate \(p < p_c\): - Logical error rate scales as \(p_L \approx A p^{(d+1)/2}\) for distance \(d\) - As \(d \to \infty\), \(p_L \to 0\) for any \(p < p_c\)

The threshold \(p_c \approx 1\%\) for the surface code with realistic noise.

The threshold is determined by the competition between: 1. Error accumulation from imperfect syndrome extraction 2. Error correction capability increasing with code distance

ImportantProposition: Threshold Scaling

For error rate \(p\) below threshold: \(p_L \sim p^{(d+1)/2}\)

This exponential suppression enables practical error rates with moderate \(d\).

7.15 Example: Error Suppression

For \(p = 10^{-3}\) and distance \(d = 25\): - Approximate logical error rate: \(p_L \approx 10^{-13}\)

With \(d = 17\): \(p_L \approx 10^{-9}\)

Trade-off: each distance increase reduces \(p_L\) by factor \(\sim 10^4\)

7.15.1 Fault-Tolerant Syndrome Extraction

In practice, syndrome extraction uses additional gates and can introduce errors.

NoteDefinition: Fault-Tolerant Measurement

A circuit is fault-tolerant if a single-qubit error cannot propagate to create multiple uncorrectable errors.

Surface code syndrome extraction achieves this by: - Repetition of each stabilizer measurement - Verification of ancilla qubit states - Use of cat states or GHZ states for verification

7.16 Example: Ancilla Circuit

To measure a face stabilizer \(X_1 X_2 X_3 X_4\): 1. Prepare ancilla in \(|+\rangle\) 2. Apply CNOTs to all 4 data qubits 3. Measure ancilla in X basis 4. Repeat for verification

Single error affects at most 1 data qubit per round

7.16.1 Circuit-Level Noise Model

The circuit-level noise model is the most realistic, capturing errors that occur during syndrome extraction.

NoteDefinition: Circuit-Level Noise

Each elementary operation (gate, measurement, preparation) is followed by a random error with probability \(p\). The model typically includes: - Idle errors: Depolarizing noise on qubits during waiting periods - Gate errors: Imperfect single-qubit and two-qubit gates - Measurement errors: Classical bit-flip after measurement - Initialization errors: Incorrect state preparation

Each error is typically modeled as depolarizing or Pauli noise.

ImportantProposition: Error Propagation in Syndrome Extraction

Errors during syndrome extraction can propagate through the circuit:

  1. CNOT propagation: A single-qubit error before CNOT can become a two-qubit error after CNOT

  2. Measurement feedback: Errors in measuring ancilla qubits can cause incorrect classical processing

  3. Temporal corruption: Errors accumulate over multiple rounds of syndrome extraction

Fault-tolerant circuits limit this propagation to ensure single errors cannot create multi-qubit errors.

7.17 Example: Error Propagation Through CNOT

Consider measuring \(X_1 X_2 X_3 X_4\): 1. Prepare ancilla in \(|+\rangle\) 2. Apply CNOTs from ancilla to data qubits (and vice versa) 3. A Z error on data qubit 1 after its CNOT propagates back to ancilla

If the CNOT ordering is not carefully designed, one physical error could cause multiple stabilizer violations, confusing the decoder.

TipIntuition

Think of circuit-level noise like building a house in an earthquake zone. The code capacity model assumes the foundation is shaky but measurements are perfect. The circuit-level model acknowledges that even our measuring instruments (the syndrome extraction circuits) shake a bit. The threshold is lower because we must protect against errors in the measuring tools, not just errors in the data qubits themselves.

The key challenge is that each syndrome extraction round involves:

  1. State preparation: Errors in preparing ancilla qubits
  2. Gate operations: Errors in CNOT gates between ancilla and data
  3. Measurement: Errors in reading out the ancilla state
  4. Repetition: Multiple rounds needed to distinguish correlated errors
NoteRemark

Advanced techniques like lattice surgery and flag qubits reduce the overhead of fault-tolerant syndrome extraction. These methods use clever circuit designs to detect errors early, before they spread.

7.17.1 Practical Thresholds and Overheads

Realistic surface code thresholds depend on noise models.

Noise Model Threshold Logical Qubits at \(p = 10^{-3}\)
Independent depolarizing 1.1% ~10,000 for \(p_L = 10^{-12}\)
Circuit noise with 1% gate error 0.1-0.5% ~100,000
Phenomenological noise 10-11% ~10 for \(p_L = 10^{-6}\)

The practical threshold of ~1% is achievable with current superconducting qubit technology, which has gate fidelities of 99.5-99.9%. This makes the surface code the leading candidate for near-term quantum error correction.

ImportantProposition: Overhead Scaling

To achieve target logical error rate \(p_L\) at physical error rate \(p\):

\(d \approx 2 \lceil (\log(p_L/p) / \log(1/p)) - 1 \rceil\)

The physical qubit overhead scales as \(O(d^2)\), so: - \(d = 17\): ~300 physical qubits for \(p_L = 10^{-10}\) at \(p = 10^{-3}\) - \(d = 25\): ~600 physical qubits for \(p_L = 10^{-15}\) at \(p = 10^{-3}\)

Each order of magnitude improvement in logical error rate requires roughly doubling the code distance.

NoteRemark

The gap between phenomenological and circuit noise thresholds highlights the importance of efficient, low-overhead syndrome extraction circuits. Research continues on improving these circuits to raise practical thresholds.

7.17.2 Recent Experimental Results

The surface code has moved from theory to experiment, with major demonstrations by leading quantum computing groups. This subsection summarizes the key experimental milestones that validate the surface code as a practical approach to quantum error correction.

7.17.2.1 Google Quantum AI (2023): Break-Even Achievement

In a landmark paper published in Nature, Google Quantum AI demonstrated the first experimental verification of the threshold theorem [@google2023]. Using their Sycamore processor with 49 physical qubits arranged in a surface code layout, they implemented distance-3 through distance-11 codes and measured logical error rates.

ImportantProposition: Break-Even Result

The key achievement was demonstrating \(p_L < p\), where \(p\) is the physical qubit error rate and \(p_L\) is the logical qubit error rate. This “break-even” point means the error-corrected logical qubit actually outperforms the underlying physical qubits.

Key findings from the Google experiment:

  1. Exponential suppression: Logical error rate decreased exponentially with increasing code distance, following \(p_L \sim p^{(d+1)/2}\)

  2. Threshold validation: The measured threshold of approximately 0.24% for circuit-level noise matched theoretical predictions

  3. Scalability: The error suppression continued consistently from distance-3 through distance-11, showing no unexpected scaling barriers

7.18 Example: Google Results

At distance-7 on the Google Sycamore: - Physical error rate: ~0.1% - Logical error rate: ~0.02% - Suppression factor: 5x improvement over physical qubits

7.18.0.1 IBM Quantum: Large-Scale Implementation

IBM’s approach to surface codes focuses on scalability and real-time decoding. Their 127-qubit Eagle processor demonstrates surface code error correction at unprecedented scale [@ibm2023].

Key contributions from IBM:

  1. Real-time decoding: Implemented decoding algorithms that can keep up with the physical qubit gate times, crucial for continuous operation

  2. High-fidelity syndrome extraction: Achieved measurement fidelities above 99% for stabilizer syndromes, reducing measurement errors

  3. State preparation: Demonstrated high-fidelity initialization of logical states including \(|0\rangle_L\) and \(|+\rangle_L\)

Group Year Qubits Key Achievement
Google 2023 49 Break-even demonstration
IBM 2023 127 Large-scale syndrome extraction
Quantinuum 2024 32 Extended logical qubit lifetime
AWS 2024 64 Surface code on custom hardware

7.18.0.2 Comparison of Experimental Results

Different experimental groups have achieved surface code error correction with varying approaches:

NoteDefinition: Experimental Metrics

Key metrics for comparing experimental results:

  • Logical error rate: How often the logical qubit experiences an error
  • Logical qubit lifetime: How long the logical qubit maintains coherence
  • Threshold: Maximum physical error rate for error correction to work
  • Code distance: Size of the error-correcting code used in the experiment

The product of lifetime and threshold determines whether error correction provides practical advantage.

TipIntuition

Think of break-even like building a dam. Each physical qubit is like a single sandbag — it leaks some water (has errors). By arranging many sandbags in the right pattern (the surface code lattice), the dam becomes stronger than any individual sandbag. Google’s 2023 result proved this principle works: the dam (logical qubit) leaked less than a single sandbag (physical qubit).

NoteRemark

The experimental threshold of ~0.2-0.3% is lower than the theoretical ~1% threshold due to additional error sources in real hardware. Current superconducting qubits achieve ~0.1% physical error rates, putting them just below the experimental threshold. Further improvements in gate fidelity are needed for practical fault-tolerant quantum computing.

These results demonstrate that surface code error correction is no longer theoretical — it is a practical reality on current quantum hardware. The remaining challenge is reducing overhead while maintaining protection. Future experiments will focus on scaling to larger code distances and implementing logical gates through lattice surgery.

7.18.1 Code Capacity vs. Phenomenological vs. Circuit

Three standard noise models benchmark surface code performance. Understanding the differences between these models is essential for interpreting theoretical and experimental results.

NoteDefinition: Noise Models
  • Code capacity: Ideal measurements, errors only on data qubits
  • Phenomenological: Errors on data qubits and measurement
  • Circuit: Full gate-level noise model

Circuit noise is most realistic but computationally most expensive.

ImportantProposition: Threshold Hierarchy

\(p_c^\text{code} > p_c^\text{phen} > p_c^\text{circuit}\)

  • Code capacity threshold: \(\sim 15\%\)
  • Phenomenological threshold: \(\sim 10-11\%\)
  • Circuit noise threshold: \(\sim 0.1-1\%\) depending on details

Each noise model adds additional complexity:

Model Error Sources Threshold
Code capacity Data qubit errors only ~15%
Phenomenological Data + measurement errors ~10%
Circuit-level All gate/measurement/prep errors ~1%

7.18.1.1 Code Capacity Model

The code capacity model assumes perfect syndrome measurement and considers only errors on data qubits. This is the simplest model and provides an upper bound on performance.

7.19 Example: Code Capacity Errors

Each data qubit experiences depolarizing noise with probability \(p\): \(\rho \mapsto (1-3p)I/4 + p(X\rho X + Y\rho Y + Z\rho Z)\)

Measurements are assumed perfect, so syndrome extraction reveals the error pattern exactly.

This model is useful for understanding the fundamental properties of the code but does not reflect realistic hardware constraints.

7.19.0.1 Phenomenological Model

The phenomenological model adds measurement errors to the code capacity model. This captures the effect of imperfect stabilizer measurements.

7.20 Example: Phenomenological Errors

After each syndrome measurement round: - With probability \(p_m\), the measurement result is flipped - This creates “oscillating” syndromes that can confuse decoders - Multiple measurement rounds help distinguish true errors from noise

The phenomenological model better captures the behavior of repeated syndrome extraction but still ignores error propagation through gates.

7.20.0.1 Circuit-Level Model

The circuit-level noise model is the most realistic, capturing all error sources in the syndrome extraction circuit.

ImportantProposition: Circuit Error Sources

Circuit-level noise includes: - Gate errors: Imperfect single-qubit rotations and CNOT gates - Idle errors: Depolarizing during qubit idle times - Measurement errors: Classical bit-flip after measurement - State preparation errors: Incorrect ancilla initialization - Error propagation: CNOT gates can spread errors between qubits

The circuit-level threshold of ~1% is the relevant number for real hardware implementations. Current superconducting qubits achieve ~0.1% error rates, putting them below threshold for error correction to provide benefit.

NoteRemark

The surface code remains the leading candidate for near-term quantum computers because its circuit-model threshold is achievable with current superconducting qubit technologies. This is why major quantum computing efforts (Google, IBM, Amazon, etc.) focus on surface code variants.

The surface code’s combination of high threshold, local interactions, and flexible encoding makes it the foundation for modern quantum error correction and the natural starting point for studying quantum LDPC codes, which aim to reduce the overhead while maintaining these desirable properties.

7.21 Key Takeaways

  • Lattice structure: Surface codes place qubits on edges of a 2D lattice, with Z-type vertex stabilizers and X-type face stabilizers that all commute
  • Error syndromes: Single errors create paired defects; error chains create defects only at endpoints, enabling matching-based decoding
  • MWPM decoding: Minimum weight perfect matching pairs defects to minimize total correction chain length, achieving optimal decoding for independent errors
  • Boundaries: Rough boundaries (truncated Z stabilizers) allow logical Z operators; smooth boundaries (truncated X stabilizers) allow logical X operators
  • Threshold: The surface code achieves \(p_c \approx 1\%\) threshold under circuit-level noise, with recent experiments demonstrating error suppression below break-even
  • Practicality: 2D nearest-neighbor connectivity makes surface codes implementable on current superconducting qubit hardware

7.22 Bridge to Chapter 5

The surface code achieves excellent performance but requires significant overhead: protecting one logical qubit needs \(O(d^2)\) physical qubits. This raises a natural question: can we design quantum codes with the good properties of the surface code (high threshold, local decoding) but with better encoding rates?

Chapter 5 explores this question by introducing quantum LDPC codes and particularly quantum Tanner codes. These constructions generalize the surface code’s geometric intuition to achieve parameters approaching the quantum Gilbert-Varshamov bound. We will see how the hypergraph product construction systematically builds quantum codes from classical LDPC codes, and how modern constructions achieve \([[n, k, d]]\) with both \(k/n\) and \(d\) scaling favorably with \(n\).

7.23 Exercises

  1. Surface Code Stabilizers. Consider a distance-3 surface code on a \(3 \times 3\) grid. (Level: basic)

    1. How many data qubits are needed? How many X-type and Z-type stabilizers are there?

    2. Draw the stabilizer layout showing which qubits participate in each X-plaquette and Z-plaquette.

    3. Verify that neighboring X and Z stabilizers share exactly 2 qubits, ensuring they commute.

  2. Logical Operators. For the distance-\(d\) surface code: (Level: basic)

    1. Describe the path of a logical \(X_L\) operator across the lattice. What is its minimum weight?

    2. Describe the path of a logical \(Z_L\) operator. Why must it cross the lattice in a different direction than \(X_L\)?

    3. If a chain of \(X\) errors spans from one rough boundary to the other, what happens to the logical state? Is this detectable?

  3. Error Thresholds. Consider the surface code under different noise models. (Level: intermediate)

    1. Explain why the code capacity threshold (~15%) is higher than the phenomenological threshold (~10%).

    2. What additional error sources are included in the circuit-level noise model that reduce the threshold further?

    3. If a physical qubit has error rate \(p = 0.1\%\), and the circuit threshold is \(p_c = 0.5\%\), can we achieve fault-tolerant computation? What happens as we increase the code distance?

  4. MWPM Decoding. Consider a distance-5 surface code with 6 defects at coordinates \((1,2)\), \((1,5)\), \((3,1)\), \((3,4)\), \((5,2)\), \((5,5)\). (Level: intermediate)

    1. Compute all pairwise Manhattan distances between these defects.

    2. List all possible perfect matchings and their total weights.

    3. Which matching does MWPM select? Draw the resulting correction chains.

  5. Degeneracy. Two errors \(E_1\) and \(E_2\) are called degenerate if they produce the same syndrome and have the same effect on the logical state. (Level: intermediate)

    1. Show that if \(E_1 = E_2 S\) for some stabilizer \(S\), then \(E_1\) and \(E_2\) are degenerate.

    2. For a distance-3 surface code, give an explicit example of two different error chains that are degenerate.

    3. Explain why degeneracy is an advantage for quantum codes but has no classical analogue.

  6. Boundary Conditions. Compare the toric code and planar code. (Level: basic)

    1. How many logical qubits does the \(L \times L\) toric code encode? What about the planar code?

    2. Why does the toric code have periodic boundary conditions while the planar code has rough and smooth boundaries?

    3. Sketch a distance-4 planar code and mark the locations of rough and smooth boundaries.

  7. Surface Code with Code Implementation. Use the qec_code library to simulate error correction. (Level: advanced)

    1. Write code to generate a distance-5 surface code using the library.

    2. Simulate 1000 random error patterns with physical error rate \(p = 0.01\). Compute the resulting syndrome for each error.

    3. Implement a simple decoder (you may use MWPM or write your own) and measure the logical error rate after correction.

    4. Vary the code distance (d=3, 5, 7) and plot how the logical error rate changes. Does it follow the expected scaling \(p_L \sim p^{(d+1)/2}\)?

  8. Error Chain Homology. Consider the topological nature of error correction in surface codes. (Level: advanced)

    1. Explain why error chains that are homologous (can be continuously deformed into each other) all produce the same syndrome.

    2. For a planar code, how many distinct homology classes of error chains exist that connect rough boundaries? What about chains connecting smooth boundaries?

    3. If an error chain wraps around the torus in a toric code (both X and Z directions), what type of logical operator does it implement?

    4. Compute the number of distinct logical operators for an \(L \times L\) toric code. How does this relate to the number of logical qubits?