research30 min studyLesson 436 in Physics

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

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 AvA_v multiplies X on the four incident edges. Around a plaquette p, BpB_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.

Av=∏e∋vXe,Bp=∏e∈∂pZe,[Av,Bp]=0A_v=\prod_{e\ni v}X_e,\qquad B_p=\prod_{e\in\partial p}Z_e,\qquad [A_v,B_p]=0
The products run over four edges on this periodic square lattice. The dimensionless Pauli checks describe ideal measurements, rather than the noisy ancilla circuits used to obtain them.↔ Scroll wide equations horizontally.

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.

n=2L2,r=2L2−2,k=n−r=2,d=Ln=2L^2,\qquad r=2L^2-2,\qquad k=n-r=2,\qquad d=L
These counts and distance apply to the specified periodic square toric code with equal side lengths. Other surface-code layouts and boundaries have different counts.↔ Scroll wide equations horizontally.

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 Z2\mathbb Z_2 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.

∂(E+C)=0,E+C∈S for successful Pauli recovery\partial(E+C)=0,\qquad E+C\in S\ \text{for successful Pauli recovery}
Here E and C denote binary edge sets for one Pauli type, addition is symmetric difference, and the boundary lists syndrome endpoints. A closed chain can still be logically nontrivial.↔ Scroll wide equations horizontally.

Count a periodic four-by-four memory

For L=4L=4, 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.

  1. There are sixteen horizontal and sixteen vertical edges, so n=32n=32. Of sixteen vertex and sixteen plaquette checks, one relation occurs in each family, leaving r=30r=30 and k=2k=2.

  2. 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.

  3. The winding four-edge cycle has no endpoints, so every check stays positive. It is a logical Z of weight four. Thus d=4d=4 and the guaranteed number of arbitrary unknown data errors correctable with ideal checks is ⌊3/2⌋=1\lfloor3/2\rfloor=1.

The result

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.

Explore the model

Interactive lab

Interactive lab · quantum

Interpret a nontrivial logical phase

View one protected logical qubit as a pure two-state system. Reset and set 90∘,0∘90^\circ,0^\circ for mixing angle and relative phase, then compare a fresh Reset run at 90∘,180∘90^\circ,180^\circ. 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.

Interpret a nontrivial logical phaseA normalized two-level pure state, not an interacting field simulation. Playback adds one radian per second to the relative phase; basis probabilities stay fixed. Current readings: Probability |0⟩: 71.1%; Probability |1⟩: 28.9%; Bloch (x, y, z): 0.78, 0.45, 0.42. All parameters are adjustable with the labeled controls below.xyz|0⟩|1⟩Basis probabilitiesP(0)71.1%P(1)28.9%
Bloch vector / P(0)P(1)Phase latitude
Probability |0⟩
71.1%
Probability |1⟩
28.9%
Bloch (x, y, z)
0.78, 0.45, 0.42
t = 0 s

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.

Check your understanding

For the specified periodic square toric code, why are there two logical qubits?

Try it yourself

Repeat the counting for a periodic L=5L=5 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 n=50n=50 data qubits, r=48r=48 independent checks, and k=2k=2 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.

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.