|q⟩ Bad Qubits

advanced · Programming · Implementing the Surface Code

Code Distance and Errors

The distance dd of a code is the weight of its smallest logical operator — the fewest single-qubit errors that can change the encoded state without being detected. For the surface code this equals the length of the shortest string spanning the patch. Distance is the single number that summarises how robust the code is.

How many errors can it correct?

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

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

errors of a given type. The reasoning is the same as for classical codes: if two distinct correctable errors produced the same syndrome, they would differ by an undetectable operator of weight at most 2t2t. To keep them distinguishable we need 2t<d2t < d, i.e. t(d1)/2t \le (d-1)/2.

For the surface code the practical consequences are:

Only odd distances are used in practice. With even dd a weight-d/2d/2 error and its complementary weight-d/2d/2 partner are equidistant from the syndrome, leaving the decoder no majority to break the tie; odd dd guarantees a unique nearest correction.

Distance versus probability

Correcting "up to tt errors" is a worst-case statement. What actually matters operationally is that any error chain shorter than d/2d/2 is matched correctly by the decoder, and only chains of weight d/2\ge \lceil d/2 \rceil can cause a logical failure. Because each additional error carries a factor of the small physical error rate pp, raising dd pushes the dominant failure mode to higher and higher order in pp — the exponential suppression we make precise in the threshold lesson.

Try it

Compute, for a distance-33 surface-code patch, how many errors of one type it can correct. Apply t=(d1)/2t = \lfloor (d-1)/2 \rfloor with d=3d = 3 and return the result. The grader checks that your returned value equals 11.

Run your code to see the quantum state.

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