Toric Code

Almost everything about the toric code is a refusal to store information where you can find it. A stabilizer code normally protects a logical qubit by spreading it across many physical qubits, but the qubit is still, in principle, somewhere — some collection of sites you could interrogate. Alexei Kitaev's 1997 construction takes this to its logical extreme: it puts qubits on the edges of a square lattice wrapped on a torus and encodes the logical information not in any region of the lattice but in the topology of the surface itself. For an L×LL\times L torus there are N=2L2N=2L^2 physical qubits, and two logical qubits hide in the two independent ways a loop can wind around the two handles of the torus. No local measurement — nothing supported on fewer than LL qubits — can read or disturb them. The machinery is disarmingly simple. Two families of commuting checks: a star operator Av=∏e∋vXeA_v=\prod_{e\ni v}X_e at every vertex and a plaquette operator Bp=∏e∈pZeB_p=\prod_{e\in p}Z_e on every face. They all commute because any vertex and face share 00 or 22 edges, and two anticommutations cancel. Two global relations, ∏vAv=∏pBp=1\prod_vA_v=\prod_pB_p=\mathbb{1}, make exactly two of the 2L22L^2 generators redundant, leaving k=2k=2 logical qubits in a code of distance d=Ld=L — the [[2L2,2,L]][[2L^2,2,L]] code. What lifts it above a clever code is the physics it carries. Violated checks are not just error flags; they are anyons — pointlike ee charges and mm fluxes whose mutual braiding multiplies the state by −1-1. The toric code is the lattice incarnation of a deconfined Z2\mathbb{Z}_2 gauge theory and the founding example of topological order, and it is the direct ancestor of the surface code that today's fault-tolerant hardware is built around.

Key takeaways
  • Qubits live on the 2L22L^2 edges of a square lattice on a torus; the checks are a star Av=∏e∋vXeA_v=\prod_{e\ni v}X_e at each vertex and a plaquette Bp=∏e∈pZeB_p=\prod_{e\in p}Z_e on each face.
  • All checks commute because any star and plaquette share 00 or 22 edges, and the two relations ∏vAv=∏pBp=1\prod_vA_v=\prod_pB_p=\mathbb{1} leave 2L2−22L^2-2 independent generators — hence k=2L2−(2L2−2)=2k=2L^2-(2L^2-2)=2 logical qubits.
  • The logical operators are non-contractible loops: Zˉ\bar Z runs ZZ along a cycle of the direct lattice, Xˉ\bar X runs XX along a cycle of the dual lattice; only their homology class matters, not their shape.
  • The distance is the shortest non-contractible loop, d=Ld=L, so it is an [[2L2,2,L]][[2L^2,2,L]] CSS code whose protection is topological, not local.
  • Violated checks are anyons: ee charges (star defects) and mm fluxes (plaquette defects) that acquire a −1-1 phase on braiding — the Z2\mathbb{Z}_2 topological order of the model.
  • Decoding pairs syndrome defects by minimum-weight perfect matching; only error chains that wind the torus cause a logical failure, giving a finite error threshold near pc≈11%p_c\approx11\%.
  • Key idea: encode logical qubits in the homology classes of loops on a torus — the checks see only the boundaries of error chains (local, correctable), while only chains that wind the torus (non-contractible, non-local) perform logical operations or cause logical failure.
The core insight

Encode logical qubits in the homology classes of loops on a torus: the stabilizer checks detect the boundaries of error chains (local and correctable), while only chains that wind the torus — non-contractible and non-local — implement logical operations or cause logical failures.

Where this lives today

The toric code is not a museum piece; it is the blueprint of the machines being built. Cut the torus open into a planar patch with two kinds of boundary and you get the surface code, the leading candidate for scalable fault tolerance: local four-qubit star and plaquette checks measured every cycle by ancilla qubits, a syndrome streamed to a classical decoder, and a recommended Pauli correction tracked in software as a "Pauli frame." In December 2024 Google's Quantum error correction below the surface code threshold ran a distance-77 surface code on 101101 superconducting qubits and saw the logical error rate fall by a factor Λ≈2.14\Lambda\approx2.14 for every increase of the code distance by two — the first convincing demonstration of the exponential suppression the toric code promises. Neutral-atom arrays (QuEra) and trapped-ion systems (Quantinuum) have run surface and color codes with transversal logical gates and mid-circuit syndrome extraction, and lattice surgery — merging and splitting code patches — is the standard way to enact logical two-qubit gates by manipulating boundaries. Decoding itself is a live engineering frontier: minimum-weight perfect matching (Edmonds' blossom algorithm), the near-linear union-find decoder, and neural-network decoders all race to keep up with the syndrome stream in real time. And the anyons are no longer only theoretical: Rydberg-atom experiments have prepared toric-code-like Z2\mathbb{Z}_2 topological spin liquids, and trapped-ion and superconducting platforms have created and braided both Abelian and, recently, non-Abelian anyons — the first laboratory steps toward the braiding-based computation Kitaev sketched in 1997.

