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 and what it predicts, and an error budget that says which physical error to fix first.

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 estimated from one round count per distance is biased, and two Deltakit helpers disagree about what means.

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 relative error is . It depends on the number of failures, not of shots: a hundred failures give about 10%, ten give about 30%. That is why good codes are expensive to measure. At , a 10% error bar needs shots.

The symmetric bar of Definition 6.1 breaks down when is small. With 3 failures it reaches almost to zero; with none it is zero, a certainty the data cannot support. The fix is to keep every that explains the data nearly as well as the best guess.

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 , about , wide on purpose. Here it is at , next to the symmetric estimate:

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 . Two habits for Deltakit 0.10.2: pass plain integers or lists to calculate_lep_asymmetric (a NumPy integer scalar raises TypeError), and say which you used.

From a run to an error per round

A memory experiment fails more often the longer it runs, so alone does not describe the code. Suppose each round flips the logical qubit independently with probability . The run fails when an odd number of rounds flip it. The average of is then a product of independent factors , and it equals .

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 and solving at one gives , the shortcut usually applied with rounds . The better practice is to run several round counts and fit the slope, which is what compute_logical_error_per_round does. Here it is for SI1000 noise at , with 5, 10, 20 and 40 rounds and 200,000 shots each (about 10 s):

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-05

The 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 fitted below from 5.46 to 5.43, a quarter of its standard error.

The SPAM term is positive at and negative at . At it is smaller than its own error bar here (Notebook 6 prints ); million-shot runs put it near . A negative value is allowed: it says that the rounds next to the time boundaries fail less often than bulk rounds, plausibly because fewer fault paths fit there. At the extra preparation and readout errors win. Deltakit warns whenever the largest LEP is below 0.2 and suggests longer runs; at these small LEPs the line is still well determined, so the block silences the warning. The variant with asymmetric errors, fit_logical_error_per_round_asymmetric, clamps the SPAM term at zero, which moves at from to .

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 for different cross. The figure shows SI1000 noise, rounds , 200,000 shots per point, decoded by PyMatching.

0.001 0.01 0.1 0.002 0.003 0.004 0.006 SI1000 noise strength p logical error probability d = 7 d = 5 d = 3 curves cross rounds = d, 200,000 shots PyMatching, seed 2026

Two things stand out. First, the crossing is not a point: and 5 cross between and , but and 7 between and . Small codes drift, and the standard remedy is a finite-size scaling fit, , over more distances. Second, the crossing depends on what you plot. These curves compare total LEPs of runs of different length, rounds each. Per round (Definition 6.2), converting each point of this sweep on its own, the order has not flipped even at : , and for . Those points still carry their SPAM terms. Slope fits over several round counts put the per-round crossings near () and (), 1.4 to 1.7 times the per-shot values. So a circuit-noise threshold is a range unless you say which quantity crosses. Note also that SI1000’s is the two-qubit gate error; its measurements flip with probability , so these values do not compare directly with a uniform depolarizing threshold.

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, , each costing a factor of about , so roughly (Fowler et al. 2012). calculate_lambda_and_lambda_stddev fits a weighted straight line to against . Fed the per-round errors fitted above:

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.6

The field map’s card uses the shortcut instead: rounds , one 400,000-shot run per distance, failures 1409, 368 and 87, giving . The two differ by about three standard errors. More shots and other seeds show that the shortcut is biased, not unlucky:

estimated fromshots per point
rounds (field-map card, seed 2026)400,000
rounds (seeds 11 and 12)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 : positive at , so comes out too large, and negative at and 7, so those come out too small. So comes out about 20% too large; barely moves, but the fit leans on the precise point, and is inflated. An 8% error in sounds harmless until you extrapolate. Inverting Definition 6.4, a target of per round needs (881 physical qubits for one patch, ) with the slope fit, against the (721 qubits) that the shortcut predicts.

For scale, Google’s Willow processor measured per step (with its neural-network decoder; ensembled matching gives ), up to a 101-qubit distance-7 memory with error per cycle (PUBLISHED; Google Quantum AI, Nature 638, 920 (2025)). That is hardware noise with its own decoders, so it does not compare with a simulated model.

also turns into an operations budget. Deltakit counts QuOps, logical operations before a failure, as of one -round block at distance , with the odd-flip sum of the Willow supplement (Sec. VI.B). The QuOps helpers, however, write : their is the reciprocal of the one in Definition 6.4 that 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 , and asks for (1,057 qubits) where (449 qubits) is enough.

Error budgets

says how good the code is; an error budget says why. Write the noise model as a vector of parameters , such as gate, readout and idle errors. Below threshold is close to linear in the noise, so it splits into one share per parameter.

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 with a polynomial and differentiates it at . On hardware, the measured minus is the excess: error that the noise model does not explain. The call takes a function that builds a noisy circuit from a parameter vector. Here it is a two-parameter ToyNoise: is the two-qubit depolarizing error (one-qubit gates, idles and resets get ) and the readout flip. It has no seed and draws progress bars, so this page does not run it:

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 and for the gate error and and for the readout. Gate errors carry about 72% of the budget although the readout flip is three times larger, so they are the ones to improve first. The sums, , should match at . A direct estimate with inverse_lambda_at and 1,000,000 shots gives (interval to ), that is , so the two agree to within two standard errors, the precision these coarse settings buy. One naming trap: despite its name, budget.lambda_estimate returns that sum, an estimate of , not 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 ValueError for 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_asymmetric is the asymmetric variant.
  • calculate_lambda_and_lambda_stddev(distances, eps, eps_std): and of Definition 6.4, as a LambdaData.
  • predict_quops_at_distance and predict_distance_for_quops: QuOps, with 1 / ld.lambda0.
  • error_budget.get_error_budget, inverse_lambda_at and plot_error_budget: Definition 6.5.

The figure’s threshold points come from the same fails_at helper. Here is the column at , nearest the crossing:

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 200000

Notebook 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.