Overview
Most quantum error-correcting codes used in practice, the surface code above all, implement the Clifford group fault-tolerantly and cheaply, and no code implements a universal gate set transversally (see logical gates). Clifford circuits alone are classically simulable, so something else must supply the missing non-Clifford gate. The standard answer is to prepare a special resource state, a magic state such as the T state or the CCZ state, and to consume it by gate teleportation (Gottesman and Chuang).
A magic state prepared directly on an encoded qubit (by state injection) carries an error comparable to the physical error rate, far too large for a long computation. Magic state distillation (Bravyi and Kitaev; Knill) uses only Clifford operations and measurements to turn many noisy copies into fewer, much better ones. The regions of a fault-tolerant computer that do this are called magic state factories, and their cost has long been one of the main inputs to resource estimates.
Intuition
Clifford operations on an error-corrected machine are reliable but "flat": they can never create magic, only move it around. A noisy T state is a little bit of magic mixed with noise. Distillation exploits a code that has a transversal gate. Feed fifteen noisy T states into the fifteen qubits of such a code, and the noise becomes a pattern of errors on the block. The code's checks catch every pattern of one or two errors; the block is thrown away when a check fires. Only a pattern of three or more errors in a specific arrangement slips through, so an input error rate becomes roughly . Repeating the procedure on its own outputs drives the error down doubly exponentially in the number of rounds.
There is a limit. If the noisy input is so bad that it could have been produced by randomly choosing stabilizer states, no Clifford procedure can extract magic from any number of copies. Distillation therefore has a threshold input quality, and the price of each output grows only polylogarithmically with the target accuracy.
Prerequisites
Stabilizer codes, the Clifford group and the Clifford hierarchy, gate teleportation, and the idea of fault-tolerant gadgets. The Hamming code and Reed–Muller codes appear in the analysis.
Mathematical Definitions
Consider qubits (or systems of prime dimension ). A pure stabilizer state is a state with in the Clifford group, the group of unitaries that map Pauli operators to Pauli operators under conjugation. The stabilizer polytope is the convex hull of the pure stabilizer states; these are the free states. A state outside is a magic state.
Stabilizer operations are the channels generated by
- preparing ancillas in ,
- Clifford unitaries,
- measurements of Pauli operators,
- discarding subsystems,
- choosing any of the above at random or conditioned on earlier measurement outcomes.
They map into . This is the framework of Veitch, Mousavian, Gottesman and Emerson. Its motivation is computational. By the Gottesman–Knill theorem a circuit of stabilizer operations acting on stabilizer states can be simulated efficiently on a classical computer (section 10.5.4 of Nielsen and Chuang), whereas Bravyi and Kitaev showed that stabilizer operations supplemented with a supply of suitable single-qubit magic states are universal for quantum computation and that such states can be distilled from noisy copies. In fault-tolerant architectures stabilizer operations are the comparatively cheap ones, so magic is the costly resource (see Magic State Distillation).
Monotones in use include:
- for odd prime dimension, the mana, the logarithm of the sum of absolute values of the discrete Wigner function of the state, and the relative entropy of magic (Veitch and co-authors); states with a non-negative Wigner function cannot be distilled to pure magic states by stabilizer operations;
- for qubits, the robustness of magic
introduced by Howard and Campbell. It equals 1 exactly on , is submultiplicative under tensor products, and controls the sampling overhead of a classical simulation that replaces magic states by quasi-probability mixtures of stabilizer states.
With , the T state is
It is the eigenstate of the Clifford operator , and it is not a stabilizer state, so it is a magic state in the sense of stabilizer operations. It is related by a Clifford gate to the eigenstate of the Hadamard gate; in the terminology of Bravyi and Kitaev both are H-type magic states.
Injection. One copy of and stabilizer operations implement the gate on an arbitrary qubit . Apply a CNOT controlled on the data qubit with the qubit as target and measure the target in the basis. Outcome 0 leaves the data qubit in . Outcome 1 leaves it in up to a phase, and applying gives . The two outcomes are equally likely. This is an instance of the gate teleportation of Gottesman and Chuang.
Noisy T states. Applying with probability maps any single-qubit state to
because has eigenvectors and and the random application removes the off-diagonal terms in that basis. The fidelity with is unchanged. A noisy T state can therefore be treated as an ideal one that suffers a error with probability , and injecting it applies followed by with probability . The number is the error rate of the magic state.
With , the CCZ state is
is in the third level of the Clifford hierarchy: it maps each Pauli operator to a Clifford operator under conjugation (for example ). Consequently one copy of , consumed by gate teleportation (Gottesman and Chuang), applies a CCZ gate to three data qubits with only Clifford corrections chosen by measurement outcomes. Conjugating a target by Hadamard gates turns CCZ into a Toffoli gate.
A CCZ gate can be built from gates and Clifford gates; with an ancilla and a measurement, four gates suffice for a Toffoli gate, against seven in the standard ancilla-free circuit (Jones). Factories that output CCZ states directly can be cheaper per Toffoli than factories for four separate T states. Gidney and Fowler also give a catalysed conversion that turns one CCZ state into two T states, using one extra T state that is returned at the end.
Theorems
No distillation from stabilizer mixtures
Let be states with , and let a protocol built from stabilizer operations act on and on ancillas prepared in . For every sequence of measurement outcomes that occurs with non-zero probability, the normalised state of the remaining qubits conditioned on lies in . Consequently the unconditioned output, and the output conditioned on any accepting set of outcomes (post-selection), also lies in .
Corollary (no distillation from free states). If a noisy resource state lies in , then no stabilizer protocol consuming any number of copies of outputs a state whose fidelity with a target state exceeds . In particular a distillation protocol for magic states can only work on inputs that lie outside the stabilizer polytope. This is the observation behind the threshold analysis of Bravyi and Kitaev and the resource-theory framework of Veitch and co-authors. For the state the boundary is computed in equation/stabilizer-fidelity-bound-for-the-t-state.
- Qubits; is the convex hull of the -qubit pure stabilizer states , Clifford.
- Stabilizer operations are those generated by preparing , Clifford unitaries, Pauli measurements, discarding qubits, and classical randomness and feed-forward based on earlier outcomes, all noiseless.
Proof · Proof that stabilizer operations preserve the stabilizer polytope
We use the standard fact that an -qubit state is a pure stabilizer state exactly when it is the unique joint eigenvector of an abelian group of Pauli operators (with signs) not containing , generated by independent elements, and that then (Gottesman; Aaronson and Gottesman). Such an is a maximal abelian subgroup: a Hermitian Pauli operator that commutes with every element of lies in .
Step 1: elementary operations on pure stabilizer states.
- Tensor products and ancillas. If and with Clifford, then and is Clifford. Adding an ancilla is the case .
- Clifford unitaries. is a stabilizer state because is Clifford.
- Pauli measurement. Measure a Hermitian Pauli operator on with stabilizer group . If the outcome is deterministic and the state is unchanged. Otherwise fails to commute with some element of (by maximality), so it anticommutes with some ; choose generators of such that commute with (multiply any generator that anticommutes with by ). Each outcome occurs with probability , and the post-measurement state is stabilized by , which are independent commuting Pauli operators. So it is again a pure stabilizer state.
- Discarding qubits. Split the qubits as with . Since every non-identity Pauli operator is traceless, , where consists of the restrictions to of those that act as the identity on . is an abelian group of Pauli operators on without ; let it have independent generators, so with the projector onto its joint eigenspace, of dimension . Extend the generators by further independent Pauli operators that commute with and with each other (for example logical operators of the stabilizer code ). Then , where is the pure stabilizer state stabilized by and . Therefore is the uniform mixture of the states , an element of .
Step 2: mixed inputs. Write each as a convex combination of pure stabilizer states. Expanding the tensor product, is a convex combination of tensor products of pure stabilizer states, which are pure stabilizer states by Step 1. So the input is with , and pure stabilizer states.
Step 3: induction over the protocol, with post-selection. Each step of the protocol is one of the elementary operations, possibly chosen according to earlier outcomes. Suppose that after some steps, conditioned on the outcome record , the state is with pure stabilizer states or elements of . Apply the next operation, which is determined by . A Clifford unitary or an ancilla preparation maps each into by Step 1 and linearity. Discarding qubits is linear and maps each term into . For a Pauli measurement with outcome , let ; the conditioned state is
summing over the terms with . The weights are non-negative and sum to one, and each normalised term is in by Step 1 (applied to the pure components of in the same way). So is in . Random choices of operations average conditioned states, which keeps them in the convex set . By induction the state conditioned on the full outcome record is in ; the unconditioned output, and the output conditioned on any set of accepting records, are convex combinations of these and so lie in too.
Corollary. is linear, so on the convex set it is at most its maximum over that set, which bounds the fidelity of every output with .
Derivation. Write a single-qubit state as . The six Pauli eigenstates have Bloch vectors , so is the octahedron , the stabilizer octahedron used by Bravyi and Kitaev. The T state has Bloch vector , and . A linear function on a polytope is maximised at a vertex; over the six vertices the largest value of is , attained at and . Hence the maximum fidelity is .
The twirled noisy state has Bloch vector . It lies in the octahedron exactly when , that is ; for the vector points the other way and the same bound applies with replaced by . By the closure theorem, inputs with cannot be distilled by any stabilizer protocol.
Comparison. The 15-to-1 protocol improves inputs only below its fixed point (output-error record), slightly below . The bound above is necessary for distillability, not sufficient: it does not say that every input with can be distilled by some protocol.
- Single qubit; is the convex hull of the six eigenstates of , and .
- The noisy T state is the twirled form of definition/t-state.
Error suppression of 15-to-1
Here is the probability that the output of 15-to-1 distillation carries a error, conditioned on acceptance. The probability of acceptance is
The map has a non-trivial fixed point at : inputs with a smaller error rate are improved, and iterating the protocol drives the error to zero. The expression and the fixed point are those of Bravyi and Kitaev. The coefficient 35 is the number of weight-3 codewords of the Hamming code.
When the stabilizer operations are themselves noisy, as in a logical-level implementation at finite code distance, their errors add to and set a floor that this formula does not contain.
- Noiseless stabilizer operations.
- Fifteen independent input T states, each with a error of probability and no other error.
- The output is kept only when all four -type checks of the fifteen-qubit code are satisfied.
Proof · Derivation of the 15-to-1 output error
Notation as in 15-to-1 distillation: is the matrix whose columns are the non-zero vectors of , and is the Hamming code.
Reduction to a classical question. After step 2 the block is in the state , where marks the inputs that carried a error; errors commute with the injected gates. The bits of are independent with .
- Detection. commutes with the stabilizer exactly when . All four checks are satisfied if and only if , that is .
- Effect of an undetected pattern. The -type stabilizers are the with of even weight. If has even weight, is a stabilizer and the state is unchanged. If has odd weight, then has even weight and lies in , because the all-ones vector is in (every row of has weight 8); hence acts as the logical .
Therefore, with the number of codewords of weight in ,
Leading order. has distance 3, so . A weight-3 codeword is a set of three distinct columns of that sum to zero. Choosing two distinct columns determines the third, , which is non-zero and differs from both; each set is counted times among the ordered pairs, so . Since ,
Exact expression. The dual of is the row space of , the simplex code, with weight enumerator . The MacWilliams identity gives
Put , so that and . Then
The odd-weight part of the sum is , so
As a check, expanding the numerator in about : its value and its first two derivatives vanish there and its third derivative is , so the numerator is , and dividing by the denominator gives .
Overhead of iterated distillation
is the number of noisy input magic states consumed per output state of error rate at most , for a fixed input error rate below threshold. The parametrisation by is due to Bravyi and Haah.
Derivation. After rounds the error obeys . With this reads , so . Each round consumes inputs per output, so rounds consume . The target is met once , and since , the smallest such gives
Values.
| Protocol | Code parameters | |
|---|---|---|
| 15-to-1 (Bravyi and Kitaev) | ||
| 10-to-2 (Meier, Eastin and Knill) | 10 inputs, 2 outputs, | |
| Triorthogonal family (Bravyi and Haah) | ||
| Multilevel (Jones) | concatenated, inputs for error | |
| Punctured Reed–Muller (Hastings and Haah) | block length about for | |
| Qudit codes (Krishna and Tillich) | qudits of growing dimension | |
| Algebraic-geometry codes (Wills, Hsieh and Yamasaki) | qubits, via -dimensional qudits |
A value means a constant number of inputs per output, independent of . The exponent describes asymptotic input counts only; it says nothing about the size of the blocks needed or the cost of the Clifford operations.
- Noiseless stabilizer operations and independent inputs of error rate .
- One round maps inputs of error to outputs of error at most , and the input error is below the protocol's threshold, .
- Outputs of one round are fed to the next in such a way that the inputs of each block remain independent; rejection probabilities are neglected, which is valid at leading order.
Worked Examples
Two rounds of 15-to-1 from
Take inputs with error rate and assume ideal Clifford operations.
Round 1. The leading-order output error is . The acceptance probability from the exact expression is . Since , this is , so an accepted output costs on average inputs.
Round 2. Fifteen round-1 outputs give , accepted with probability . One output costs about raw inputs.
Reading the result. A computation with T gates that should fail with probability below 1% needs output error about . One round () is not enough and two rounds overshoot by ten orders of magnitude. This mismatch is why practical factories mix protocols and code distances rather than iterate one protocol, and why the two-level factory of Litinski described below targets .
The distillation boundary for the T state
A dephased T state with error rate has Bloch vector . At the coordinates sum to , so the state is inside the stabilizer octahedron and cannot be distilled by any protocol. At the sum is : the state is magic, and it is just below the 15-to-1 fixed point , so 15-to-1 improves it, slowly. Between and the state is magic but 15-to-1 makes it worse.
Algorithms and Implementations
The 15-to-1 protocol
The code. Let be the binary matrix whose columns are the 15 non-zero vectors of . The punctured Reed–Muller code has -type stabilizers for in the row space of (four generators of weight 8), -type stabilizers for every even-weight with (ten generators), and logical operators , . Every basis string in has weight 0 or 8 and every basis string in has weight 7 or 15, so acts as the logical .
Input. Fifteen noisy T states of error rate .
Procedure.
- Prepare the encoded state with stabilizer operations.
- Apply to each of the 15 qubits by state injection, consuming one input state per qubit. With ideal inputs the block is now in ; an input with a error leaves a error on its qubit.
- Measure the four -type stabilizer generators. If any outcome is , discard the block and start again.
- Decode the block onto a single qubit with a Clifford circuit and apply , which maps to .
Output. One T state with error rate , produced with probability ; see the output-error record for the exact expressions and their derivation.
Why it works. Only errors occur. A pattern of errors passes the checks exactly when it is a codeword of the Hamming code, and it harms the output exactly when that codeword has odd weight. The lightest such patterns have weight 3, and there are 35 of them.
Equivalent form. Bravyi and Kitaev describe the protocol as measuring the stabilizers of the code directly on the fifteen input states and decoding. The encode-then-inject form above is the one used by Bravyi and Haah for general codes with a transversal and gives the same output error.
Cost. Fifteen inputs per attempt and, for small , close to fifteen per output. Repeating the protocol on its own outputs for rounds cubes the error each time and uses inputs per output; the resulting scaling is the distillation overhead exponent with .
- Stabilizer operations (Clifford gates, Pauli preparations and measurements) are noiseless.
- The fifteen input states are independent, each a T state with a error of probability (the twirled form).
Other codes
The 15-to-1 protocol is one member of a broader recipe: any code with a transversal gate from the third level of the Clifford hierarchy, combined with post-selection on its stabilizers, distils the corresponding magic state, and the output error is of order where is the code's distance against the relevant errors. Bravyi and Haah introduced triorthogonal codes, a family of codes with transversal that output states per block with quadratic error suppression, lowering the overhead exponent towards . Meier, Eastin and Knill give a ten-input, two-output protocol based on a four-qubit code. Jones concatenates such codes so that the exponent approaches 1, and Haah, Hastings, Poulin and Wecker give a family with constant space overhead and an input count that scales linearly in , up to factors, without concatenation. The distillation idea also applies directly to multi-qubit resource states: protocols that output CCZ states can replace four T states per Toffoli gate (Jones; Gidney and Fowler).
Factories at the logical level
In a real machine every qubit of a distillation circuit is itself a logical qubit, for example a surface-code patch, and the Clifford operations are carried out by lattice surgery. The relevant cost is then the space-time volume of the factory per output state. Two observations reduced that cost substantially:
- Not every qubit needs full distance. The output state only has to be as good as the algorithm requires, and errors that the distillation checks themselves detect only need to be suppressed weakly. Litinski encodes the qubits of a 15-to-1 circuit at different, mostly small, distances. Under circuit-level noise with physical error rate , his factory outputs states with error using 4,620 physical qubits and 42.6 code cycles per state, and a two-level design reaches with 46,800 qubits and 157 cycles. He concludes that distillation is not the dominant cost of a surface-code computer.
- Distil the gate you need. Gidney and Fowler lay out a CCZ factory with a footprint of that emits one CCZ state every code cycles, where is the code distance.
O'Gorman and Campbell give an earlier detailed account of factory footprints under realistic noise. The number of factories a computation needs is set by matching their output rate to the rate at which the algorithm consumes magic states; see resource estimation.
Limitations and Common Pitfalls
- assumes perfect Clifford operations. At the logical level, faults in the distillation circuit add terms that are not cubic in ; the logical error rate of the factory's own qubits sets a floor. The circuit-level factory numbers quoted on this page include these effects; the formula does not.
- The input error is not the physical error rate. It is the error of the injected logical state, which depends on the injection circuit. With careful post-selection an injected state can be better than the gates that made it (Li).
- Overhead exponents are asymptotic. A small says nothing about block size or about the cost of the Clifford circuit; protocols with record exponents use very large blocks.
- Only -type errors are handled by the twirl. The single-parameter error model relies on twirling the input; without it, the analysis must track other error components.
- Counting T gates is not counting cost. Throughput, latency and the code distance of the consuming computation all enter; a factory that is cheap in volume but slow can stall the algorithm.
State of the Art
As of 2026-11:
- Cultivation. Gidney, Shutty and Jones (preprint, 2024) grow a single T state inside a surface-code patch, checking it repeatedly while enlarging the code, at a cost in physical gates comparable to a lattice-surgery CNOT of the same reliability. Their simulations reach logical error rates about under uniform depolarizing circuit noise of , and about at , with an order of magnitude fewer qubit-rounds than earlier approaches; they suggest that further distillation may often be unnecessary. Vaknin and co-authors (preprint, 2025) study cultivation carried out within the surface code itself.
- Physical-level distillation. Itogawa and co-authors (published 2025) distil before encoding into the surface code, using a Steane-code circuit on a square lattice of physical qubits, and report a logical magic-state error of about in numerical simulations.
- Experiments. Rodriguez and co-authors (published 2025) ran distillation on logical qubits encoded in distance-3 and distance-5 colour codes on a reconfigurable neutral-atom processor and observed output logical magic states with higher fidelity than the inputs.
- Constant overhead. The best exponent for qubit protocols was (Hastings and Haah), and Krishna and Tillich reached for qudits of growing dimension. Wills, Hsieh and Yamasaki (published 2025) obtain for qubits, using asymptotically good algebraic-geometry codes on -dimensional qudits, each represented by ten qubits. Independent 2024 preprints construct asymptotically good qubit codes with a transversal CCZ gate, which also give distillation with exponent tending to zero (Golowich and Guruswami) or with constant space overhead (Nguyen). These results concern asymptotic input counts; their practical constants have not been established.