What a resource estimate is
"How many qubits does it take?" has no answer without a list of assumptions. A resource estimate is a model that takes a computation (how many logical qubits, how many gates, how much failure probability you can tolerate) and a description of the hardware and the error-correction scheme, and returns physical qubit counts and run times. Its value lies less in the headline numbers than in making every assumption explicit and showing which of them matter.
This lesson builds such a model from pieces you have already met: a logical error rate you measure yourself, lattice-surgery time steps, and magic-state distillation. Throughout, each quantity carries one of three labels:
- Simulated: computed in this course from a stated noise model, decoder and seed.
- Fitted: a parameter of an ansatz, fitted to simulated data, with the data range stated.
- Assumed: a modelling choice (cycle time, routing overhead, factory footprint). Assumed values are inputs, not findings, and must be reported as such.
Step 1: a logical error model from your own data
The ansatz
Below threshold, the logical error rate of a distance- surface code is commonly modelled as
The exponent reflects the smallest number of faults that can cause a logical error at odd distance , and the form is a standard heuristic in the surface-code literature (Fowler et al.). It is not a theorem. absorbs the number of minimum-weight failure paths and plays the role of a threshold, but a value fitted this way is a parameter of the ansatz, not an independently measured threshold. The ansatz is reasonable well below threshold and poor near it, where higher-order fault paths dominate.
Per shot versus per round
A memory experiment of rounds reports a failure probability per experiment, . A computation needs a rate per round (per code cycle). If each round independently flips the logical observable with probability , the observable is wrong after rounds when an odd number of flips occurred:
For small rates . Mixing the two units is one of the easiest ways to be wrong by a factor of .
Fitting
Taking logarithms with ,
which is linear in the unknowns . A weighted least-squares fit uses the failure count of each point as its weight, since the variance of is approximately for a binomial estimate with few failures. Points with zero failures carry no information about the logarithm and must be left out (or treated with an upper-bound method).
A seeded study
The exercise's default_study(seed=2026) simulates Stim's rotated surface-code
Z memory with rounds, depolarizing noise of strength after every Clifford
gate, on idle data qubits before each round, before every measurement and after
every reset, and decodes with PyMatching (Gidney, Stim)
(Higgott and Gidney), 20,000 shots per
point. A few of its simulated points (per-round rates after conversion):
| failures / 20,000 | per-round rate | ||
|---|---|---|---|
| 3 | 0.003 | 130 | |
| 5 | 0.003 | 76 | |
| 7 | 0.003 | 33 | |
| 7 | 0.002 | 3 |
The full twelve-point grid (, ) gives the fitted values and (per round). The point with 3 failures shows why weights matter: its relative uncertainty is of order , and an unweighted fit would let it pull the parameters as hard as a point with 300 failures. The exercise also asks you to refit on a subset of distances; how far the parameters move is a useful, if crude, measure of the ansatz's systematic error.
Step 2: from an error budget to a code distance
Suppose the computation keeps logical patches alive for logical time steps of code cycles each, and we allow a total memory failure probability . Using a union bound (failures are rare, so probabilities add), we need
Solving for (ignoring the slowly varying factor on the left),
Two consequences follow. The distance grows only logarithmically with the size of the computation , which is why fault tolerance scales at all. And it is inversely proportional to , so improving the physical error rate pays off most when is close to threshold.
Worked example (by hand). Take , and (all assumed for the example), so . Let , steps and . The condition becomes , that is :
- : , too large;
- : , which satisfies it.
So , and the memory failure probability is . The exercise's estimator reproduces both numbers.
Step 3: space
A rotated surface-code patch of distance uses data qubits and measurement qubits, so about physical qubits per tile (Horsman et al.). The algorithm's logical qubits need more than tiles, because lattice surgery requires free tiles for routing joint measurements between patches. Litinski's layouts trade space for speed, from compact blocks that need extra time steps to fast blocks that use roughly twice the tiles (Litinski, game of surface codes). Our model collapses this into one assumed routing factor: tiles .
Magic-state factories add their own tiles. How many factories are needed depends on how fast the computation consumes states. If the algorithm uses states per logical time step and one factory produces an accepted state every steps, about factories are needed. A factory's footprint and duration are again assumed inputs; published factory designs vary widely, and careful designs are much cheaper than early ones (Litinski, magic states).
Step 4: distillation level and time
With a count and a fraction of the budget reserved for states, each state may fail with probability at most . The number of 15-to-1 levels follows from the exact formula of the previous lesson (Bravyi and Kitaev). For raw states with error and a per-state target of , one level gives , not enough, and two levels give about , far more than enough; the discreteness of the level count is typical.
Time follows from the step count. If states are the bottleneck, the computation takes logical steps of code cycles, and the wall-clock time is with the code-cycle time an assumed hardware parameter. Real estimates also model the reaction time, the latency of decoding and feeding forward the measurement outcome that decides the correction of a gadget, which can bound the speed of sequential gates.
Putting it together
The estimator in the exercise combines these steps. Here is its core logic in a self-contained form, applied to the worked example:
import math
def estimate(Q, t_count, R, eps, p, A, p_th, cycle_s, routing, f_T, fac_tiles, fac_steps, accept):
steps = math.ceil(t_count / R)
tiles = math.ceil(routing * Q)
factories = math.ceil(R * fac_steps / accept)
d = 3
while tiles * steps * d * A * (p / p_th) ** ((d + 1) / 2) > (1 - f_T) * eps:
d += 2
qubits = (tiles + factories * fac_tiles) * 2 * d * d
return d, factories, qubits, steps * d * cycle_s
# Assumed inputs; accept = product of two levels' acceptance at p_raw = 1e-3.
print(estimate(Q=100, t_count=10**8, R=1, eps=0.01, p=1e-3, A=0.03, p_th=1e-2,
cycle_s=1e-6, routing=2.0, f_T=0.5, fac_tiles=20, fac_steps=6, accept=0.985))
It prints (25, 7, 425000, 2500.0): distance 25, seven factories, 425,000 physical
qubits and 2,500 s. Every one of those numbers is conditional on the assumed
inputs on the last lines; none is a prediction about a machine.
With the fitted parameters of the seeded study (, ) instead of the round example values, the estimator also chooses for this toy workload. Note what that step involved: the study simulated and the estimate uses , an extrapolation of the ansatz outside the data. Published estimates extrapolate too, which is exactly why they must state their models.
Sensitivity analysis
Change one assumption at a time and watch the outputs. For the toy workload with the fitted parameters (results from the exercise's reference solution):
| Parameter scaled | Factor | Distance | Physical qubits | Run time |
|---|---|---|---|---|
| (baseline) | 1 | 25 | 425,000 | 2,500 s |
| physical error rate | 0.5 / 2 | 19 / 37 | 245,480 / 930,920 | 1,900 / 3,700 s |
| fitted | 0.5 / 2 | 37 / 19 | 930,920 / 245,480 | 3,700 / 1,900 s |
| fitted | 0.1 / 10 | 23 / 27 | 359,720 / 495,720 | 2,300 / 2,700 s |
| routing factor | 0.5 / 2 | 25 / 25 | 300,000 / 675,000 | 2,500 s |
| factory tiles | 0.5 / 2 | 25 / 25 | 337,500 / 600,000 | 2,500 s |
| cycle time | 0.5 / 2 | 25 / 25 | 425,000 | 1,250 / 5,000 s |
Three lessons stand out. The ratio dominates: a factor of two in either moves the distance by six and the qubit count by more than a factor of two, because qubits scale as . The prefactor barely matters: a factor of ten changes by only two, because it enters through a logarithm. And the cycle time changes nothing but the run time in this model, while routing and factory footprints change nothing but the qubit count. A sensitivity table like this tells a reader which of your assumptions deserves scrutiny.
Published estimates and their assumptions
Published estimates differ by orders of magnitude, mostly because their assumptions and algorithms differ. Quote them only together with those assumptions:
- Gidney and Ekerå estimated that 2048-bit RSA integers could be factored in about 8 hours with about 20 million noisy qubits, assuming a planar grid with nearest-neighbour connectivity, a physical gate error rate of , a surface-code cycle time of 1 µs and a reaction time of 10 µs (Gidney and Ekerå).
- Gidney later estimated, under the same physical assumptions, that the same task could take less than a week with less than a million noisy qubits, the reduction coming mainly from approximate residue arithmetic, yoked surface codes for idle qubits and magic-state cultivation instead of distillation; the longer run time comes from more Toffoli gates and fewer factories (Gidney, 2025). The two estimates illustrate a space-time trade-off, not a contradiction.
- Beverland and co-authors built a layered resource-estimation framework and, for three application workloads and a range of qubit parameter sets, found that hundreds of thousands to millions of physical qubits are needed; they identify qubit size, speed and controllability as critical parameters (Beverland et al.).
None of these is a measurement of an existing device, and none transfers to a different error rate, connectivity or cycle time without redoing the estimate.
Common mistakes
- Mixing per-shot and per-round rates. A memory experiment with rounds reports a per-experiment probability; convert it before multiplying by the number of rounds in a computation.
- Treating a fitted as a measured threshold. It is a parameter of an ansatz with a fixed exponent. Report the data range it came from, and expect it to move if you refit on other distances.
- Fitting zero-failure points in log space. is undefined; leave them out or use an upper-bound method, and say which.
- Extrapolating silently. Using a fit at outside the simulated range is sometimes necessary; doing it without saying so is not acceptable.
- Reporting a single number. An estimate without its sensitivity to , and the layout assumptions hides its own uncertainty.
- Leaving things out without saying so. Our model ignores routing congestion, factory-internal Clifford errors, decoder latency and throughput, leakage and correlated noise. Each can matter; a careful report lists them.
Summary
- A resource estimate turns a workload and stated assumptions into physical qubits and time. Label every quantity as simulated, fitted or assumed.
- Fit to per-round rates from your own seeded simulations, weighting by failure counts.
- The required distance grows logarithmically with the size of the computation and inversely with . Qubits scale as per tile.
- Time is steps × × cycle time. -state supply often sets the step count, and factories add space.
- Sensitivity analysis shows that dominates and hardly matters. Published estimates are meaningful only with their assumptions.
What next
The capstone asks you to implement a decoder of your own, benchmark it against PyMatching with honest statistics, and publish a reproducible report of the kind whose numbers could feed an estimate like this one.