Code distance

On this page 7

Code distance, usually written d, is the minimum weight of an error that changes the encoded logical information of a quantum error-correcting code without being detected. In quantum error correction it is the single most important measure of code strength, because a code of distance d can detect up to d − 1 errors and correct up to ⌊(d − 1)/2⌋ errors on arbitrary qubits.

Codes are commonly labeled with the notation [[n, k, d]], where n is the number of physical qubits, k the number of logical qubits and d the distance. In quantum computing practice, the distance determines how fast the logical error rate falls when physical hardware improves, which makes it a central parameter in every fault-tolerant resource estimate.

How code distance is defined

For a stabilizer code, the distance is the smallest weight of a Pauli operator that commutes with every stabilizer but is not itself a stabilizer. Such an operator is a nontrivial logical operator: it passes every syndrome check unnoticed while flipping or dephasing the logical qubit. The weight counts how many qubits the operator acts on nontrivially.

Many codes treat bit flips and phase flips separately, so engineers often quote two distances. The X distance is the minimum weight of a logical X operator, and the Z distance is the minimum weight of a logical Z operator; the overall distance is the smaller of the two. Asymmetric codes deliberately make one distance larger when the hardware is biased toward one error type.

Distance dErrors detectedErrors correctedTypical use
100No protection
210Error detection and postselection
321Smallest correcting codes, demonstrations
542Early logical qubit experiments
763Below-threshold scaling studies
25 and more24 or more12 or moreProjected large-scale algorithms
What a given distance guarantees

Distance of well-known codes

Different code families achieve their distance with very different qubit overheads. The comparison below lists standard codes in [[n, k, d]] notation together with the connectivity they require, which is often the deciding practical factor.

CodeParametersConnectivity required
Shor code[[9, 1, 3]]Moderate, non-local checks
Steane code[[7, 1, 3]]Weight-four checks
Five-qubit code[[5, 1, 3]]Smallest possible distance-three code
Rotated surface code[[d², 1, d]]Nearest neighbors on a square grid
2D color codeAbout [[3d²/4, 1, d]]Planar, weight-six checks
Bivariate bicycle code[[144, 12, 12]]Some long-range couplings
Parameters of common quantum codes

The surface code is popular despite its quadratic qubit overhead because it tolerates high physical error rates and needs only local interactions. Quantum LDPC codes reach far better ratios of k and d to n, but they require long-range connectivity, which hardware is only beginning to provide.

Code distance and the logical error rate

Below the error threshold, increasing the distance suppresses logical errors exponentially. For the surface code, a widely used approximation is p_L ≈ A (p / p_th)^((d+1)/2), where p is the physical error rate, p_th the threshold of roughly one percent and A a constant of order 0.1. Each increase of d by two multiplies the logical error rate by the ratio p / p_th.

This ratio is often expressed through the suppression factor Λ, the factor by which logical error falls when distance grows by two. A device with Λ = 2 halves its logical error per step, while Λ = 10 gives an order of magnitude. The table illustrates how the physical error rate shapes the required distance.

Physical error rateRatio to thresholdApproximate distance needed
0.5 percent0.5Above 50, impractical
0.2 percent0.2About 25
0.1 percent0.1About 17
0.01 percent0.01About 9
Approximate surface-code distance for a target of one logical error in a billion operations

These figures are order-of-magnitude estimates. Real values depend on noise correlations, decoder quality, measurement errors and the number of syndrome rounds, so serious resource estimates rely on detailed circuit-level simulation.

Code distance captures the worst-case error pattern, but it is not the only figure that matters. Two codes with the same distance can perform quite differently, because performance also depends on how many low-weight logical operators exist and on the noise model.

  • Threshold is the physical error rate below which increasing distance helps; distance alone says nothing about it.
  • Effective distance is the distance after accounting for errors during syndrome extraction, and poor circuits can reduce it below the nominal value.
  • Logical error rate is the quantity users actually care about, and distance is the main lever that controls it.
  • Encoding rate k/n measures qubit efficiency and often trades off against distance.

A frequent misconception is that a distance-d code fails at exactly ⌊(d − 1)/2⌋ + 1 errors. Many heavier error patterns are still corrected, so logical failure is probabilistic and depends on which specific qubits fail.

Practical pitfalls when choosing a distance

Choosing a distance means balancing qubit count, time and reliability. A distance-d rotated surface code patch uses d² data qubits and about the same number of measurement qubits, and syndrome extraction is usually repeated about d times per logical cycle, so both space and time grow with distance.

Hook errors are a classic pitfall: a single fault in a syndrome-measurement circuit can spread to two data qubits and halve the effective distance unless the gate order is chosen carefully. Leakage, cosmic-ray events and other correlated errors can likewise defeat the independence assumption that underlies the distance guarantee.

A non-technical view

Imagine a message protected by many guards. Code distance is how many guards an attacker must defeat before the message changes without anyone noticing.

A bigger distance means more mistakes are needed to cause real harm. Quantum computers make small mistakes all the time. A larger distance lets them survive those mistakes. The price is simple. More protection needs more qubits.

A concrete example

A hardware team operating a superconducting processor with a physical two-qubit error rate near 0.3 percent runs surface-code memory experiments at distances three, five and seven. Each experiment stores one logical qubit for dozens of syndrome cycles and measures how often the decoded result is wrong.

The team finds that moving from distance five to distance seven roughly halves the logical error per cycle, a suppression factor Λ of about two. This confirms that the device operates below threshold, because a larger code is now more reliable rather than less.

Using the measured Λ, the team estimates that reaching one error in a million cycles would require distance 27 or more with current hardware. Halving the physical error rate would bring that requirement down to about distance 15, which shows engineers that improving gate fidelity saves more qubits than simply building larger codes.