Problem 7.1 (Reading syndromes on the L = 3 torus).
Work on the torus. For each error, list the stars and plaquettes that report .
.
.
.
. What kind of operator is this?
Show that and have the same syndrome, and that .
Solution
A Z-type error is seen by stars at the endpoints of its edge set. An X-type error is seen by the plaquettes that contain an odd number of its edges.
The path runs . The interior vertex touches two error edges, so its star sees an even number of flips. The flipped stars are and . No plaquette is flipped, because Z errors commute with Z checks.
The edge belongs to when , that is, for and . The flipped plaquettes are and , the two faces left and right of the edge. The left one wraps around the torus.
, so both parts act. The Z part flips the stars at the endpoints and . The X part flips the two plaquettes above and below the horizontal edge, (which contains ) and . In total four checks are flipped.
Every vertex of row 0 touches exactly two edges of the loop, so the syndrome is zero. The loop winds once around the torus, so it is not a boundary. It is the logical operator , and this error goes undetected.
is the path . is the path . Both have endpoints and , so both flip exactly and . Their sum is the closed loop around faces and , so . (Checked numerically: , and .)
Problem 2
Problem 7.2 (Independent checks, rectangles, and genus).
Consider the toric code on an torus (rows , columns ). Find , the number of independent checks, and . Argue that .
Let be any cellulation of a connected closed orientable surface of genus , with vertices, edges and faces. Put qubits on edges, X-stars on vertices and Z-plaquettes on faces. Prove that . You may use .
What is for the same construction on a cellulated sphere? Explain in one sentence why this is reasonable.
Solution
We have , with stars and plaquettes. The proof of Lemma 7.1 used only the fact that the lattice and its dual are connected graphs, so the only relations are again “all stars” and “all plaquettes”. Each family has rank , and . A Z-logical that winds horizontally must contain a horizontal edge in each of the columns, so it has weight . One that winds vertically has weight . Straight loops achieve these bounds, and the same holds for X-type logicals. So . Numerically, the torus gives and the torus gives .
A set of stars multiplies to iff every edge has both or neither endpoint in . For a connected graph this forces , so . The dual graph (faces adjacent across edges) of a closed surface is also connected, so . Therefore
For the sphere, gives : a unique state. Every closed loop on a sphere bounds a region, so every operator that commutes with the checks is a product of checks. There is no non-contractible loop to carry logical information.
Problem 3
Problem 7.3 (Homology classes and their shortest representatives).
Show that (the horizontal loop in row ) equals times a product of plaquettes, for every .
Every Z-type logical is equivalent to for some . Explain how to read and off a cycle using the X-logicals.
Show that the minimum weight of a Z-type operator in the class is , while classes and have minimum weight .
A closed path winds once horizontally and three times vertically around the torus. Which logical operator is it, modulo stabilizers?
Solution
over a full row of faces is on and for all . Each vertical edge appears in and in , so it cancels. Hence the row- loop times the row- loop is a product of plaquettes. Chaining shows that the row- loop is times the plaquettes of rows .
The commutation table is , and stabilizers commute with everything in it. So for , we get and . Here is the parity of the number of horizontal edges of in column 0, and is the parity of the number of vertical edges of in row 0. These count the horizontal and vertical winding numbers mod 2.
In class , anticommutes with every column copy , so it has a horizontal edge in each column: weight , achieved by . Class is the same with rows. In class both arguments apply at once. The cycle needs a horizontal edge in each of the columns and a vertical edge in each of the rows, and these edges are distinct, so the weight is . A staircase loop (one step right, one step down, repeated times) achieves . A brute-force search over gives minimum weights for and for in classes .
The winding numbers mod 2 are , so it is up to stabilizers. Winding twice in a direction is trivial because .
Problem 4
Problem 7.4 (How degenerate is the toric code?).
Fix and consider only Z-type errors (X errors are symmetric).
How many Z-type operators have zero syndrome? How many of them are stabilizers?
Fix a syndrome that is reachable (for example two flipped stars). How many chains have ? Into how many logical classes do they split, and how many chains are in each class?
Evaluate for . Why does this make “the most likely single error” a poor proxy for “the most likely logical class” at large ?
Solution
Zero syndrome means , which has dimension . There are such chains. The Z-stabilizers are , with elements.
The solutions of form a coset , so there are again of them. Two solutions are in the same logical class iff they differ by an element of . There are classes ( relative to ), each with chains.
For : chains per syndrome, split into 4 classes of . Each class contains one or a few short chains and very many long ones. At small the shortest chain dominates its class. At larger the number of chains of each length matters too (an “entropy” effect), and a class with many medium-length chains can outweigh a class containing the single shortest chain. The maximum-likelihood decoder of Module 10 sums over each class for this reason.
Problem 5
Problem 7.5 (Anyons and braiding).
Let be the boundary of a set of faces (a contractible closed loop). Show that .
Prepare a code state, then apply on a single edge . This creates two -particles on the faces next to . Let be the boundary of a region containing but not . What is the effect of on this state?
Use part 2 to explain, without matrices, why and must anticommute.
Solution
. Edges inside the region border two faces of and cancel mod 2, leaving the outline .
Write the state as with . By part 1, . Only (inside ) anticommutes with , so moving to the left gives one sign: . The state picks up a phase . Physically, an -particle carried around encircles exactly one -particle.
Grow the X string: apply X on the dual path that winds once vertically around the torus, so the two -particles are created, separated, and annihilated again. The result is . The loop crosses this dual path once, so during the process exactly one -particle crosses , which is the same as encircling one flux. That gives a single sign . Algebraically, the supports of and share exactly one qubit.
Problem 6
Problem 7.6 (Coding: build the toric code and decode it).
Write a function toric(L) returning (as numpy arrays over ) with the edge indexing and .
Verify and for (write a small rank routine).
For , brute-force the number of weight-3 Z-type logical operators.
(Preview of Module 10.) Use pymatching.Matching(Hx) to decode independent Z errors with probability on each qubit (code-capacity noise). A trial fails if the residual anticommutes with or . Estimate the failure rate for and . What do you observe?
Solution
A reference implementation:
import numpy as np, pymatchingdef toric(L): h = lambda i, j: (i % L) * L + (j % L) v = lambda i, j: L * L + (i % L) * L + (j % L) n = 2 * L * L HX = np.zeros((L * L, n), dtype=np.uint8); HZ = np.zeros_like(HX) for i in range(L): for j in range(L): for e in (h(i, j), h(i, j - 1), v(i, j), v(i - 1, j)): HX[i * L + j, e] ^= 1 for e in (h(i, j), h(i + 1, j), v(i, j), v(i, j + 1)): HZ[i * L + j, e] ^= 1 return HX, HZ, h, vdef rank2(M): M = M.copy() % 2; r = 0 for c in range(M.shape[1]): piv = [i for i in range(r, M.shape[0]) if M[i, c]] if not piv: continue M[[r, piv[0]]] = M[[piv[0], r]] for i in range(M.shape[0]): if i != r and M[i, c]: M[i] ^= M[r] r += 1 return rrng = np.random.default_rng(2026)for L in (4, 8, 12): HX, HZ, h, v = toric(L); n = HX.shape[1] X1 = np.zeros(n, np.uint8); X1[[h(i, 0) for i in range(L)]] = 1 X2 = np.zeros(n, np.uint8); X2[[v(0, j) for j in range(L)]] = 1 m = pymatching.Matching(HX) for p in (0.05, 0.08, 0.12, 0.15): err = (rng.random((20000, n)) < p).astype(np.uint8) res = (err + m.decode_batch(err @ HX.T % 2)) % 2 print(L, p, np.mean((res @ X1 % 2) | (res @ X2 % 2)))
All checks pass: and .
There are : three straight rows and three straight columns.
With 20000 trials per point (seeded as above) we obtained:
0.05
0.080
0.019
0.0046
0.08
0.193
0.132
0.089
0.12
0.372
0.410
0.444
0.15
0.489
0.586
0.649
Below about , larger lattices fail less often. Above it, they fail more often. The curves cross between and . This is the code-capacity threshold of minimum-weight matching for the toric code. The literature value is about (Wang, Harrington, Preskill 2003), and Module 11 shows how to estimate it carefully. Your exact numbers will differ slightly with the random seed.