Yifei Wang · Yingfei Gu · Tsinghua University
18 November 2026 · Freie Universität Berlin
github.com/itpyi/magna · arXiv:2610.22315
Many codes implement Clifford gates transversally or by lattice surgery.
Gottesman–Knill: Clifford circuits on stabilizer states are classically efficient.
Add . Eastin–Knill: no code has a transversal universal gate set.
The non-Clifford gate needs another route: consume a magic state.
Gottesman, arXiv:quant-ph/9807006 · Eastin, Knill, arXiv:0811.4262
Gottesman, Chuang, arXiv:quant-ph/9908010 · Bravyi, Kitaev, arXiv:quant-ph/0403025
How often an attempt passes postselection.
Infidelity of the accepted output with the ideal target state.
A bent wire is a Bell pair. Apply at one end and project onto : the gate slides around the bend as its transpose (the same gate, since it is diagonal), and the other end carries the magic state .
The same thing as a circuit. A CNOT prepares the Bell pair; the projection becomes an measurement with a known correction on R — teleportation again.
Encode the measured half in the code. on every qubit acts as a logical , so R again receives . The readout gives 4 parity checks: accept only if all pass.
Every is a gate-teleportation gadget. It consumes one noisy magic state, so a faulty input acts as a error on its line.
One faulty input is caught. Its error flips one outcome, and two of the parity checks fire: the run is rejected.
Two faulty inputs are caught too. At least one check always fires for one or two errors.
Three can pass. These three errors fire no check but flip the output. There are 35 such triples, so the output error is about .
Bravyi, Kitaev, arXiv:quant-ph/0403025
Bravyi, Haah, arXiv:1209.2426
Triorthogonal codes: one run produces magic states.
Fowler et al., arXiv:1208.0928 · Litinski, arXiv:1808.02892
Each input is a surface-code patch. A decoder reads its syndromes and decides the correction before the next input: 15 decoder decisions in a row.
A decoder's decision is a nonlinear function of the outcomes. Keep it for later.
The 15-qubit 3D color code (the same ) has a transversal : apply to every qubit of .
Measure the 8 qubits off one face in . The face is the 7-qubit 2D color code, where all Clifford gates are transversal.
A correction set by the outcomes fixes the face's checks: feedforward again. This is one of three ways to switch codes.
Anderson, Duclos-Cianci, Poulin, arXiv:1403.2734 · Bombín, arXiv:1412.5079
Daguerre, Kim, arXiv:2410.07327
Wang, Gu, arXiv:2503.19758
Inject a state into a color code.
Double check the logical Clifford transversally: a layer of , the check and its time reverse through a cat state, a layer of . Postselect on every detector.
Grow to , stabilize with three syndrome cycles, and double check again. The physical count grows with distance: 15 at , 53 at .
Escape quickly into a large surface code; fine-grained postselection decides which attempts to keep.
Gidney, Shutty, Jones, arXiv:2409.17595
Gidney, Shutty, Jones, arXiv:2409.17595
The original: transversal check on the color code.
15 / 53Chen et al., arXiv:2503.18657
Surface code on the projective plane.
31 / 101Sahay et al., arXiv:2509.05212
Fold-transversal Clifford check on the surface code.
Chan et al., arXiv:2609.17706
Diagnoses and repairs a degraded fault distance; three- and four-round models.
Hetényi, Brown, Williamson, arXiv:2603.05429
Measures the logical Clifford by gauging, in constant depth.
129 atCommon skeleton: a logical Clifford check built from physical non-Clifford gates, repeated with postselection. One magic state out.
Chan et al., arXiv:2609.17706
Diagnoses and repairs a degraded fault distance; three- and four-round models.
Gidney, Shutty, Jones, arXiv:2409.17595 · Chan et al., arXiv:2609.17706
and two questions it raises for simulation
| Protocol | Hidden structure | Physical | Logical output |
|---|---|---|---|
| 15-to-1 distillation | transversal on | 15 | one |
| Bravyi–Haah | triorthogonal code | copies of | |
| Code switching | transversal on the 3D color code | 15 | one |
| Cultivation (color, RP², gauged, …) | layers implementing a transversal Clifford check | 15–129 | one |
The physical count grows with the distance. The logical magic is fixed by the output.
SOFT, Clifft, SymFT, PPVM, MPS
Track the state through time. Cost follows the intermediate states.
RP² : amplitudes at peak
Li et al., arXiv:2512.23037 · Chase, Labib, arXiv:2604.27058 · Fang, Lou, Li, arXiv:2607.28600 · Luo et al., arXiv:2610.18225 · Hartweg, Piñeiro Orioli, arXiv:2609.19116
ZX / Tsim, stabilizer-rank estimators
Simplify the whole circuit first. The output state still costs its stabilizer rank.
: stabilizer rank believed exponential in
Kissinger, van de Wetering, arXiv:2109.01076 · Haenel, Luo, Zhao, arXiv:2604.01059 · Pashayan et al., arXiv:2101.12223 · Bravyi, Smith, Smolin, arXiv:1506.01396
,
Cheap, but shown to be unreliable for cultivation.
miss the degraded fault distance
Li et al., arXiv:2512.23037 · Wan, Zapirain, arXiv:2609.18922 · Chan et al., arXiv:2609.17706
Can a deterministic algorithm find this structure — with no human insight and no protocol-specific input — in polynomial time?
How do we use it to simulate the noisy, adaptive factory, at a cost set by the logical magic — or even less — rather than the physical count?
the genuine non-Clifford degrees of freedom
Start from the gadget form. Every is teleported: an ancilla , a CNOT, a measurement and an correction. The logical outcome sets the correction on R. Shown: 3 of the 15 code qubits.
Make all feedforward coherent. Each becomes C from its ancilla, measured at the end. becomes CNOTs from R onto the qubits of , before the readout. The checks become projections.
Push the gadget CNOT into the initial Clifford. Passing only changes its axis, , by : a on the parity . Cliffords that arrive multiply into one Clifford.
Combine the diagonal gates: . A on the code qubit, and one on the ancilla, which is only measured in .
Push the CNOTs from R in as well. Passing turns it into on the parity ; it commutes with everything else on the way.
One commuting layer. What is left is diagonal: rotations about products of 's, which all commute.
Only now, abstract the ends. Everything before the layer is one stabilizer state; the readout and the checks become stabilizer projections.
Related: Pashayan et al., arXiv:2101.12223
Insert a complete basis at the diagonal layer: the boundaries keep only an affine space — it plays the role of the code labels .
Related: Cui, Gottesman, Krishna, arXiv:1608.06596
Goal: find , the directions along which is Clifford. The boundaries absorb ; only is expanded.
Tool: finite differences. Flip bit : ; in general flips a direction . All values mod 8.
| Gate | first difference | second | third | Level | |
|---|---|---|---|---|---|
| Pauli | |||||
| Clifford | |||||
| non-Clifford | |||||
| C | Clifford | ||||
| C | non-Clifford | ||||
| CC | non-Clifford |
Third differences define a trilinear form, , zero exactly for Clifford phases. — Gaussian elimination over , deterministic and polynomial.
The network becomes stabilizer terms: rank , known at compile time. : Bravyi, Smith, Smolin, arXiv:1506.01396
Related: Cui, Gottesman, Krishna, arXiv:1608.06596 · Heyfron, Campbell, arXiv:1712.01557
Q1 found the genuine non-Clifford coordinates of the ideal circuit — for cultivation, 53 or 101 physical gates become one coordinate.
We sample faulty circuits, but the analysis was for the ideal one. Does every fault force a new analysis?
Even the logical magic can be large: Bravyi–Haah with outputs , whose stabilizer rank is believed exponential in . Do we need the output state at all?
Bravyi, Smith, Smolin, arXiv:1506.01396
faults keep the code · two numbers, not a state · nonlinear feedforward
A fault, in the coherent 15-to-1 circuit: on code qubit 1 after the encoder. Shown: that qubit, its gadget ancilla and R. Push the fault to the readout, gate by gate.
Through a Clifford, the Pauli changes: the CNOT maps to , .
Through a rotation, only a sign changes. C is three rotations, about , and ; anticommutes with the first two, so their signs flip. In phases: gains , a Clifford term.
At the readout: the CNOT from R leaves unchanged and commutes with ; flips the ancilla's record — the sign of a boundary stabilizer.
Run the protocol with a fault draw . Its ending legs: output , postselection , and irrelevant (records no longer needed, discarded qubits).
puts the protocol next to its conjugate .
The trace joins the irrelevant legs of the two copies.
becomes projectors on the postselection legs.
Acceptance network : the output legs are traced too. Contracting it gives .
Fidelity network : the output legs meet a small noiseless target circuit . No intermediate state and no output state is ever built.
Figure: Wang, Gu, arXiv:2610.22315, Fig. 1
How can a decision change the circuit without changing what we compiled?
How can we sample round with its physical probability before the later decisions exist?
The sampling network, every outcome leg open (triangles): and its conjugate as staircases, one step per round. Output and postselection are traced. Nothing is drawn and no decision is known yet.
Trace every round after round 1. Everything after round 1 is then trace preserving — postselection included, because it is traced too — so the later decisions, still unknown, drop out.
Draw from .
Only now can the decoder act: enters as a Pauli insertion. Return to the open network, with fixed — a trace can be taken from open legs, never undone.
Trace every round after round 2. The future is trace preserving again, and it needs only .
Draw from .
Insert , reopen, repeat: uses only decisions already made. Proposals come from the affine support with weight ; in our examples every weight is 1.

