Magic State Distillation
Magic state distillation trades several imperfect nonstabilizer ancillas for fewer, cleaner ones using Clifford operations, Pauli measurements and postselection. The accepted states can then implement non-Clifford gates on data. The central tradeoff is between output quality, acceptance probability and the work needed to obtain each accepted output.
We will derive a -gate injection, explain the noise assumptions behind a scalar distillation map, and work through the 15-to-1 protocol. Its familiar law is a small-error result for independent inputs and ideal Clifford processing. Correlations, faulty checks and finite output supply require additional analysis.
Required background. Stabilizer Formalism supplies Pauli checks and logical operators; Fault-Tolerant Gates explains protected gadgets; Universal Gate Sets explains why adding to Clifford operations gives universality.
The resource state for a T gate
Section titled “The resource state for a T gate”Use the convention
and define
Its Bloch vector is , outside the octahedron of single-qubit stabilizer mixtures. Clifford operations and Pauli measurements alone cannot create it from stabilizer inputs. It is consequently a resource relative to that restricted set of operations; Resource Theories explains this general idea.
Names vary across the literature. The state called here is Clifford-equivalent to a Hadamard eigenstate. Bravyi and Kitaev (2005) call this family H-type; their T-type states point along a different Bloch-sphere direction. Stating the vector prevents confusion between their five-qubit protocol and the 15-to-1 protocol considered below.
Magic-state consumption is useful when logical Clifford operations are easier to protect than the desired non-Clifford gate. A code with a transversal gate can have a different expensive operation. Distillation is therefore an architectural option, not a universal requirement for every fault-tolerant design.
Injection with one ancilla and feedforward
Section titled “Injection with one ancilla and feedforward”Prepare data and an ancilla . Apply CNOT with data as control and ancilla as target, then measure the ancilla in the computational basis. The unnormalized data outputs are
Both outcomes have probability . For outcome one, apply , since . The corrected output is always , up to a branch phase.
The state has supplied the non-Clifford part; the remaining circuit uses Clifford operations and a Pauli measurement. Fault-tolerant injection still requires protected CNOT, readout and classical decisions. A correction can sometimes be tracked in a Clifford frame, but later operations must be adapted to that frame. A bad ancilla can inject an error directly into the data.
A noise model that can be distilled
Section titled “A noise model that can be distilled”Let . These states are orthogonal eigenvectors of the Hermitian Clifford operator
The eigenvalues are and , respectively. Applying or with equal probability and discarding the random choice dephases a qubit in this basis:
The resulting state is
where . This twirl preserves the target-state fidelity while removing coherence between the two basis states. In the injection circuit above, this diagonal resource produces the ideal gate followed by a stochastic error of probability .
Independent twirling of many inputs makes their joint state diagonal in the product basis, but it does not make their classical error variables independent. A shared preparation fault survives as a correlation. Leakage outside the qubit space and faults during the twirl are also outside this ideal two-state model.
For , the Bloch vector of is . It becomes a stabilizer mixture when
This boundary is a property of the state family and free operations. It need not equal the threshold of a particular distillation protocol. Having a nonstabilizer state does not imply that every chosen protocol improves it.
Acceptance and conditional output quality
Section titled “Acceptance and conditional output quality”A protocol’s accepted branch is a completely positive, trace-nonincreasing map . For a joint input , define
The first quantity is the acceptance probability. The second is the state conditioned on acceptance, provided . Normalization makes this conditional transformation nonlinear as a function of the input; the unnormalized accepted map remains linear.
For identical independent diagonal inputs , a one-output protocol may reduce to functions and . Improvement means , not merely that an accepted state was produced. With independent retries, the expected input-state consumption per accepted output is . This does not count protected gates, storage or routing.
Bravyi and Kitaev (2005) establish distillation using noisy ancillas and ideal stabilizer operations. In a hardware implementation, the stabilizer operations are themselves encoded and imperfect. It is useful to solve the ideal map first, then identify which additional errors enter the actual accepted ensemble.
Why fifteen inputs give cubic suppression
Section titled “Why fifteen inputs give cubic suppression”The 15-to-1 construction uses the phase structure of the punctured quantum Reed–Muller code. After the ideal Clifford processing is accounted for, the diagonal input errors can be represented by fifteen binary variables . A one denotes a error on that resource.
Let be the binary matrix whose columns are the fifteen distinct nonzero four-bit vectors, ordered by the integers . The run accepts when
For an accepted pattern, the output error bit is the total parity
These rules describe the input-error propagation in the ideal distillation circuit; simply measuring four ordinary checks directly on fifteen unprocessed magic states is not the same protocol. Encoding, the phase-gate pattern and Clifford corrections establish this classical description. Bravyi and Haah (2012) explain its relation to triorthogonal constructions.
Every single error produces a nonzero column syndrome. Every pair produces the XOR of two distinct columns, also nonzero. Hence all weight-one and weight-two input errors are rejected.
For a triple, the syndrome vanishes precisely when its columns obey . Any two distinct nonzero columns determine the third, and each triple is counted three times by its pairs. There are therefore
accepted triples. All have odd parity and hence cause an output error. For independent errors of small probability , each such pattern has probability . Their leading contribution is ; acceptance tends to one as .
The exact map
Section titled “The exact map”Write . Every nonzero binary combination of the four rows of has weight eight. Averaging the corresponding parity signs gives
To separate accepted even and odd patterns, define their signed difference
Then their total is and their difference is , so the conditional odd probability is
This also gives the commonly written rational expression
Near zero, and . Subtracting nearly equal numbers in is numerically unstable at extremely small . One can instead sum the nonnegative probabilities of accepted odd-weight patterns, or use higher-precision arithmetic.
The useful nonzero fixed point is . Below it, the ideal map improves these inputs; immediately above it, it worsens them. This is a 15-to-1 protocol threshold, assuming independent diagonal inputs and perfect Clifford processing. It is smaller than and is unrelated to a physical surface-code threshold.
Top: improvement occurs where the exact output curve lies below the identity line. The crossing is near . The cubic approximation is useful near zero but misses the crossing quantitatively. Bottom: acceptance decreases as the inputs become noisier, so the raw-state cost rises even before improvement stops. Both panels assume the ideal independent-input model.
| Input error | Acceptance | Output error |
|---|---|---|
| 0.001 | 0.9851 | |
| 0.01 | 0.8601 | |
| 0.10 | 0.2198 | 0.0477 |
At , one accepted output consumes about raw states on average. At , it consumes about . A clean conditional output and a high yield are separate desirable properties.
Correlations and imperfect checks
Section titled “Correlations and imperfect checks”The cubic law depends on probabilities of complete patterns. Consider a batch with no error with probability , and with probability choose uniformly one of the 35 accepted triples. Every batch accepts. Every faulty batch produces a logical output error, so .
Each input belongs to seven of the triples. All fifteen marginals are therefore identical, with . An independent-input model with those same marginals would predict about , while the actual output error is . Even equal input fidelities and ideal twirling do not establish independent inputs.
Faulty Clifford checks introduce another issue: their error contribution must be evaluated conditioned on acceptance. If a harmful circuit event has unconditional probability at most , then
Thus an unconditional circuit-error estimate cannot simply be added to the ideal conditional output error without accounting for the acceptance event. A rare fault that both damages the output and forces acceptance is particularly important. Exercise 5 gives an exact example.
For a stage model , the term must be a justified bound in the accepted ensemble, with any acceptance changes included. Once that term dominates, adding another ideal distillation stage without improving its protected implementation will not achieve the ideal recurrence’s tiny output error.
The same conditioning matters for catalysts and multiple outputs. A persistent catalyst fault can correlate outputs from many rounds. O’Gorman and Campbell (2017) analyze correlated outputs in factory estimates; Gidney and Fowler (2019) discuss a catalyzed conversion from CCZ resources to two states. Returning a catalyst does not mean its errors are reset.
Recursive purification and other resource choices
Section titled “Recursive purification and other resource choices”If each new level receives genuinely independent outputs from separate lower-level attempts, the ideal recurrence is . At , two ideal 15-to-1 levels give approximately
The second number describes the ideal map, not a predicted hardware error. Even a small conditional circuit contribution can dominate it.
For independent retries and one output per block, expected raw consumption obeys
Two such levels at this input error consume about raw states per accepted output. The number exceeds because rejected attempts also consume inputs. Finite buffers, shared drift and batch-dependent acceptance can require a more detailed model.
Several alternatives change this tradeoff. Meier, Eastin, and Knill (2013) use ten inputs to produce two improved Hadamard-type states. These are Clifford-equivalent to our resource, but their protocol has different checks, suppression and yield. Bravyi–Haah blocks can produce several outputs, with correlations that must be retained when those outputs feed another stage.
In the latter construction, a binary matrix is triorthogonal when each pair and each triple of distinct rows have even overlap. Odd-weight rows identify logical operators; even-weight rows supply stabilizers. The overlap conditions arrange a transversal phase operation, with possible Clifford corrections, to act appropriately on the encoded information. They do not by themselves give an output-error rate: the undetected patterns and their probabilities still have to be counted.
A workload dominated by Toffoli gates may benefit from a direct CCZ resource instead of compiling every operation into separate injections. Code switching and pieceable gates offer other routes, as explained in Fault-Tolerant Gates. Current experimental milestones and newer preparation proposals are discussed in Fault-Tolerant Quantum Computing Frontier; the ideal maps here establish neither sustained hardware throughput nor an experimental error floor.
Supplying resources when the algorithm needs them
Section titled “Supplying resources when the algorithm needs them”A factory repeatedly prepares and checks resources, then stores and delivers accepted outputs. If independent units each attempt a -output batch every , with acceptance probability , the nominal mean supply is
Mean supply exceeding mean demand does not guarantee that every requested resource arrives on time. Rejections are random, batches can be correlated, routes can be occupied, and stored states continue to accumulate errors. A finite buffer converts a sequence of random supply events into a probability of stalling. Exercise 6 shows this even for independent batches.
For stochastic resource-failure events , the union bound
does not require independence. Correlations do affect whether the individual bounds are valid for the delivered resources and how sharp their sum is. A coherent resource error may require a channel-distance analysis instead of a classical event interpretation. The relevant resource quality includes delivery and injection, not only the state immediately after a successful check.
The compiled number of gates estimates total consumption; their scheduled parallelism and adaptive dependencies determine when the states are needed. Resource Estimation combines those demands with factory duration, footprint and storage. Lattice Surgery explains one way to connect encoded resource states to the data through protected parity measurements.
Exercises
Section titled “Exercises”1. Inject a noisy resource
Section titled “1. Inject a noisy resource”For the data-control injection circuit, derive the two ideal branches. Then replace the resource by and apply the same outcome-dependent correction. What channel results for input resource ?
Solution
For the ideal resource, outcome zero gives and outcome one gives . Multiplying the second by produces the desired gate. For the orthogonal resource, the corrected outputs are and . The branch phase is irrelevant. Thus
Both outcomes still have probability , so the measurement record does not identify the resource error.
2. Apply the Clifford twirl
Section titled “2. Apply the Clifford twirl”Verify that is Clifford and show its action on a general density matrix in the basis.
Solution
The operator is Hermitian, satisfies , and conjugates to , to , and to . In its eigenbasis,
Conjugation by changes the sign of both off-diagonal entries. Averaging removes them and leaves the populations unchanged. Separate twirls remove coherences from a joint input state but preserve its diagonal correlations.
3. Count accepted triples
Section titled “3. Count accepted triples”Using the fifteen nonzero four-bit columns, count the accepted weight-three patterns. How often does a particular column appear among them?
Solution
For distinct nonzero columns , the third column is nonzero and different from both. Every unordered pair belongs to one triple, and each triple contains three pairs. Thus there are triples. For a fixed column , each of the other fourteen columns pairs with it, but the two other columns describe the same triple twice. Hence appears in seven triples. These counts yield both the independent coefficient 35 and the correlated marginal .
4. Derive the exact acceptance probability
Section titled “4. Derive the exact acceptance probability”Use the binary Fourier identity
and independent error bits to calculate acceptance. Then include the sign to obtain .
Solution
For any binary vector , independence gives . The term contributes one; the other fifteen vectors each have weight eight. Therefore . Multiplying by total parity replaces by its complement: the corresponding weights become fifteen and seven. Hence . Accepted odd patterns have total probability , giving .
5. Condition a harmful circuit event correctly
Section titled “5. Condition a harmful circuit event correctly”A toy ideal checker accepts with probability and has no accepted output errors. With probability , a separate circuit fault instead forces acceptance and a wrong output. Find the actual acceptance and conditional output error.
Solution
The no-fault branch has weight , so
The conditional error is almost five times the unconditional fault probability. Simply adding to the ideal conditional error would be incorrect. The acceptance rule selected the faulty events more strongly than the ordinary events.
6. Find a shortfall despite adequate mean supply
Section titled “6. Find a shortfall despite adequate mean supply”Four independent units each produce two states with probability every 120 cycles. Demand is six states in each such interval, with no initial buffer. Find mean supply and the probability of insufficient supply in one interval.
Solution
The mean is states, exceeding demand. But if is the accepted-batch count, supply fails when :
Thus one interval has a 5.23% shortfall probability despite adequate mean rate. A buffer, spare capacity or rescheduling can help; none is represented by the mean alone.
7. Construct equal marginals without cubic suppression
Section titled “7. Construct equal marginals without cubic suppression”Use the uniform accepted-triple model with . Calculate each input error rate, acceptance and output error. Compare with independent inputs having the same marginals.
Solution
Each input has error . The correlated distribution contains only no-error and accepted odd-triple patterns, so acceptance is one and output error is . Independent inputs with instead have acceptance about and conditional output error . Local fidelity measurements cannot distinguish these radically different joint inputs.
8. Compute the cost of two ideal levels
Section titled “8. Compute the cost of two ideal levels”Starting from , use the exact map and independent retries to estimate two-level raw-state consumption. Explain why the very small ideal is not a hardware prediction.
Solution
The first stage has and . The second acceptance is about , so
A stable probability sum gives . That number neglects all faults in encoded checks, storage, transport and injection, as well as correlations between lower-stage outputs. These contributions must be controlled in the accepted ensemble before such a total error could be inferred.
References
Section titled “References”- S. Bravyi and J. Haah, “Magic-state distillation with low overhead,” Physical Review A 86, 052329 (2012), doi:10.1103/PhysRevA.86.052329, arXiv:1209.2426.
- S. Bravyi and A. Kitaev, “Universal quantum computation with ideal Clifford gates and noisy ancillas,” Physical Review A 71, 022316 (2005), doi:10.1103/PhysRevA.71.022316, arXiv:quant-ph/0403025.
- C. Gidney and A. G. Fowler, “Efficient magic state factories with a catalyzed CCZ to 2T transformation,” Quantum 3, 135 (2019), doi:10.22331/q-2019-04-30-135, arXiv:1812.01238.
- A. M. Meier, B. Eastin, and E. Knill, “Magic-state distillation with the four-qubit code,” Quantum Information and Computation 13, 195–209 (2013), arXiv:1204.4221.
- J. O’Gorman and E. T. Campbell, “Quantum computation with realistic magic-state factories,” Physical Review A 95, 032338 (2017), doi:10.1103/PhysRevA.95.032338, arXiv:1605.07197.