Surface-code checks and logical operators
Relate local checks, error-chain endpoints, and noncontractible logical strings in an explicit periodic lattice code.
On this page
The question for today
What you’ll understand
- Verify commutation of local vertex and plaquette checks.
- Count independent checks and logical qubits on a periodic square lattice.
- Distinguish contractible stabilizer loops from nontrivial logical cycles.
Surface codes distribute quantum information across a lattice while measuring checks supported on nearby qubits. Their geometric description separates local evidence of an error from the global route the error followed. We use the square toric code, a periodic member of the surface-code family, because it makes this distinction precise without unspecified boundary rules. Planar implementations instead choose boundary types and logical endpoints explicitly; their qubit counts and number of encoded qubits must be computed for that geometry.
Place data on edges and checks on cells
Take an L-by-L square lattice with periodic boundaries in both directions and at least three cells per side. Each horizontal or vertical edge carries one data qubit. At a vertex v, the check multiplies X on the four incident edges. Around a plaquette p, multiplies Z on its four boundary edges. All vertex pairs and all plaquette pairs commute because they use one Pauli type.
A vertex and plaquette share either zero or two edges. In the shared case, two local X-Z anticommutations cancel, so every mixed pair also commutes. The code is the common positive check eigenspace. A single Z on an edge flips the two vertex checks at its endpoints but leaves all plaquette checks unchanged. A single X similarly flips the neighboring plaquette checks, described as endpoints on the dual lattice. A Y contains both effects.
Local redundancy leaves global information
There are twice L squared edges and L squared checks of each type. However, multiplying every vertex check gives identity because each edge appears twice. The plaquette checks have the analogous single relation. These are the only relations within their respective types on this connected torus. Consequently the number of independent checks is two L squared minus two, leaving two encoded qubits. Counting every printed check as independent would incorrectly erase the global information.
A product of neighboring plaquette checks cancels internal edges and leaves a contractible Z boundary. Such a loop is a stabilizer. A Z loop winding once around a periodic direction has no vertex endpoints and hence zero syndrome, but it cannot be obtained as a boundary of plaquettes. It implements a logical Z. A dual X cycle crossing it exactly once anticommutes with it, establishing a logical conjugate pair; the other torus direction supplies the second pair.
Recovery chooses a chain class
A multi-edge Z error chain has negative vertex checks only at its endpoints: each internal vertex touches two erroneous edges and sees even parity. An ideal decoder chooses a correction chain with the same endpoints. Their combined binary chain is closed. Recovery succeeds when it is a boundary of plaquettes, meaning its homology class over is trivial, even if it contains several loops. Nonzero winding parity in either periodic direction instead leaves a logical operation. Matching a syndrome is therefore necessary but insufficient for successful recovery.
The shortest noncontractible cycle uses L edges, giving distance L. With perfect checks this guarantees correction of any data Pauli error below half that length, using an appropriate decoder. It does not guarantee correction of that many faulty circuit locations: one faulty ancilla can spread errors, and a wrong check outcome can invent endpoints. Repeated rounds and a spacetime decoder are needed when measurement is unreliable. Local check geometry enables a scalable architecture only together with those additional assumptions.
Work it through
Count a periodic four-by-four memory
For , count data qubits, independent checks, logical qubits, and ideal data distance. Compare a three-edge open Z path with a four-edge Z cycle winding once around the torus.
There are sixteen horizontal and sixteen vertical edges, so . Of sixteen vertex and sixteen plaquette checks, one relation occurs in each family, leaving and .
The three-edge open path has two distinct endpoints. Only the vertex checks at those endpoints are negative; its two internal vertices have even overlap. Path length is not directly equal to syndrome weight.
The winding four-edge cycle has no endpoints, so every check stays positive. It is a logical Z of weight four. Thus and the guaranteed number of arbitrary unknown data errors correctable with ideal checks is .
The code has 32 physical and two logical qubits; a zero syndrome can hide the four-edge logical cycle, whereas an open path produces only endpoint evidence.
The living notebook
Explore the model
Interactive lab · quantum
Interpret a nontrivial logical phase
View one protected logical qubit as a pure two-state system. Reset and set for mixing angle and relative phase, then compare a fresh Reset run at . Predict unchanged basis probabilities and reversed Bloch x after a logical Z. This instrument does not draw lattice checks, represent the second logical qubit, or simulate surface-code recovery.
- Probability |0⟩
- 71.1%
- Probability |1⟩
- 28.9%
- Bloch (x, y, z)
- 0.78, 0.45, 0.42
A normalized two-level pure state, not an interacting field simulation. Playback adds one radian per second to the relative phase; basis probabilities stay fixed. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA logical phase error changes encoded coherence even when all physical parity checks could have zero syndrome.
Pause & reason
Check your understanding
Your turn
Try it yourself
Repeat the counting for a periodic toric code. Give its ideal correction guarantee and explain the difference between a contractible Z loop and a shortest winding Z loop.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Count edges first, subtract the two check relations, and use the length of the shortest noncontractible cycle.
Compare with the solution
The code has data qubits, independent checks, and logical qubits. Its distance is five, so it corrects any two unknown data Pauli errors with ideal syndrome extraction and suitable decoding. A contractible Z loop is a product of plaquette stabilizers and acts trivially on the code. A shortest winding loop has five edges and acts as a logical Z despite producing zero syndrome. Measurement faults are outside that ideal guarantee.
Keep the idea
Take it with you
- Local checks reveal chain endpoints while global topology distinguishes logical classes.
- Check relations must be removed before counting logical degrees of freedom.
- Data distance alone does not quantify tolerance to syndrome-measurement circuit faults.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.