The physical picture

Think of every error as a string. A chain of ZZ errors is a set of edges on the direct lattice, and a star AvA_v fires (Av=−1A_v=-1) exactly at a vertex where an odd number of the chain's edges meet — which happens only at the chain's two endpoints. A chain of XX errors is a path on the dual lattice, and a plaquette BpB_p fires only at its two ends. So syndrome extraction never sees a string; it sees only the boundary of a string, a pair of point defects. If you can pair those defects and erase the chain between them — closing it into a contractible loop that the stabilizers can absorb — you have corrected perfectly. You fail only when the chain you close happens to wrap the torus.

Figure
On an L×L torus qubits sit on edges: a star Aᵥ is X on the four edges at a vertex and a plaquette Bₚ is Z on the four edges of a face — here they overlap on exactly 2 edges so Aᵥ and Bₚ commute, while a Z along a non-contractible loop is the logical Z̄ of weight L, giving the code parameters ⟦2L², 2, L⟧ = ⟦32, 2, 4⟧ at L = 4
The toric code: a star Aᵥ, a plaquette Bₚ, and a logical loop on the torus Star (X, blue) and plaquette (Z, amber) overlap on exactly 2 edges (green) ⇒ AᵥBₚ = BₚAᵥ v p Z̄ = ∏ Zₑ (weight L = 4) code parameters ⟦2L², 2, L⟧ = ⟦32, 2, 4⟧ L = 4, N = 2L² = 32 k = 2, d = L = 4 k = dim H₁(T², ℤ₂) Aᵥ = ∏ Xₑ star at a vertex Bₚ = ∏ Zₑ plaquette on a face Z̄ non-contractible loop ◦ = qubit on an edge · opposite sides identified

Now picture the two logical qubits as two independent "how much flux threads a handle" degrees of freedom. On the torus there are two inequivalent windings, and Zˉ1,Xˉ1\bar Z_1,\bar X_1 live on one cycle while Zˉ2,Xˉ2\bar Z_2,\bar X_2 live on the other. They are utterly non-local: reading a logical qubit requires an operator supported on a full loop of length at least LL, so no local perturbation, and no thermal fluctuation confined to a patch, can decohere the stored state. The degeneracy of the ground space is 22=42^{2}=4 on the torus and 22g2^{2g} on a genus-gg surface — a number fixed by topology alone, which is the defining signature of topological order. The most striking physics is in the excitations. Because a ZZ-string ends on star defects and an XX-string on plaquette defects, the elementary excitations are two species of particle: the electric charge ee (where Av=−1A_v=-1) and the magnetic flux mm (where Bp=−1B_p=-1). Each is separately a boson, but dragging an ee all the way around an mm multiplies the wavefunction by −1-1 — they are mutual semions — and their bound state ε=e×m\varepsilon=e\times m is a fermion. That −1-1 is not decoration: it is the very same sign that makes Xˉ\bar X and Zˉ\bar Z anticommute, so the anyon braiding and the logical Pauli algebra are two faces of one fact.

Figure
A Z-string ends in two e charges where Aᵥ = −1 and an X-string ends in two m fluxes where Bₚ = −1; dragging an e once around an m multiplies the state by −1, so e and m are mutual semions and their bound state ε = e × m is a fermion
Excitations are anyons: strings end in charges and fluxes, and braiding gives −1 Error strings end in anyon pairs e e m m ● e charge, Aᵥ = −1 (ends of a Z-string, solid) ■ m flux, Bₚ = −1 (ends of an X-string, dashed) Braiding an e around an m gives −1 m Bₚ = −1 e |ψ⟩ → (−1) |ψ⟩ = ∏ Bₚ over enclosed faces = −1 e, m bosons · ε = e × m fermion

Why is all of this efficient to reason about? Because the toric code is a CSS stabilizer code: the XX-type checks (stars) and ZZ-type checks (plaquettes) never mix, so XX and ZZ errors can be decoded on two independent copies of the same geometric problem. That decoupling is what makes the surface-code descendant practical — nearest-neighbor four-qubit checks, a syndrome you can read every cycle, and a decoding problem that reduces to pairing up points on a grid.

The core equations

The construction starts from two local check operators, one per vertex and one per face of the lattice. Everything else — commutation, the logical count, the anyons — is forced by their structure.

Av=∏e∋vXe,Bp=∏e∈pZe(1)A_v=\prod_{e\ni v} X_e,\qquad B_p=\prod_{e\in p} Z_e \qquad (1)

