Resource Estimation
Before committing months of effort to a quantum algorithm, you want an answer to a blunt question: how big and how long? Resource estimation produces that answer — a count of qubits, gates, circuit depth, and (under a fault-tolerant model) physical resources and runtime. It is the quantum analogue of complexity analysis, but with constants that matter, because a factor of ten can be the difference between "runs tonight" and "runs in a decade".
Two regimes of estimate
A resource estimate lives in one of two regimes:
- Asymptotic. Big- scaling: Grover searches items with queries; Shor factors an -bit number with gates. This tells you whether an algorithm is worthwhile but hides constants.
- Concrete. Exact counts for a specific instance and a specific gate set: "factoring a 2048-bit RSA key needs roughly 6700 logical qubits and Toffoli gates" (illustrative figures from the literature). This is what you submit to a hardware budget.
This lesson works the concrete count for the cleanest example: Grover's search.
Counting Grover's iterations
Grover's algorithm searches an unstructured database of items, with one marked item, by repeating a two-step Grover iterate: apply the oracle (which flips the phase of the marked state) then the diffusion operator (which reflects about the mean). Each iterate rotates the state vector by a fixed angle in the two-dimensional plane spanned by the marked and unmarked states, where
Starting from the uniform superposition (already at angle from the unmarked axis), we want to rotate as close as possible to the marked axis at . The optimal number of iterations is
This is the famous quadratic speedup: oracle calls instead of the classical .
Qubits, gates, and depth
A complete Grover estimate has three numbers:
- Width (qubits). data qubits to index items, plus any ancillas the oracle and a multi-controlled diffusion phase need. The diffusion operator's -controlled uses on the order of ancillas when decomposed into Toffoli gates.
- Gate count. Each iterate costs (oracle gates) + (diffusion gates), and there are iterates, so the leading term is . Because , the total gate count scales as times a per-iterate polynomial in .
- Depth. Roughly the gate count divided by how much parallelism the iterate allows; for the serial multi-controlled gates inside diffusion, depth and gate count scale similarly.
Why the floor, and why it can be off by one
The exact optimum is a real number ; rounding to the nearest integer maximises success probability. Using the floor of is the standard, slightly conservative choice and is exact when is large. The residual angle error means Grover's success probability is very close to but not exactly 1 — a subtlety a good resource estimate notes rather than hides.
Try it
Compute the optimal Grover iteration count for an qubit search ( items, one marked) and return it as an integer. The grader checks the value and that it is a whole number.
Sign in on the full site to ask questions and join the discussion.