This set practises Lecture 5 and
Lecture 6. Problem 1, Problem 2 and Problem 3 are
mostly pen and paper, with a short Deltakit check at the end. Problem 4 and Problem 5
start from the counts of
Notebook 6. Try each problem before you open its solution.
research/hw03_check.py recomputes every number in the solutions.
Problem 1 (When maximum likelihood is minimum weight).
Take the distance-5 repetition code: five data qubits in a line, four checks
(), and independent errors of probability on each qubit
(perfect measurements).
Checks 0 and 3 fire. List every error with this syndrome. Which one does a
minimum-weight decoder pick?
Show that, for this code and this noise, maximum-likelihood and minimum-weight decoding
are the same rule for every syndrome and every . What is missing, compared with
the surface code of Lecture 5?
Find the failure probability of the decoder at .
Solution
An on qubit flips checks and (those that exist). flips
checks 0 and 1, 1 and 2, 2 and 3: the inner checks cancel and only 0 and 3 remain.
flips check 0 (through qubit 0) and check 3 (through qubit 4). The two differ by
, the logical , which commutes with every check, so there are no
others. Minimum weight picks (weight 2 against 3).
The checks generate the whole stabilizer group, and none of its elements is a product
of s alone. So for errors each logical class contains exactly one error: and
. Maximum likelihood compares with , and for
the lighter error always wins, which is the minimum-weight rule. Degeneracy, many
errors per class, needs -type stabilizers, which the surface code has and the
repetition code does not.
The decoder returns the lighter of and , so it fails exactly when the actual
error has weight 3 or more:
which is at .
import itertoolsfrom math import combimport numpy as npn, p = 5, 0.1H = np.array([[int(j in (i, i + 1)) for j in range(n)] for i in range(n - 1)])by_syndrome = {}for e in itertools.product((0, 1), repeat=n): s = tuple(int(x) for x in H @ np.array(e) % 2) by_syndrome.setdefault(s, []).append(e)sizes = {len(v) for v in by_syndrome.values()}print("syndromes:", len(by_syndrome), " errors per syndrome:", sizes)print("errors firing checks 0 and 3:", by_syndrome[(1, 0, 0, 1)])fail = sum(comb(n, w) * p**w * (1 - p)**(n - w) for w in range(3, n + 1))print(f"failure probability at p = {p}: {fail:.5f}")
syndromes: 16 errors per syndrome: {2}errors firing checks 0 and 3: [(0, 1, 1, 1, 0), (1, 0, 0, 0, 1)]failure probability at p = 0.1: 0.00856
Problem 2 (Matching three defects by hand).
In the 3-round, distance-3 SI1000 memory at (Notebook 5), a shot fires
detectors 4, 5 and 9. Detector 4 sits at , detector 5 at
and detector 9 at . PyMatching’s decoding graph has these edges among them and the
boundary node , with weights :
edge
–
–
–
–
weight
4.771
5.425
5.425
4.850
There is no direct edge – or –; the cheapest path between them runs through .
Of these edges, only the three boundary edges cross the logical.
Explain why the total weight of a set of edges ranks corrections by probability.
An odd number of defects must use the boundary. List the three ways to pair the defects,
with their total weights. Which does matching choose, and how much less likely is the
runner-up?
Does the decoder predict a logical flip? What physical faults does its correction stand
for?
Check your answer with Deltakit, without sampling: decode a hand-made syndrome.
Solution
If independent edges fire with probabilities , a correction has probability
.
The first product is the same for every , so of the probability is a constant
plus . The lightest correction is the most probable.
The pairings are with ;
with ; and
with . Matching takes the
first. The runner-up is heavier by , so less likely by a factor
. (A path through is the same as sending both ends to the boundary:
can absorb any number of defects.)
Yes. Of the chosen edges, only – crosses the logical, so the parity is 1 and the
decoder predicts a flip. The edge – joins the same check in consecutive rounds: a
fault that flips one readout of that check, most often the readout error itself
(probability under SI1000). The edge – is a single data-qubit error at the edge
of the patch, and it flips the logical observable.
The boundary node is 16. In Notebook 5 this syndrome turns up in shot 77, and there the
logical did flip, so the decoder’s correction is right.
Problem 3 (Zero failures).
A memory runs 250,000 shots with no logical failure.
Why is "" the wrong summary?
Using a likelihood interval (Lecture 6), find the upper bound on for ,
and Deltakit’s default .
If the true is , about how many shots give a 10% error bar?
Solution
The binomial standard error vanishes at , which
would claim certainty. Zero failures in shots is also likely for any , so
the data only bound from above. Deltakit’s calculate_lep_and_lep_stddev refuses
the case with a ValueError.
With the likelihood is , maximal at . The interval keeps
, so : ,
(the rule of three) and .
The relative error is about , so 10% needs about 100 failures:
shots.
import numpy as npfrom deltakit.explorer import analysis as ann = 250_000for name, R in (("e^2", np.exp(2)), ("e^3", np.exp(3)), ("1000", 1000.0)): _, _, hi = an.calculate_lep_asymmetric([0], [n], max_likelihood_factor=R) print(f"R = {name:>4}: p_L < {hi[0]:.1e}" f" (ln R / n = {np.log(R) / n:.1e})")
R = e^2: p_L < 8.0e-06 (ln R / n = 8.0e-06)R = e^3: p_L < 1.2e-05 (ln R / n = 1.2e-05)R = 1000: p_L < 2.8e-05 (ln R / n = 2.8e-05)
Problem 4 (Error per round and SPAM).
Notebook 6 ran the memory at SI1000 for rounds,
200,000 shots each, and counted 177, 394, 832 and 1630 failures.
Compute the single-point error per round for
each . Does it depend on ?
In the model , show that to first order in the small
quantities .
Using only and , estimate from the slope, by hand.
Fit all four points with compute_logical_error_per_round, and check (2) against (1).
Solution
, , ,
give , , and (units of ). They rise with
towards a plateau: short runs look better per round.
Take the -th root:
dropping the product of two small terms. Then . A negative
lowers short runs most, as in (1).
The ratio removes :
, so
and .
The weighted fit gives and .
Then predicts the single-point values to within 3%: against
at , and against at . The leftover scatter is
within shot noise: the relative error of each point is about , from 7.5% at
to 2.5% at .
import warningsimport numpy as npfrom deltakit.explorer import analysis as anrounds = [5, 10, 20, 40]fails, n = [177, 394, 832, 1630], 200_000pl, r = np.array(fails) / n, np.array(rounds)single = 0.5 * (1 - (1 - 2 * pl) ** (1 / r))print("single-point eps:", " ".join(f"{x:.3e}" for x in single))lep, std = an.calculate_lep_and_lep_stddev(fails, [n] * 4)with warnings.catch_warnings(): warnings.simplefilter("ignore") # "max LEP below 0.2" fit = an.compute_logical_error_per_round(rounds, lep, std)print(f"fit: eps = {fit.leppr:.3e}, p_s = {fit.spam_error:.2e}")approx = fit.leppr + fit.spam_error / rprint("eps + p_s / r: ", " ".join(f"{x:.3e}" for x in approx))
The slope fits of Notebook 6 give, at SI1000 , errors per round
,
and .
Compute the two ratios . Then fit
with Deltakit, and predict
and .
A machine with must reach per round at .
What is the smallest that does it?
The rule of thumb with the total-LEP crossing of Lecture 6,
, predicts what at ? Why is the
measured value larger?
Solution
The ratios are and
, consistent with one : they differ by
0.87, under twice their combined error (about and ). The weighted fit gives and (Notebook 6
has 29.9 from the unrounded inputs), so and : each step
divides by .
At , , so we need , that is . A higher buys a smaller distance;
at the same target needs .
, well below 5.46. The rule only fixes the order of
magnitude, and the crossing of total LEPs is the wrong one to use: compares
errors per round. Slope fits over several round counts put the per-round crossings near
to (Lecture 6), so the same rule gives to 6.3,
close to the measured 5.46.
ds = [3, 5, 7]eps = [1.118e-3, 2.116e-4, 3.438e-5]std = [1.4e-5, 5.6e-6, 2.3e-6]print("ratios:", [round(eps[i] / eps[i + 1], 2) for i in range(2)])ld = an.calculate_lambda_and_lambda_stddev(ds, eps, std)L, L0 = ld.lambda_, ld.lambda0print(f"Lambda = {L:.2f}, Lambda0 = {L0:.1f}")for d in (11, 15): print(f"d = {d}: eps = {1 / (L0 * L ** ((d + 1) / 2)):.2e}")print(f"Lambda needed at d = 25: {(1 / (30 * 1e-12)) ** (1 / 13):.2f}")