where: AvA_v — star (vertex) operator, a product of Pauli-XX over the four edges meeting at vertex vv; BpB_p — plaquette (face) operator, a product of Pauli-ZZ over the four edges bounding face pp; e∋ve\ni v — edges incident on vv; e∈pe\in p — edges on the boundary of pp. Reading: both are Hermitian, square to 1\mathbb{1}, and have eigenvalues ±1\pm1; the code is their simultaneous +1+1 eigenspace. The whole scheme only works because these checks are mutually compatible. A star and a plaquette can overlap only on an even number of qubits, and each shared qubit contributes one XZ→−ZXXZ\to-ZX flip, so the signs cancel.

AvBp=(−1)∣supp Av∩supp Bp∣ BpAv=BpAv,∣⋅∣∈{0,2}(2)A_vB_p=(-1)^{\lvert\mathrm{supp}\,A_v\cap\mathrm{supp}\,B_p\rvert}\,B_pA_v=B_pA_v,\qquad \lvert\cdot\rvert\in\{0,2\} \qquad (2)

where: supp\mathrm{supp} — the set of qubits an operator acts on nontrivially; ∣supp Av∩supp Bp∣\lvert\mathrm{supp}\,A_v\cap\mathrm{supp}\,B_p\rvert — the number of shared edges, always 00 (disjoint) or 22 (vv a corner of pp). Reading: since (−1)0=(−1)2=+1(-1)^0=(-1)^2=+1, every star commutes with every plaquette; stars commute among themselves (all XX) and plaquettes among themselves (all ZZ) trivially, so S=⟨Av,Bp⟩S=\langle A_v,B_p\rangle is abelian. The generators are not all independent. On a closed surface each edge borders exactly two vertices and two faces, so in the full product every XX (every ZZ) appears twice and cancels.

∏vAv=1,∏pBp=1(3)\prod_{v} A_v=\mathbb{1},\qquad \prod_{p} B_p=\mathbb{1} \qquad (3)

where: ∏v\prod_v — product over all L2L^2 vertices; ∏p\prod_p — product over all L2L^2 plaquettes. Reading: these are the only two relations among the generators, so the number of independent generators is 2L2−22L^2-2, not 2L22L^2 — the single fact that makes the logical count nonzero. Feeding the generator count into the stabilizer dimension formula gives the number of encoded qubits directly.

k=N−r=2L2−(2L2−2)=2(4)k=N-r=2L^2-(2L^2-2)=2 \qquad (4)

where: N=2L2N=2L^2 — physical qubits (edges); r=2L2−2r=2L^2-2 — independent generators; kk — logical qubits. Reading: the code stores exactly two logical qubits regardless of LL, and k=dim⁡H1(T2;Z2)=2gk=\dim H_1(T^2;\mathbb{Z}_2)=2g identifies them with the two independent 11-cycles of the torus. The logical operators are the operators that commute with every check yet are not products of checks — geometrically, non-contractible loops.

Zˉi=∏e∈γiZe,Xˉi=∏e∈γ^iXe,XˉiZˉj=(−1)δijZˉjXˉi(5)\bar Z_i=\prod_{e\in\gamma_i} Z_e,\quad \bar X_i=\prod_{e\in\hat\gamma_i} X_e,\qquad \bar X_i\bar Z_j=(-1)^{\delta_{ij}}\bar Z_j\bar X_i \qquad (5)

where: γi\gamma_i — a non-contractible loop on the direct lattice (a 11-cycle), i=1,2i=1,2; γ^i\hat\gamma_i — a non-contractible loop on the dual lattice; δij\delta_{ij} — the mod-22 intersection number of the two loops. Reading: a direct loop and a dual loop cross an odd number of times iff they wind the same handle, which is exactly the canonical Pauli algebra of two independent logical qubits. The distance is the weight of the lightest logical operator — the shortest loop that wraps the torus.

d=min⁡γ non-contractible∣γ∣=L,[[N,k,d]]=[[2L2,2,L]](6)d=\min_{\gamma\text{ non-contractible}}\lvert\gamma\rvert=L,\qquad [[N,k,d]]=[[2L^2,2,L]] \qquad (6)

where: ∣γ∣\lvert\gamma\rvert — number of edges (weight) of the loop γ\gamma; LL — linear size, so the shortest wrapping loop uses LL edges. Reading: any error on a contractible chain is correctable; only a chain that winds the torus can implement or mimic a logical operator, and it must have weight at least LL. The codespace projector shows the ground state is a uniform superposition of closed loops — a "string-net condensate".

∣ψ⟩∝∏v1+Av2 ∣0⟩⊗N= ⁣ ⁣∑γ∈closed loops ⁣ ⁣∣γ⟩(7)|\psi\rangle\propto\prod_{v}\frac{\mathbb{1}+A_v}{2}\,|0\rangle^{\otimes N}=\!\!\sum_{\gamma\in\text{closed loops}}\!\!|\gamma\rangle \qquad (7)

