Lecture 5 ended with a count: 344 failures in 100,000 shots of a distance-3 memory experiment.
Counts like that are the raw material of every performance claim in QEC, from “this decoder is
better” to “this chip is below threshold”. This lecture turns them into the numbers people
actually quote: a logical error probability with an honest error bar, an error per round, a
threshold, the suppression factor
Two warnings run through the whole lecture. Every number is a statistical estimate from a
finite run, so without an interval it means little. And every number belongs to a code, a
circuit, a noise model and a decoder taken together; change one and the number changes. Along
the way we meet two quieter traps: a
Notebook and field map
Notebook 6: Thresholds and Λ sweeps SI1000 noise for
and prints the table behind the threshold figure below, fits the error per round from four round counts, extracts and predicts QuOps. Field map: LEP and its uncertainty, Logical error per round, Thresholds, The error-suppression factor Λ, Error budgets, QuOps and resource prediction.
Counting failures
Definition 6.1 (Logical error probability).Run
shots and let of them end with the decoder’s prediction of the logical observable wrong. The logical error probability (LEP) estimate is . Each shot is a Bernoulli trial, so the standard error is .
For small
The symmetric bar of Definition 6.1 breaks down when
Remark 6.1 (Likelihood intervals and zero failures).The likelihood of
failures in shots is . A likelihood interval keeps every with . For a Gaussian, reproduces a bar, so is the analogue of two sigma. With the condition reads , so : the upper bound is for and for , the “rule of three”.
Deltakit’s calculate_lep_asymmetric computes the intervals of Remark 6.1. Its default
is
import numpy as np
from deltakit.explorer import analysis as an
n = 100_000
for f in (344, 3, 0):
try:
lep, std = an.calculate_lep_and_lep_stddev(fails=f, shots=n)
sym = f"{lep:.2e} ± {std:.1e}"
except ValueError:
sym = "ValueError"
lo, _, hi = an.calculate_lep_asymmetric(
[f], [n], max_likelihood_factor=np.exp(2))
print(f"{f:>3} fails: {sym:<18} 2-sigma [{lo[0]:.1e}, {hi[0]:.1e}]")344 fails: 3.44e-03 ± 1.9e-04 2-sigma [3.1e-03, 3.8e-03]
3 fails: 3.00e-05 ± 1.7e-05 2-sigma [7.2e-06, 7.9e-05]
0 fails: ValueError 2-sigma [0.0e+00, 2.0e-05]With 344 failures the two agree. With 3 the likelihood interval is lopsided, as it should be,
and with none the symmetric function refuses while the likelihood interval still says
calculate_lep_asymmetric (a NumPy integer scalar raises TypeError), and say which
From a run to an error per round
A memory experiment fails more often the longer it runs, so
Definition 6.2 (Logical error per round).The logical error per round
is defined through where
absorbs whatever is special about the first and last rounds: preparation, final readout and the time boundaries of the decoding graph (SPAM, for state preparation and measurement). Then is a straight line in with slope .
Setting compute_logical_error_per_round does. Here it is for
SI1000 noise at
import warnings
from deltakit.circuit.gates import PauliBasis
from deltakit.decode import PyMatchingDecoder
from deltakit.decode.analysis import StimDecoderManager
from deltakit.explorer.codes import RotatedPlanarCode
from deltakit.explorer.codes import css_code_memory_circuit
from deltakit.explorer.qpu import QPU, SI1000Noise
SEED = 2026
def fails_at(d, p, rounds, shots):
code = RotatedPlanarCode(width=d, height=d)
circ = css_code_memory_circuit(
code, num_rounds=rounds, logical_basis=PauliBasis.Z)
qpu = QPU(qubits=code.qubits, noise_model=SI1000Noise(p=p))
noisy = qpu.compile_and_add_noise_to_circuit(circ)
dec, dcirc = PyMatchingDecoder.construct_decoder_and_stim_circuit(
noisy)
mgr = StimDecoderManager(dcirc, dec, seed=SEED, batch_size=100_000)
return int(mgr.run_batch_shots(shots)[1])
rounds, shots = [5, 10, 20, 40], 200_000
eps, eps_std = {}, {}
for d in (3, 5, 7):
fails = [fails_at(d, 1e-3, r, shots) for r in rounds]
lep, std = an.calculate_lep_and_lep_stddev(fails, [shots] * 4)
with warnings.catch_warnings():
warnings.simplefilter("ignore") # "max LEP below 0.2"
fit = an.compute_logical_error_per_round(rounds, lep, std)
eps[d], eps_std[d] = fit.leppr, fit.leppr_stddev
print(f"d={d} {fails}: eps = {fit.leppr:.3e} ± "
f"{fit.leppr_stddev:.1e}, SPAM = {fit.spam_error:+.1e}")d=3 [1199, 2273, 4489, 8626]: eps = 1.118e-03 ± 1.4e-05, SPAM = +4.1e-04
d=5 [177, 394, 832, 1630]: eps = 2.116e-04 ± 5.6e-06, SPAM = -1.6e-04
d=7 [30, 63, 129, 273]: eps = 3.438e-05 ± 2.3e-06, SPAM = -2.5e-05The failures roughly double with the rounds, as they should. One caveat: fails_at reuses one
seed for every round count, so the four runs at a distance draw the same noise for their shared
first rounds and the points are not quite independent. Seeding each round count separately
(seed=SEED + r) lowers the
The SPAM term is positive at fit_logical_error_per_round_asymmetric, clamps the SPAM term at zero, which moves
Thresholds
Definition 6.3 (Threshold).For a family of codes of growing distance, a noise model of strength
and a decoder, the threshold is the noise strength below which the logical error rate goes to zero as , and above which it does not.
Below threshold, more distance helps; above it, the extra qubits bring more faults than they can correct. The value depends on everything named in Definition 6.3. For the surface code with matching, Lecture 5 quoted 10.3% for bit flips with perfect measurements. With faulty measurements it drops to about 3% (Wang, Harrington and Preskill 2003), and with circuit-level noise, where every gate, reset and measurement can fail, it falls below 1% (Fowler et al. 2012).
We only ever see finite distances, so in practice we look for the place where the curves
Two things stand out. First, the crossing is not a point:
The suppression factor Λ and what it predicts
Definition 6.4 (Error-suppression factor).Below threshold the error per round falls exponentially with distance. Write
so that
is the factor gained by each step and sets the overall scale. means below threshold.
The exponent counts the faults in the cheapest logical failure, calculate_lambda_and_lambda_stddev fits a weighted straight line to
ds = [3, 5, 7]
ld = an.calculate_lambda_and_lambda_stddev(
ds, [eps[d] for d in ds], [eps_std[d] for d in ds])
L, L0 = ld.lambda_, ld.lambda0
print(f"Lambda = {L:.2f} ± {ld.lambda_std:.2f}, "
f"Lambda0 = {L0:.1f} ± {ld.lambda0_std:.1f}")Lambda = 5.46 ± 0.12, Lambda0 = 29.9 ± 1.6The field map’s
| shots per point | ||
|---|---|---|
| rounds | 400,000 | |
| rounds | 1,000,000 | |
| slope over 5 to 40 rounds (seed 2026, above) | 200,000 | |
slope over 5 to 40 rounds (seeds 11 and 12, seed + r) | 1,000,000 |
The SPAM term is the cause. The shortcut folds it into
For scale, Google’s Willow processor measured
LambdaData returns. So pass 1 / ld.lambda0:
quops = an.predict_quops_at_distance
need = an.predict_distance_for_quops
print(f"d=15: {quops(1 / L0, L, 15):,.0f} QuOps "
f"(lambda0 passed as is: {quops(L0, L, 15):,.0f})")
print(f"d for 1e6 QuOps: {need(1 / L0, L, 1e6)} "
f"(lambda0 passed as is: {need(L0, L, 1e6)})")d=15: 1,572,737 QuOps (lambda0 passed as is: 1,758)
d for 1e6 QuOps: 15 (lambda0 passed as is: 23)The wrong convention understates QuOps by
Error budgets
Definition 6.5 (Error budget).The contribution of noise parameter
is , with the derivative taken at . Because vanishes at zero noise, by the midpoint rule, which is exact when
is quadratic along the line from to .
Deltakit’s get_error_budget follows the method of Google’s repetition-code experiment
(Nature 595, 383 (2021), supplement VIII.C).
It samples circuits on a grid of noise values, fits ToyNoise:
from deltakit.explorer.analysis.error_budget import (
FittingParameters, SamplingParameters, get_error_budget)
from deltakit.explorer.qpu import ToyNoise
def toy(circuit, x): # x = [gate error, readout flip]
noise = ToyNoise(p=float(x[0]), p_measurement_flip=float(x[1]))
qpu = QPU(circuit.qubits, noise_model=noise)
return qpu.compile_and_add_noise_to_circuit(circuit)
budget = get_error_budget(
toy, [2e-3, 6e-3], # the noise point p to explain
{3: [10], 5: [10]}, # distance: list of round counts
[(3e-4, 4e-3), (1e-3, 2e-2)], # range explored for each parameter
fitting_parameters=FittingParameters(
num_points_per_parameters=6, fitting_degree=2),
sampling_parameters=SamplingParameters(
max_shots=300_000, batch_size=100_000))
print(budget.contributions, budget.contribution_stddevs)Two runs of this block (about 8 s each) gave contributions of inverse_lambda_at and 1,000,000 shots gives
budget.lambda_estimate returns that sum, an estimate of
In Deltakit
All of the calls above live in deltakit.explorer.analysis, except the error budget, which has
its own module:
calculate_lep_and_lep_stddev(fails, shots):and of Definition 6.1; it raises ValueErrorfor zero failures.calculate_lep_asymmetric(fails, shots, max_likelihood_factor=1000.0): the likelihood intervals of Remark 6.1.compute_logical_error_per_round(rounds, lep, lep_std): the slope fit of Definition 6.2;fit_logical_error_per_round_asymmetricis the asymmetric variant.calculate_lambda_and_lambda_stddev(distances, eps, eps_std):and of Definition 6.4, as a LambdaData.predict_quops_at_distanceandpredict_distance_for_quops: QuOps, with1 / ld.lambda0.error_budget.get_error_budget,inverse_lambda_atandplot_error_budget: Definition 6.5.
The figure’s threshold points come from the same fails_at helper. Here is the column at
for d in (3, 5, 7):
f = fails_at(d, 4e-3, d, 200_000)
print(f"p = 4e-3, d = {d}, rounds = {d}: {f} fails in 200000")p = 4e-3, d = 3, rounds = 3: 9495 fails in 200000
p = 4e-3, d = 5, rounds = 5: 9932 fails in 200000
p = 4e-3, d = 7, rounds = 7: 9690 fails in 200000Notebook 6 runs the full grid of nine noise strengths and prints every count.
Try this
- In Notebook 6, refit
from rounds 5 and 10 only, then from 20 and 40 only. Which pair gives a closer to the four-point fit, and what does that say about the SPAM term? - Add
to the threshold sweep at the four largest noise strengths. Does the crossing keep drifting to higher ? - With the QuOps block, find the distance for
QuOps from the slope-fit and from the card’s , . How many qubits does the bias cost? - Run the error-budget block with the readout flip raised from
to . At what readout error does it overtake the gate error?
Readings
- A. G. Fowler, M. Mariantoni, J. M. Martinis and A. N. Cleland, Surface codes: towards
practical large-scale quantum computation,
Phys. Rev. A 86, 032324 (2012). The scaling form behind
. - C. Wang, J. Harrington and J. Preskill, Confinement-Higgs transition in a disordered gauge theory and the accuracy threshold for quantum memory, Ann. Phys. 303, 31 (2003). Thresholds with faulty measurements.
- Google Quantum AI, Exponential suppression of bit or phase errors with cyclic error correction, Nature 595, 383 (2021). The error budget method, in the supplement.
- Google Quantum AI and collaborators, Quantum error correction below the surface code
threshold, Nature 638, 920 (2025).
on hardware, and the QuOps formula in supplement VI.B. - Deltakit documentation: the analysis API and the error-budgeting example.