|q⟩ Bad Qubits

advanced · Programming · Capstone Projects

Project: Resource Estimate a Real Algorithm

Before anyone runs a "real" algorithm on hardware, they estimate its resources: how many physical qubits, how many cycles, how long it runs once you account for error correction. This capstone performs the central fault-tolerant calculation — turning a logical-qubit count and a target error rate into a physical-qubit budget — the kind of estimate behind headline results like factoring RSA-2048.

Why logical qubits are expensive

A fault-tolerant algorithm is written in logical qubits, but each logical qubit is encoded in a patch of many physical qubits running a quantum error-correcting code. The dominant code today is the surface code, whose logical error rate falls exponentially with the code distance dd:

pLA(ppth)(d+1)/2,p_L \approx A\left(\frac{p}{p_{\text{th}}}\right)^{\lfloor (d+1)/2 \rfloor},

where pp is the physical error rate and pth1%p_{\text{th}} \approx 1\% is the threshold. You pick dd large enough that pLp_L times the total number of logical operations stays below your tolerated failure probability.

The qubit budget

A planar surface-code patch at distance dd uses roughly

nphys per logical2d2n_{\text{phys per logical}} \approx 2d^2

physical qubits (data plus measurement ancillas). For an algorithm needing QQ logical qubits the data block costs

NdataQ2d2.N_{\text{data}} \approx Q \cdot 2d^2.

With Q=100Q = 100 logical qubits at d=15d = 15:

Ndata100×2×152=100×450=45,000.N_{\text{data}} \approx 100 \times 2 \times 15^2 = 100 \times 450 = 45{,}000.

What this leaves out

A full estimate adds two more terms. Magic-state factories distill the non-Clifford (TT) states the algorithm consumes; for TT-heavy circuits these can dominate the footprint. Runtime is set by the surface-code cycle time multiplied by the algorithm's logical depth — and the depth is inflated by dd rounds of syndrome extraction per logical step. Gidney & Ekerå's RSA-2048 estimate (\sim20 million physical qubits, \sim8 hours) is exactly this calculation carried out end-to-end on Shor's algorithm.

Try it

Implement physicalQubits(logicalQubits, d) returning the data-block footprint Q2d2Q \cdot 2d^2. The grader checks you return 45,00045{,}000 for Q=100Q = 100, d=15d = 15.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.