where: 1+Av2\tfrac{\mathbb{1}+A_v}{2} — projector onto Av=+1A_v=+1; ∣0⟩⊗N|0\rangle^{\otimes N} — the all-Ze=+1Z_e=+1 reference state, already a Bp=+1B_p=+1 eigenstate. Reading: expanding the star projectors flips edges along contractible loops, so the ground state is an equal-weight sum over all closed-loop configurations — the vacuum of the deconfined Z2\mathbb{Z}_2 gauge theory. Finally, the excitations obey a Z2×Z2\mathbb{Z}_2\times\mathbb{Z}_2 fusion algebra with a nontrivial mutual braiding phase.

e×e=m×m=ε×ε=1,Bem=−1(8)e\times e=m\times m=\varepsilon\times\varepsilon=\mathbb{1},\qquad B_{em}=-1 \qquad (8)

where: ee — charge (Av=−1A_v=-1); mm — flux (Bp=−1B_p=-1); ε=e×m\varepsilon=e\times m — fermionic composite; Bem=−1B_{em}=-1 — the phase from a full braid of ee around mm. Reading: four superselection sectors {1,e,m,ε}\{1,e,m,\varepsilon\}, each its own antiparticle, with the single sign Bem=−1B_{em}=-1 encoding all of the code's topological order.

Derivation ACounting the two logical qubits on the torus

The goal is to show, without hand-waving, that the toric code on an L×LL\times L torus encodes exactly k=2k=2 logical qubits — first by the stabilizer dimension count and then by the homology interpretation that explains why the answer is topological rather than a numerical accident. We assemble three ingredients: the edge/vertex/face census of the torus, the two global product relations among the checks, and the trace formula for the stabilizer codespace, and we watch them conspire to give 22=42^2=4 ground states. This doubles as a check that the codespace is nonempty, since the two axioms SS abelian and −1∉S-\mathbb{1}\notin S both hold.

Step 1. Census the lattice. A square lattice on the torus with L2L^2 vertices and L2L^2 faces has 2L22L^2 edges, and the Euler characteristic is χ=V−E+F=L2−2L2+L2=0\chi=V-E+F=L^2-2L^2+L^2=0, exactly the value for a genus-11 surface. So N=2L2N=2L^2 physical qubits. Why: the qubit count is a topological invariant of the surface, not a lattice detail — the first hint that the logical count will be too.

Step 2. Count the raw generators. There is one star per vertex and one plaquette per face, giving L2+L2=2L2L^2+L^2=2L^2 Hermitian, mutually commuting checks. Naively subtracting them from NN would give k=0k=0 — no logical qubits — so the whole encoding hangs on the generators being dependent. Why: a stabilizer code's logical count is NN minus the number of independent generators, so we must find the relations.

Step 3. Subtract the two relations. Because each edge touches two vertices, ∏vAv\prod_vA_v applies XX to every edge twice, giving 1\mathbb{1}; identically ∏pBp=1\prod_pB_p=\mathbb{1}. These are the only relations, so the number of independent generators is r=2L2−2r=2L^2-2. Why: on a closed surface the "boundary of everything is nothing" — the product of all stars, and of all plaquettes, is trivial, and there is no further redundancy.

Step 4. Apply the dimension formula. The codespace dimension is dim⁡C(S)=2N−r=22L2−(2L2−2)=22=4\dim C(S)=2^{N-r}=2^{2L^2-(2L^2-2)}=2^2=4, so k=2k=2. Equivalently, k=dim⁡H1(T2;Z2)=2gk=\dim H_1(T^2;\mathbb{Z}_2)=2g, the two independent non-contractible cycles of the torus; the four ground states are the four parity sectors of the two Zˉ\bar Z-loops. Why: reading k=2gk=2g off the topology makes the robustness manifest — deforming the lattice or adding a local perturbation cannot change a homology dimension.

Go deeper · Derivation B · 2 minLogical anticommutation from loop intersection
Derivation BLogical anticommutation from loop intersection

The goal is to derive the canonical Pauli algebra of the two encoded qubits — XˉiZˉj=(−1)δijZˉjXˉi\bar X_i\bar Z_j=(-1)^{\delta_{ij}}\bar Z_j\bar X_i — purely from the geometry of how loops cross on the torus, turning an operator commutation relation into a counting of intersection points. This is the algebraic heart of the code: it is what guarantees the two logical qubits are genuine, independent qubits, and it is the operator-level shadow of the ee–mm mutual statistics derived next. We take Zˉj\bar Z_j to be ZZ along a direct-lattice cycle γj\gamma_j and Xˉi\bar X_i to be XX along a dual-lattice cycle γ^i\hat\gamma_i.

Step 1. Confirm both are logical. A direct-lattice cycle enters and leaves any vertex through an even number of its edges, so Zˉj\bar Z_j shares 00 or 22 edges with every star AvA_v and commutes with it; it commutes with every plaquette trivially. Yet γj\gamma_j, being non-contractible, is not the boundary of any region, so Zˉj\bar Z_j is not a product of plaquettes — it acts nontrivially on the codespace. The same argument with roles swapped applies to Xˉi\bar X_i. Why: commuting with every check but lying outside the stabilizer group is precisely the definition of a logical operator.