Six surface-code patches, 102 qubits, 15 decoder-controlled stages and a decoder postselection.
Exact formula reproduced within 1 SE, down to .
All three networks . 1.27 ms per draw, half of it in the decoder.
Protocol: Litinski, arXiv:1808.02892 · Haah, Hastings, arXiv:1709.02832
resources, speed, and cultivation with actual gates
| Example | Qubits | Non-Clifford | Output | fid / acc / samp | Prepare (ms) | Sample (ms / draw) |
|---|---|---|---|---|---|---|
| Bravyi–Haah 14-to-2 | 30 | 14 | 1 / 1 / – | 3.66 | 0.0069 | |
| Bravyi–Haah 68-to-20 | 156 | 68 | 1 / 1 / – | 27.8 | 0.014 | |
| Bravyi–Haah 308-to-100 | 716 | 308 | 1 / 1 / – | 201 | 0.0503 | |
| Color cultivation | 42 | 53 | color | 1 / 1 / – | 11.2 | 0.0104 |
| RP² cultivation | 61 | 101 | RP² | 1 / 1 / – | 12.4 | 0.00877 |
| 3D → 2D color code | 38 | 15 | 2D color | 1 / 1 / 1 | 4.37 | 0.0148 (0.0144) |
| 3D color → 2D surface code | 70 | 15 | surface | 1 / 1 / – | 10.7 | 0.00711 |
| Logical-level distillation | 102 | 15 | surface | 1 / 1 / 1 | 319 | 1.27 (0.64) |
| TQD , 8 rounds | 151 | 1250 CC | toric | 4 / 2 / 1 | 4550 | 16.5 (12.6) |
Paper Table I; Mac Studio (Apple M1 Ultra), one CPU thread. In parentheses: sampling time without the decoder.
Bravyi, Haah, arXiv:1209.2426 · Gidney, Shutty, Jones, arXiv:2409.17595 · Wan, Zapirain, arXiv:2609.18922 · Chen et al., arXiv:2503.18657 · Daguerre, Kim, arXiv:2410.07327 · Wang, Gu, arXiv:2503.19758 · Litinski, arXiv:1808.02892 · Davydova et al., arXiv:2503.15751 · Magdalena de la Fuente et al., arXiv:2604.02033
| Cultivation | gates | magna | peak amplitudes | magna | SymFT | Clifft | PPVM |
|---|---|---|---|---|---|---|---|
| Color | 15 | 1 | 16 | 0.0059 | 0.0020 | 0.00031 | 0.017 |
| RP² | 31 | 1 | 256 | 0.0064 | 0.0066 | 0.0046 | 0.088 |
| Color | 53 | 1 | 1 024 | 0.0104 | 0.044 | 0.027 | 0.53 |
| RP² | 101 | 1 | 262 144 | 0.0088 | 7.46 | 8.14 | 193 |
Sampling time in ms per draw at , one thread, Mac Studio, excluding preparation. Peak amplitudes coincide for SymFT, Clifft and PPVM. Per draw, not per equal precision: each magna draw already averages over all measurement outcomes.
Comparators — SymFT: Fang, Lou, Li, arXiv:2607.28600 · Clifft: Chase, Labib, arXiv:2604.27058 · PPVM: Luo et al., arXiv:2610.18225
Circuits and exact series: Wan, Zapirain, arXiv:2609.18922 · Gidney, Shutty, Jones, arXiv:2409.17595 · Chen et al., arXiv:2503.18657
Circuits and exact series: Sahay et al., arXiv:2509.05212 · Chan et al., arXiv:2609.17706 · Wan, Zapirain, arXiv:2609.18922
Circuits: Hetényi, Brown, Williamson, arXiv:2603.05429 · Wan, Zapirain, arXiv:2609.18922
Fault configurations per hard point, under an hour each.
Fault configurations evaluated per second on the hard curves.
Status: these runs use a GPU sampler that is in development and not yet in public magna. The released version (v0.2.0) samples on the CPU; the paper's timings are single-thread CPU.
is certified per circuit at compile time — small in every benchmark here, not guaranteed for every factory. Rare events still need importance sampling. Coherent (non-Pauli) errors are not supported yet.
Inspired by the algebraic structure of codes: the radical of the phase trilinear form recovers the hidden code — deterministic, polynomial time.
Acceptance and fidelity, not the output state — closing the network avoids paying for the output's magic.
github.com/itpyi/magna · arXiv:2610.22315
We thank Hong-Ye Hu, Kwok Ho Wan, Ainhoa Zapirain, Zikang Zhang and Tian-Gang Zhou for useful discussions.