Problem 12.1 and Problem 12.2 treat the hypergraph product in general and for repetition codes. Problem 12.3 computes a constant-rate example. Problem 12.4 covers bivariate bicycle codes, Problem 12.5 compares figures of merit, and Problem 12.6 is a decoding experiment. Use the conventions of the notes: and .
Problem 1
Problem 12.1 (Why the product commutes).
Check that the blocks of and have compatible sizes, and that both have columns.
Prove over using .
What is the weight of an X-check row in terms of the row weights of and the column weights of ? Give the analogous answer for a qubit’s degree.
Solution
is and is . So has rows and columns. Likewise is and is . So has rows and the same number of columns.
stacks on top of . Then
The two blocks contribute the same matrix, which cancels mod 2. Commutation comes from the structure, not from luck with .
The X-check indexed by (check of , bit of ) has weight . In the first block, row of has the support of row of . In the second block, row of has the support of column of . By the same argument, a qubit’s degree is a column weight of one factor plus a row weight of the other. So if have bounded row and column weights, the product is LDPC.
Problem 2
Problem 12.2 (Surface codes as products).
Let be the cyclic repetition check. Compute , , and . Use the parameter theorem to get the parameters of , and show every check has weight 4.
has rows but rank . Find the dependency.
Now let be the open repetition check. Compute , and the check weights of , and identify the code for .
Explain in one or two sentences why the hypergraph product can never have distance larger than about when is a good classical code.
Solution
The kernel of is spanned by the all-ones vector, so , . is square with the same structure in its columns (each column has two ones), so is again a cyclic repetition check: , . The theorem gives , the toric code. A row and a column of both have weight 2, so each check has weight . Our script confirms , and for , all with weight-4 checks.
The sum of all star operators is the identity: each edge lies in exactly two stars. In matrix terms, the all-ones row vector satisfies because the all-ones vector lies in and in . So the rank is , and .
Now , , (all-ones) and ( has full column rank, since it is an matrix whose columns are independent). The product has and . Rows of have weight 2 and columns have weight 1 or 2, so checks have weight 3 (along the boundary) or 4. For this is , the unrotated planar surface code. Our scripts find and , with and checks of weight 3 and 4.
, while . So . A logical operator can live on a single “row” copy of inside the grid, so the distance cannot exceed the size of one factor.
Problem 3
Problem 12.3 (The Hamming product).
Let be the Hamming check of the Module 12 notes (Example 12.2), with column weights . It is the Module 4 matrix with columns permuted into systematic form; use the Module 12 version so your qubit numbering matches.
Compute , and the shapes of and for .
Find the possible check weights and qubit degrees. Do they stay bounded if we replace by a larger Hamming code?
Compute the rate and with , and compare with storing the same 16 logical qubits at distance 3 in rotated surface patches.
(Coding) Build the matrices in numpy and verify and .
Solution
. , because has full row rank, which makes . and are both .
Check weight = row weight of (4) + a column weight (1, 2 or 3), so 5, 6 or 7. Qubit degrees within are 1 to 4, from a column weight (1-3) or a row weight (4) of a factor. For the Hamming family the row weight grows, so this particular family is not LDPC as grows. To get a qLDPC family one needs classical LDPC factors, such as random sparse codes or expanders.
Rate , and . The surface code needs data qubits (rate and ). The product uses 58.
A GF(2) rank routine (row reduction with XOR) gives rank 21 for both, so . There are no redundant checks, unlike the toric code.
Problem 4
Problem 12.4 (Bivariate bicycle codes).
Let and , where is the cyclic shift, and let be sums of powers of and .
Show , and hence .
Prove for and .
Show , and argue that given that .
(Coding) For , , , compute , and . Repeat for , (the gross code). Check that each row has weight 6.
Solution
. Polynomials in commuting matrices commute, so .
.
, and is stacked on , a matrix whose kernel is . By rank-nullity, . The two ranks are equal because transposing inverts the exponents (), which is a symmetry of the torus. Then .
import numpy as npdef shift(j): return np.roll(np.eye(j, dtype=int), 1, axis=1)def bb(l, m): x = np.kron(shift(l), np.eye(m, dtype=int)); y = np.kron(np.eye(l, dtype=int), shift(m)) P = np.linalg.matrix_power A = (P(x, 3) + y + P(y, 2)) % 2; B = (P(y, 3) + x + P(x, 2)) % 2 return np.hstack([A, B]), np.hstack([B.T, A.T])
With a GF(2) rank routine we found, for , , so , and . This is . For the gross code, the ranks are 66 and , with the same kernel dimension 6. Every row of and has weight , and every qubit is in 3 X-checks and 3 Z-checks.
Problem 5
Problem 12.5 (Beating the surface code, and the price).
Compute for the toric code at , the rotated surface code at , the Hamming product, , the gross code and .
State the Bravyi-Poulin-Terhal bound and explain what it says about the last three codes.
A rotated surface patch at odd distance uses physical qubits, counting ancillas. How many physical qubits do 12 logical qubits at distance at least 12 need? Compare with the 288 of the gross code.
Solution
The values are (toric), (rotated surface), (Hamming), (), (gross) and ().
For any family of codes with local checks on a 2D grid of qubits, (Theorem 12.1). The surface code reaches the constant. The BB codes beat it by a factor of 6 to 13.5. That is allowed for fixed sizes, but a family with growing cannot be 2D-local. Their checks must contain long-range links, and the hardware has to provide them.
Distance at least 12 with odd means , so qubits, about the gross code’s 288. Bravyi et al. quote “nearly 3000” for a comparable surface-code memory, using a slightly different count. Either way the saving is about an order of magnitude.
Problem 6
Problem 12.6 (Decoding a BB code).
Using the ldpc package, simulate independent X errors with probability on , decoding from .
Implement the failure test: given the error and the correction , decide whether is a logical operator. You need a basis of the 12 Z-logicals.
Compare BpDecoder and BpOsdDecoder (product-sum, 100 iterations, OSD-CS order 7) at .
Explain why BP+OSD always produces an output with the right syndrome, and why that alone does not mean the decoding is correct.
Solution
Z-logicals are vectors in outside the row space of . Compute a basis of by GF(2) elimination. Then add each basis vector to the rows of when it raises the rank, which keeps 12 of them as rows of a matrix . A correction fails iff or .
A non-converged BP output does not satisfy the syndrome, so it counts as a failure.
With 3000 shots per point:
BP alone (non-converged)
BP+OSD-CS7
0.02
0.0123 (0.0053)
0.0103
0.04
0.0993 (0.0367)
0.0893
0.06
0.2770 (0.1387)
0.2513
OSD fixes every non-converged case that is fixable, but on this code many BP failures are converged wrong answers, so the gain is modest. The statistical error at is about .
OSD solves on an information set of independent columns (Proposition 11.1). A solution always exists, because comes from a real error and so lies in the column space. But any in the coset has the right syndrome. Choosing a member of the wrong logical class satisfies the syndrome and still fails.