Step 2. Collect the signs edge by edge. On a single qubit XeZe=−ZeXeX_eZ_e=-Z_eX_e, and operators on distinct qubits commute, so XˉiZˉj=(−1)∣γ^i∩γj∣ZˉjXˉi\bar X_i\bar Z_j=(-1)^{\lvert\hat\gamma_i\cap\gamma_j\rvert}\bar Z_j\bar X_i, where ∣γ^i∩γj∣\lvert\hat\gamma_i\cap\gamma_j\rvert is the number of edges the dual loop γ^i\hat\gamma_i and the direct loop γj\gamma_j share. Why: the entire commutator is fixed by how many qubits carry both an XX and a ZZ — a geometric intersection count.

Step 3. Evaluate the intersection form. On the torus, the dual cycle winding handle 11 crosses the direct cycle winding handle 11 exactly once and never crosses the orthogonal cycle, so ∣γ^i∩γj∣≡δij(mod2)\lvert\hat\gamma_i\cap\gamma_j\rvert\equiv\delta_{ij}\pmod 2 — the mod-22 intersection form is the identity matrix. Hence Xˉ1Zˉ1=−Zˉ1Xˉ1\bar X_1\bar Z_1=-\bar Z_1\bar X_1 while Xˉ1\bar X_1 commutes with Zˉ2\bar Z_2, and so on. Why: this is exactly the symplectic structure of H1(T2;Z2)H_1(T^2;\mathbb{Z}_2), the standard commutation table of two independent qubits.

Step 4. Read off the invariance. Multiplying γj\gamma_j by the boundary of a face — i.e. by a plaquette — deforms the loop but changes the intersection number by an even amount, so the algebra is untouched. The commutation relation depends only on the homology classes, not the loop shapes. Why: this is why a logical operator is a class of loops, and why local deformation (by stabilizers) can never alter the logical action.

Go deeper · Derivation C · 2 minCharge–flux braiding gives the −1 phase
Derivation CCharge–flux braiding gives the −1 phase

The goal is to prove that transporting an ee charge once around an mm flux multiplies the state by −1-1, establishing the toric-code excitations as mutual semions and grounding the model's topological order in a concrete operator identity. The mechanism is that the closed ZZ-string tracing the charge's path equals the product of the plaquettes it encloses, and a plaquette hosting a flux reports −1-1. We move an ee around a contractible loop γ\gamma that bounds a region RR containing a single mm.

Step 1. Write the transport operator. Dragging an ee around the closed path γ\gamma applies WZ=∏e∈γZeW_Z=\prod_{e\in\gamma}Z_e to the state, since a charge is carried by ZZ-string operators, and γ\gamma being contractible bounds an interior region RR of faces. Why: braiding is implemented by string operators, so the phase we want is an eigenvalue of WZW_Z.

Step 2. Rewrite the string as enclosed plaquettes. Because each interior edge of RR borders two faces inside RR, it appears in exactly two plaquette operators and cancels, leaving ∏e∈∂RZe=∏p∈RBp\prod_{e\in\partial R}Z_e=\prod_{p\in R}B_p. So the encircling ZZ-string equals the product of all plaquettes it surrounds. Why: this is the discrete Stokes' theorem of the lattice — a boundary loop equals the "curl" summed over the enclosed area.

Step 3. Evaluate on the flux. Every enclosed plaquette gives +1+1 except the one hosting the mm, which by definition has Bp∗=−1B_{p^\ast}=-1: ∏p∈RBp ∣m in R⟩=Bp∗∣m⟩=−∣m⟩\prod_{p\in R}B_p\,|m\ \text{in}\ R\rangle=B_{p^\ast}|m\rangle=-|m\rangle. If RR enclosed no flux, the product would act as the identity and the braid would be trivial. Why: the braiding phase counts, mod 22, the flux enclosed — a genuinely topological quantity insensitive to the loop's exact shape.

Step 4. Interpret the result. The full braid returns −1-1, so ee and mm are relative semions; each alone is a boson, and a self-braiding argument shows the composite ε=e×m\varepsilon=e\times m is a fermion. This −1-1 is identical to the sign in XˉZˉ=−ZˉXˉ\bar X\bar Z=-\bar Z\bar X: the mutual statistics of the anyons is the anticommutation of the logical operators. Why: it ties the two derivations together — the code's error-correcting algebra and its exotic quasiparticle physics are one and the same Z2\mathbb{Z}_2 structure.

Limiting cases

The code's behavior under changes of size, topology, noise, and temperature exposes what is essential and what is incidental:

