A decoding graph has check nodes and a boundary node . The erased edges are , , , and . The defects are and .
The erasure contains a cycle. Which one? Give two different spanning trees of the erasure.
Run the peeling decoder on each spanning tree, listing each leaf removal. What corrections do you get?
The two corrections differ. Why are both acceptable, assuming the cycle you found is a stabilizer?
Prove that peeling runs in time linear in the number of erased edges.
Solution
The cycle is (edges ). A spanning tree must drop exactly one of these four edges and keep . For example, (drop ) and (drop ).
Root both trees at .
: leaf (via ) is not a defect, so drop . Leaf (via ) is a defect: flip and toggle , which is now a defect. Leaf (via ) is a defect: flip and toggle , which is no longer a defect. Leaf (via ) is not a defect, so drop . The correction is , the path .
: leaf (via ) is a defect: flip and toggle . Leaf (via ) is now a defect: flip and toggle , clearing it. Leaf (via ) is not a defect: drop . Then drop . The correction is , the path .
Our implementation reproduces both. Its breadth-first tree for the full erasure happens to drop and gives .
The two corrections have the same boundary , and their sum is the 4-cycle . If that cycle is a stabilizer (on a surface code, a plaquette or star), the two corrections are equivalent and both succeed.
A spanning forest can be built by breadth-first search in time. Peeling processes the nodes in reverse BFS order. Each node root removes its unique parent edge in time: one check of its defect bit and possibly one toggle. So the total work is linear.
Problem 2
Problem 11.2 (Union-Find by hand).
Use the distance-9 repetition code of the notes: checks , edges (from the left boundary to ), and (from to the right boundary).
The error is . Find the defects. Run UF growth round by round (which edges are half or fully grown, which clusters fuse or stop), then peel. What is the correction?
Repeat for the error .
In part 1, the cluster around stops for a different reason than the others. What is it, and why is the rule needed?
Solution
flips only, and flips and . So the defects are .
Round 1: every cluster grows half an edge each way. half-grows ; half-grows ; half-grows . Edge is now fully grown, so fuse: even, stop. The cluster at is still odd.
Round 2: grows and fully. The cluster now contains the boundary node, so it is no longer odd. No odd clusters remain.
Peel: cluster with edge gives . Cluster is rooted at . Leaf is not a defect, so drop . Leaf is a defect, so flip .
The correction is , equal to the error.
flips , and . The flips cancel, so the defects are .
Round 1: becomes fully grown, and fuse: even, stop. The clusters at (half of ) and (half of ) stay odd and separate. The half edges of and come from different sides of and do not meet in a fully grown edge.
Round 2: grows fully (touching ), and grows fully. They share node , so they fuse into one cluster containing , .
Peel (rooted at ): is dropped ( is not a defect). Leaf is a defect: flip , toggling . Then is a defect: flip , which clears . Then is dropped. The other cluster gives .
The correction is , again exact. Our implementation agrees on every step.
The cluster stops because it touches the boundary, not because its defect count became even. A boundary can absorb any number of string endpoints, so a cluster containing the boundary can always be explained internally (pair its defects among themselves, and send one to the boundary if the count is odd). Without this rule, a lone defect near a boundary would keep growing forever, or until it fused with unrelated clusters, producing a poor correction.
Problem 3
Problem 11.3 (Why BP needs help).
In the split-belief example of the notes (Z error on two edges of one toric plaquette, defects at diagonal corners), argue by symmetry that, at every iteration of BP, the four plaquette edges have the same marginal.
Show that any bitwise hard decision that treats the four edges identically fails to satisfy the syndrome.
Explain how OSD-0 resolves the tie, and why its output is a weight-2 path rather than something heavier.
In a non-CSS (joint X and Z) Tanner graph, show that an X-type check and a Z-type check that share any qubit must share at least two, and conclude that the graph contains 4-cycles.
Solution
Label the plaquette corners , with the defects at and . Write for the horizontal edge from to and for the vertical edge from to . The two paths are and . BP’s update rules are equivariant under automorphisms of the Tanner graph that preserve the syndrome and the prior. The initial messages are all equal (), so any such symmetry keeps every later message, and every marginal, symmetric. Two symmetries of the torus qualify. The reflection across the diagonal through the defects fixes both defects and swaps and . On its own it only shows that the marginals are equal in pairs. The 180-degree rotation about the plaquette centre swaps the two defects, so it also preserves the defect set, and it maps and . Together the two symmetries act transitively on the four plaquette edges, so all four marginals are equal at every iteration. Our numerical run gives on all four edges.
If the four edges are treated alike, the hard decision on the plaquette is all 0 or all 1. All 0 leaves both defects unexplained. All 1 is the plaquette boundary, which has zero syndrome, so it again leaves both defects unexplained. Edges outside the plaquette have small marginals and are set to 0. Either way .
OSD sorts columns by marginal. The four plaquette edges come first, in some tie-broken order. It keeps the first independent columns as the information set. The four plaquette columns are linearly dependent (their sum is the plaquette, which has zero syndrome), so only three of them enter. The syndrome is then solved using the most likely columns. The two-edge path through the edges that entered first is a solution supported on those columns, and since the information-set columns are independent, the solution is unique. So OSD outputs one weight-2 path, which is a correct decoding.
An X-check and a Z-check commute iff they overlap on an even number of qubits, where they anticommute qubit by qubit. Overlap is odd, so any nonzero overlap is at least . If they share qubits and , then is a 4-cycle in the Tanner graph. Since overlapping checks are everywhere in a quantum code, so are 4-cycles. Classical LDPC design avoids these cycles, but stabilizer codes cannot.
Problem 4
Problem 11.4 (Concatenation arithmetic).
Suppose one level of concatenation obeys with , and each level uses the Steane code (7 qubits per block).
What is the threshold?
For , how many levels are needed to reach , and how many physical qubits per logical qubit (ignoring ancillas)?
Repeat for . Comment on how the cost depends on the distance to threshold.
Solution
Setting gives .
. This gives for . So levels and qubits are needed.
Now and . For this is , still too large. For it is . So 6 levels and qubits. Moving from a factor 10 below threshold to a factor 2 below costs about more qubits. The suppression is doubly exponential in , but its base degrades sharply near threshold.
Problem 5
Problem 11.5 (Lambda and projections).
Use the Willow numbers per cycle and , and assume for odd .
Predict and .
Find the smallest odd with and the qubit count . Repeat for .
Repeat part 2 with and , keeping fixed.
A memory experiment reports after rounds. What is the per-round error?
Solution
and .
We need , that is, .
target : (qubits)
target : (qubits)
2.14
27 (1457)
63 (7937)
4
19 (721)
39 (3041)
10
15 (449)
27 (1457)
For and : , so 10 steps and , matching the Willow projection.
See the table. Raising from about 2 to 10 cuts the qubit count for by more than a factor of 5. Since , this is the payoff of better physical qubits.
. This is slightly more than , because of the small chance that two logical flips cancel.
Problem 6
Problem 11.6 (A circuit-level threshold).
Using stim.Circuit.generated("surface_code:rotated_memory_z", ...) with the same for after_clifford_depolarization, before_round_data_depolarization, before_measure_flip_probability and after_reset_flip_probability, and rounds = d:
Estimate the per-shot logical error for and , decoding with PyMatching (sample in chunks to bound memory).
Locate the crossing of each pair of curves. Does it drift?
At , estimate per-round errors for and the two values of . How many shots do you need for to see about 50 failures?
Solution
import numpy as np, stim, pymatchingdef run(d, p, shots, chunk=100_000): c = stim.Circuit.generated("surface_code:rotated_memory_z", distance=d, rounds=d, after_clifford_depolarization=p, before_round_data_depolarization=p, before_measure_flip_probability=p, after_reset_flip_probability=p) m = pymatching.Matching.from_detector_error_model(c.detector_error_model(decompose_errors=True)) sampler, fails, done = c.compile_detector_sampler(), 0, 0 while done < shots: k = min(chunk, shots - done) det, obs = sampler.sample(k, separate_observables=True) fails += int(np.sum(np.any(m.decode_batch(det) != obs, axis=1))); done += k return fails / shots
With shots per point we obtained
0.4%
0.5%
0.6%
0.7%
0.8%
0.9%
0.0116
0.0174
0.0243
0.0315
0.0395
0.0485
0.0077
0.0146
0.0234
0.0348
0.0488
0.0651
0.0040
0.0093
0.0193
0.0326
0.0528
0.0756
versus cross near , and versus near . Yes, the crossing drifts upward with size, a finite-size effect. The asymptotic threshold for this model is roughly or a bit higher. A finite-size scaling fit with larger would pin it down.
With , and shots we found , and . Converting with gives , and , so and . Fifty failures at need about shots. The relative statistical error is then about .