|q⟩ Bad Qubits

advanced · Physics · Surface Codes & Topological Codes

Code Distance on the Lattice

The protective power of a surface code is set by its distance dd: the minimum weight of any logical operator. Because logical operators are strings that span the patch (or wind the torus), the distance is a purely geometric quantity that grows with the linear size of the lattice. This lesson makes the relationship precise and works out the code parameters [[n,k,d]][[n, k, d]].

Distance is the shortest logical string

Recall that a logical Pauli is a homologically nontrivial string: a noncontractible loop on the torus, or a boundary-to-boundary string on the planar patch. Any such string can be deformed by multiplying with stabilizers, but its weight cannot drop below the geometric minimum needed to cross the system. Hence

d=minlogical Pˉwt(Pˉ)=(length of the shortest spanning string).d = \min_{\text{logical } \bar P} \mathrm{wt}(\bar P) = (\text{length of the shortest spanning string}).

For an L×LL \times L toric code the shortest noncontractible loop runs straight across one direction and has length LL, so d=Ld = L. For a planar patch with dd qubits between the two like-type boundaries, the shortest boundary-to-boundary string has length dd.

The rotated surface code

The most hardware-efficient layout is the rotated surface code. To achieve distance dd it uses

n=d2data qubits,k=1logical qubit,n = d^2 \quad \text{data qubits}, \qquad k = 1 \quad \text{logical qubit},

with d21d^2 - 1 stabilizer checks (half XX-type, half ZZ-type, including weight-2 checks along the boundaries). Its parameters are therefore

[[n,k,d]]=[[d2,  1,  d]].[[\,n, k, d\,]] = [[\,d^2,\; 1,\; d\,]].

So for distance d=3,5,7,d = 3, 5, 7, \dots one needs n=9,25,49,n = 9, 25, 49, \dots data qubits. Inverting, the distance recoverable from a rotated patch of nn data qubits is d=nd = \sqrt{n}.

How many errors does it correct?

A distance-dd code can detect up to d1d-1 errors and correct up to

t=d12t = \left\lfloor \frac{d-1}{2} \right\rfloor

arbitrary errors. A distance-5 patch (n=25n = 25) thus corrects t=4/2=2t = \lfloor 4/2 \rfloor = 2 errors; a distance-3 patch corrects a single error. Increasing dd by 2 (the smallest step that keeps an odd, unambiguous distance) buys one more correctable error while keeping every check local.

Why this is the whole point

Every check stays weight-4 (weight-2 at boundaries) no matter how large dd becomes — locality is never sacrificed. Yet dd, and hence the protection, scales with n\sqrt{n}. Combined with a positive error threshold (two lessons ahead), this lets the logical error rate be suppressed exponentially in dd by a merely polynomial growth in qubit count. That favorable trade is the engineering case for surface codes.

Try it

For a rotated surface-code patch with n=25n = 25 data qubits, recover the distance d=nd = \sqrt{n} and return the number of correctable errors t=(d1)/2t = \lfloor (d-1)/2 \rfloor.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.