CaseResultMeaning
Large LL (thermodynamic limit)d=L→∞, k=2d=L\to\infty,\ k=2distance grows linearly while kk stays fixed, so the rate k/N=1/L2→0k/N=1/L^2\to0 — excellent protection, poor encoding efficiency
Genus-gg surfacek=2gk=2gthe logical count equals dim⁡H1\dim H_1; the torus (g=1g=1) gives k=2k=2, a double torus k=4k=4 — encoding scales with topology, not area
Below thresholdp<pc≈10.9%p<p_c\approx10.9\%with optimal decoding the logical failure probability →0\to0 as L→∞L\to\infty; the threshold is the Nishimori point of the random-bond Ising model (MWPM gives a slightly lower ≈10.3%\approx10.3\%)
Above thresholdp>pcp>p_cerror chains percolate and routinely wind the torus, so larger LL no longer helps and the logical error rate saturates near 1/21/2
Finite temperature (2D)no self-correctionpointlike anyons cost a constant energy to create and diffuse freely, so there is no growing energy barrier — the 2D toric code is not a passively stable memory and needs active correction

Worked examples

1 · Building the ⟦50, 2, 5⟧ code and reading off its numbers (fully worked)

Take the toric code on a 5×55\times5 torus. Find the number of physical qubits, the number of independent stabilizer generators, the number of logical qubits, the distance, the code rate, and the number of single-qubit errors it can correct. Then state the ground-space degeneracy.

Step 1. Count physical qubits. The lattice has L2=25L^2=25 vertices and 2525 faces, hence N=2L2=2⋅25=50N=2L^2=2\cdot25=\mathbf{50} edges, one qubit each. (Euler check: 25−50+25=025-50+25=0, the torus.)

Step 2. Count generators. There are 2525 stars and 2525 plaquettes, 5050 raw checks, minus the two relations ∏vAv=∏pBp=1\prod_vA_v=\prod_pB_p=\mathbb{1}, giving r=50−2=48r=50-2=\mathbf{48} independent generators.

Step 3. Count logical qubits and distance. From equation (4), k=N−r=50−48=2k=N-r=50-48=\mathbf{2}. The shortest non-contractible loop uses L=5L=5 edges, so d=5d=\mathbf{5}, and the code is [[50,2,5]][[50,2,5]].

Step 4. Rate and error-correcting power. The rate is k/N=2/50=0.04k/N=2/50=\mathbf{0.04}, four logical percent — the price of topological protection. A distance-55 code corrects any error of weight up to t=⌊(d−1)/2⌋=⌊4/2⌋=2t=\lfloor(d-1)/2\rfloor=\lfloor4/2\rfloor=\mathbf{2} qubits. The 5×55\times5 toric code is a [[50,2,5]][[50,2,5]] CSS code: 5050 qubits, 22 logical qubits, distance 55, rate 0.040.04, correcting all weight-≤2\le2 Pauli errors — with a ground-space degeneracy of 2k=22=42^k=2^2=4.

2 · A winding error chain is a logical operator, not a detectable one

On the same torus, compare two ZZ-error chains: (a) a short chain of 33 edges lying along part of one row, and (b) a chain of 55 edges that runs the whole way around a row, closing on itself through the periodic boundary. Which does the syndrome catch, and what happens if the decoder mishandles each?

Step 1. Locate the defects of chain (a). A chain of 33 consecutive edges has two endpoints; at each endpoint an odd number of the chain's edges meet the vertex, so the two end-vertices have Av=−1A_v=-1 and light up as a pair of ee charges. Chain (a) produces syndrome defects at both ends — it is detected.

Step 2. Correct chain (a). The decoder pairs the two lit vertices by minimum-weight perfect matching and applies ZZ along the shortest connecting path (here the 33 edges themselves, or the complementary short path). The product of the error and the correction is a contractible loop, which is a product of plaquettes and acts as the identity on the codespace. The logical qubit is untouched.

Step 3. Locate the defects of chain (b). The winding chain has no endpoints — it closes through the torus — so every vertex it touches meets an even number of its edges and Av=+1A_v=+1 everywhere. The syndrome is completely blank; nothing lights up.

Step 4. Recognize the danger. A closed, non-contractible ZZ-loop of weight 55 is exactly Zˉ\bar Z, a logical operator. It commutes with every check (invisible to the syndrome) yet flips a logical qubit. Its weight equals the distance d=L=5d=L=5, which is the whole point of the distance: the lightest undetectable-yet-nontrivial error has weight dd, so no error of weight <d<d can be a logical failure, and any error of weight ≤⌊(d−1)/2⌋\le\lfloor(d-1)/2\rfloor is safely correctable.

Physics of the portrait

The toric code is not a lucky guess — it is the first move of a program to compute with topology. Its author had already reshaped complexity theory and quantum algorithms before turning to the question of how a quantum memory could protect itself.

Origins · 1 minAlexei Kitaev and how this was discovered
AK
Alexei Kitaev
born 1963 · topological quantum computation and anyons

Alexei Kitaev proposed the toric code in a 1997 preprint, "Fault-tolerant quantum computation by anyons" (arXiv:quant-ph/9707021, published in Annals of Physics in 2003), and with it opened an entirely new route to fault tolerance. Where earlier codes were algebraic constructions, Kitaev's idea was physical: build a many-body Hamiltonian whose ground space is degenerate for topological reasons, so that the degeneracy — and the quantum information it holds — is protected by an energy gap and a homology invariant rather than by active intervention. The same paper introduced anyons as the excitations, showed that braiding them enacts logical gates, and argued that a suitable non-Abelian model could compute universally by braiding alone. Kitaev's reach across physics and computer science is unusually wide: he devised the phase-estimation algorithm and the quantum version of the hidden-subgroup approach behind Shor's algorithm, introduced the notion of a magic state, proposed the honeycomb model that is exactly solvable in terms of Majorana fermions, wrote the Kitaev chain that is now the standard toy model for topological superconductivity and Majorana zero modes, and later co-invented the Sachdev–Ye–Kitaev model linking quantum chaos to black-hole physics. The practical descendant of the toric code — the planar surface code — is the architecture that every leading superconducting and neutral-atom quantum-computing effort is now built on. Kitaev has been recognized with the MacArthur Fellowship, the Buckley Prize, the Dirac Medal, and a Breakthrough Prize in Fundamental Physics; he works at Caltech's Institute for Quantum Information and Matter, where "protect the information with topology" has become a design philosophy rather than a slogan.

History
1977
— Leinaas and Myrheim show two-dimensional particles can obey anyonic statistics
1997
— Kitaev proposes the toric code and fault-tolerant computation by anyons
2002
— Dennis, Kitaev, Landahl, and Preskill map the error threshold to the random-bond Ising model
2012
— Fowler and collaborators lay out the practical planar surface-code architecture
2024
— Google runs a distance-7 surface code below the fault-tolerance threshold

Going further

Texts. Kitaev, Fault-tolerant quantum computation by anyons, Ann. Phys. 303, 2 (2003), arXiv:quant-ph/9707021 (the source) · Nielsen & Chuang, Quantum Computation and Quantum Information, 10th anniv. ed. (2010), Ch. 10 · Preskill, Lecture Notes for Physics 219, Ch. 9 (topological quantum computation) · Dennis, Kitaev, Landahl & Preskill, Topological quantum memory, J. Math. Phys. 43, 4452 (2002) · Watrous, The Theory of Quantum Information (2018) · Kitaev, Shen & Vyalyi, Classical and Quantum Computation (2002) · Fowler, Mariantoni, Martinis & Cleland, Surface codes: towards practical large-scale quantum computation, Phys. Rev. A 86, 032324 (2012). The key results collected in this article are: the torus census χ=V−E+F=0\chi=V-E+F=0 and N=2L2N=2L^2; commutation via even shared-edge overlap, ∣supp Av∩supp Bp∣∈{0,2}\lvert\mathrm{supp}\,A_v\cap\mathrm{supp}\,B_p\rvert\in\{0,2\}; the two relations ∏vAv=∏pBp=1\prod_vA_v=\prod_pB_p=\mathbb{1} giving r=2L2−2r=2L^2-2 and k=2k=2, with k=2gk=2g on genus gg; the loop-intersection algebra XˉiZˉj=(−1)δijZˉjXˉi\bar X_i\bar Z_j=(-1)^{\delta_{ij}}\bar Z_j\bar X_i; the braiding identity ∏e∈∂RZe=∏p∈RBp\prod_{e\in\partial R}Z_e=\prod_{p\in R}B_p giving phase −1-1; and the [[50,2,5]][[50,2,5]] parameters of Worked Example 1. Standard values quoted: d=Ld=L, threshold pc≈10.9%p_c\approx10.9\% (optimal / Nishimori) and ≈10.3%\approx10.3\% (MWPM) for independent noise with perfect syndromes; the circuit-level surface-code threshold (∼1%\sim1\%) is quoted qualitatively.

Prerequisites. Stabilizer Formalism · CSS Codes · Pauli Group and Clifford Group · Code Distance and Logical Operators · Syndrome Measurement and Decoding. Leads to. Surface Codes · Topological Quantum Computation · Quantum Hamming and Singleton Bounds · Fault-Tolerant Threshold Theorem.

Ask the tutor: Want to watch a specific error chain turn into a syndrome and get matched, or see exactly how cutting the torus into a planar patch turns this into the surface code on real hardware?

Why exactly 2 logical qubits, and not one per plaquette or one per qubit?

Because almost all of the 2L22L^2 stabilizer checks are used up constraining the physical qubits, and only a two-dimensional slack remains. There are 2L22L^2 physical qubits and 2L22L^2 raw checks, but the two global relations ∏vAv=1\prod_vA_v=\mathbb{1} and ∏pBp=1\prod_pB_p=\mathbb{1} make two of them redundant, so only 2L2−22L^2-2 are independent. Each independent check pins down one qubit's worth of Hilbert space, leaving 2L2−(2L2−2)=22L^2-(2L^2-2)=2 logical qubits no matter how large the lattice grows. The deeper reason is topological: those two qubits are the two independent ways a loop can wind the torus, i.e. dim⁡H1(T2;Z2)=2g=2\dim H_1(T^2;\mathbb{Z}_2)=2g=2. On a sphere (g=0g=0) you would get zero logical qubits; on a genus-22 surface, four.

What are the e and m anyons, physically?

They are the two elementary excitations of the code, and they are literally the two kinds of violated check. An ee (electric charge) is a vertex where the star operator reads Av=−1A_v=-1; it sits at the end of a string of ZZ errors. An mm (magnetic flux) is a face where the plaquette operator reads Bp=−1B_p=-1; it sits at the end of a string of XX errors. Each appears only in pairs, because a string has two ends, and each is its own antiparticle (e×e=1e\times e=\mathbb{1}). Individually they behave as ordinary bosons, but they are not independent: carry an ee all the way around an mm and the whole quantum state picks up a factor −1-1. That mutual statistic is what makes them anyons rather than ordinary particles, and their bound state ε=e×m\varepsilon=e\times m turns out to be a fermion. This quartet {1,e,m,ε}\{1,e,m,\varepsilon\} is the complete particle content of the Z2\mathbb{Z}_2 topological phase.

If a bigger lattice has a bigger distance, why isn't it automatically a better memory at room temperature?

Because distance protects against errors of bounded weight, not against a thermal bath that can apply many small errors continuously. Creating an ee–mm pair costs a fixed energy, roughly twice the gap, no matter how far apart the two defects end up — the "string" joining them costs nothing. So at any finite temperature, anyons are thermally nucleated and then diffuse freely; once a defect random-walks around a non-contractible loop, it has enacted a logical error that the syndrome never saw. There is no growing energy barrier to suppress this in two dimensions, so the 2D toric code has no finite-temperature self-correction. A large LL helps only if you actively measure the syndrome and correct faster than errors accumulate. Genuine passive stability requires higher dimensions: the 4D toric code, whose excitations are loops rather than points, does have a barrier that grows with size.

How is the toric code related to the surface code that hardware actually uses?

The surface code is the toric code opened up onto a planar sheet. Cutting the torus removes the periodic boundary and replaces it with two types of edge — "rough" and "smooth" boundaries — that terminate the star and plaquette checks. This costs you one thing and buys you another: a single planar patch encodes just one logical qubit instead of two, but every check becomes a local, nearest-neighbor operator on a 2D grid, which is exactly what superconducting and neutral-atom chips can measure. All the essential physics carries over unchanged: the same star and plaquette checks, the same anyonic excitations, the same minimum-weight-matching decoder, and logical operators that now run between boundaries instead of around handles. The surface code is why the toric code is not just elegant theory — it is the operating principle of the largest error-corrected quantum devices built to date.

Why does homology, of all things, show up in a code?

Because the objects the code cares about — error chains and logical operators — are exactly the objects homology classifies. An error is a chain of edges; the syndrome measures its boundary (the endpoints where checks fire). A chain with no boundary is a closed loop, a "cycle." Some cycles are boundaries of a region (contractible loops) and are harmless — they are products of stabilizers and act as the identity. Others are not boundaries of anything (non-contractible loops that wind the torus) and act nontrivially. Homology is precisely the mathematics of "cycles modulo boundaries," so the logical operators are the nonzero elements of H1(T2;Z2)H_1(T^2;\mathbb{Z}_2), and the number of logical qubits is its dimension. The whole code is a physical instantiation of a homology group, which is why deforming the lattice — a continuous change that cannot alter a topological invariant — leaves the logical structure intact.

Where does the ≈11% error threshold come from?

From a beautiful mapping to statistical mechanics. Consider independent bit-flip and phase-flip errors on the qubits, each with probability pp, and ask when the optimal decoder can still recover the logical state as L→∞L\to\infty. Dennis, Kitaev, Landahl, and Preskill showed this question is identical to asking whether a two-dimensional random-bond Ising model is in its ordered phase, with the error probability playing the role of disorder and the decoding condition sitting exactly on the model's Nishimori line. The phase boundary crosses the Nishimori line at a critical disorder corresponding to pc≈10.9%p_c\approx10.9\%: below it, logical failure is exponentially suppressed in LL; above it, error chains percolate, routinely wind the torus, and correction fails. Practical decoders fall a little short of this optimum — minimum-weight perfect matching gives about 10.3%10.3\% — and adding realistic circuit-level measurement noise lowers the usable threshold to around 1%1\%, still comfortably within reach of today's hardware.

Before this

Where this leads