Z X SpiderCSS
Interactive Research Companion & Fault-Tolerant Circuit Compiler

SpiderCSS: Scalable Fault-Tolerant CSS State Preparation

Boldizsár Poór1 Andrey Boris Khesin1 Sarah Meng Li2,3 Benjamin Rodatz1 John van de Wetering2,3 Richie Yeung1
1University of Oxford 2University of Amsterdam 3QuSoft

Abstract

Fault-tolerant preparation of logical states is a critical primitive for the realization of large-scale fault-tolerant quantum computing. SpiderCSS introduces a scalable compilation pipeline that generates highly optimized, fault-tolerant state preparation circuits for arbitrary Calderbank–Shor–Steane (CSS) codes. Starting from an idealized bipartite ZX-diagram specification of a CSS state, we apply fault-equivalent rewrites and precomputed well-ordered Cat states to construct a diagram that is CNOT-minimal both within each component and across their interconnections—provably preserving fault tolerance by construction without expensive verification.

Avg. LER Reduction
−33.7%
Up to −90% vs. Flag at Origin
CNOT Reduction
Up to 53.8%
Matches or beats FaO on all codes
Preloaded QECCs
43
Distances d = 2 to 15 (n ≤ 144)
Well-Ordered Cats
593
Bundled for instant client-side synthesis
Interactive 5-Phase Compiler Studio

From CSS Stabilizers to Fault-Tolerant Quantum Circuits

Choose how you want to interact with SpiderCSS: explore the step-by-step theoretical walkthrough or synthesize circuits directly with the full compiler.

CSS Code & Target Logical State Specification

Select from 43 benchmarked CSS codes or define custom HX,HZH_X, H_Z parity-check matrices / Pauli strings, target basis, and distance dd.

[[7, 1, 3]]Steane Code
rank(HX)=3•rank(HZ)=3•t=1
Perfect QECC (X-spiders at t−1 = 0)
FT Level:t = 1
Quick Presets:
Click any cell to toggle 0/1
HXH_XX-Stabilizer Parity Matrix(3 × 7)
genq0q1q2q3q4q5q6wt
SX,04
SX,14
SX,24
HZH_ZZ-Stabilizer Parity Matrix(3 × 7)
genq0q1q2q3q4q5q6wt
SZ,04
SZ,14
SZ,24

Bipartite ZX-Diagram & Column-Permuted RREF Basis Optimization

Different stabilizer generator bases yield different bipartite ZX-diagrams. Column-permuted Gaussian elimination over F2\mathbb{F}_2 embeds an identity submatrix IrI_r into the pivot columns (guaranteeing the unique-ones property) while minimizing Eq. (8) CNOT cost.

Step-by-Step RREF Procedure (Single Trial Inspector):

Eq. (8) Fault-Tolerant CNOT & Flag Cost Model

t = ⌊d / 2⌋ = 1
Ctotal(M′,t)=∑i: wi>12 f(wi+1,t)⏟Col Flag CNOTs  +  ∑j=1r(wj−1)⏟Row Fan-Out CNOTs  +  ∑j=1r2 f(wj,t)⏟Row Flag CNOTsC_{\text{total}}(M', t) = \underbrace{\sum_{i:\, w_i > 1} 2\,f(w_i + 1, t)}_{\text{Col Flag CNOTs}} \;+\; \underbrace{\sum_{j=1}^{r} (w_j - 1)}_{\text{Row Fan-Out CNOTs}} \;+\; \underbrace{\sum_{j=1}^{r} 2\,f(w_j, t)}_{\text{Row Flag CNOTs}}
Row Fan-Out
9
Σ(w_j − 1)
Row Flag CX
6
Σ 2f(w_j, t)
Col Flag CX
2
Σ 2f(w_i+1, t)
Eq. (8) CNOTs
17
Init: 17 CX
Eq. (8) Flags
4
Init: 4 flags
Perfect QECC (is_perfect): Col (X) spiders unfuse at t−1=0t-1=0 instead of t=1t=1Actual Circuit: 15 CNOTs, 3 Flags
Stage 4/4Un-Permuted RREF Basis M' = RREF(M[:, π])[:, π⁻¹]
Pivot Rows (3/3)Non-Pivot Cols (4)Active: H_X
Column Permutation π\pi:[]
Click any two π entries to swap columns
Row
q0
q1
q2
q3
q4
q5
q6
wjw_jf(wj,t)f(w_j,t)
Z0(q0)
10011104+1
Z1(q1)
01011014+1
Z2(q2)
00110114+1
Col wiw_i1113222——
f(wi+1,t)f(w_i{+}1,t)···+1000Flags: 4
Unique-1 Pivot (Z-Spider)Pivot Row (Green |0̄⟩)Non-Pivot Column (Red |+̄⟩ comp.)Non-Pivot 1 (Idealized Bipartite Edge)

Bipartite ZX-State Diagram (RREF Form)

3 row spiders (ZjZ_j) • 4 non-pivot spiders (XiX_i) • all 7 output legs on the right • 9 idealized internal edges

Z-spiderX-spiderIdealized Edge
Output State Legs (q_0..q_6)q_0q_1q_2q_3q_4q_5q_6Z0deg=4Z1deg=4Z2deg=4X0deg=4X1deg=3X2deg=3X3deg=3
Hover over any spider to highlight its incident edges.State outputs: 7 right-hand boundary legs
Post-Phase 2 Exploration Branch

How would you like to proceed from the idealized bipartite ZX-diagram?

Explore the theoretical fault-equivalent ZX-calculus rewrites (Section III.A) or jump directly into the Algorithm 1 compiler pipeline (Section IV).

Global Port Matching (G_global, D_global) Without Backtracking

Each external bipartite edge (a,b)(a, b) is matched to the earliest unassigned 3-ary ports u(a)∈V(a)u(a) \in V(a) and u(b)∈V(b)u(b) \in V(b), adding CNOT edge (u(a),u(b))(u(a), u(b)) to GglobalG_{\text{global}} and causal dependencies PDglobal(u(a))→u(b)P_{D_{\text{global}}}(u(a)) \to u(b), PDglobal(u(b))→u(a)P_{D_{\text{global}}}(u(b)) \to u(a) to DglobalD_{\text{global}}.

Step 0 / 9 (Initial State)Disjoint Union of Well-Ordered Cat States (Before Adding External CNOT Edges)

Heuristic selected: SA Sequence Distance (Simulated annealing minimizing cat-state sequence span). Click Next >, Play, or click any dashed edge in Panel 1 to step through Algorithm 1.

Perfect QECC: X-spiders unfused at t−1
Panel 1 • Edge Schedule

Target Bipartite ZX-State

0 / 9 edges
Added (0)Active (a, b)Remaining (9)
Panel 2 • Global Structure Network
32 spiders • 7 rootsDepth: 4 (5 generations)

Spiders copy the horizontal topological positions from the Global Digraph, updating with each added edge. All ports exit to the right boundary as output qubits q_0..q_6 (quantum state preparation). Bold edges form spanning forest F from roots r_k (blue boxes).

Z_0 (q_0)Z_1 (q_1)Z_2 (q_2)X_0 (q_3)X_1 (q_4)X_2 (q_5)X_3 (q_6)Gen 0Gen 1Gen 2Gen 3Gen 4Output Qubitsq_0q_1q_2q_3q_4q_5q_6r_001234r_156789r_21011121314r_31516171819r_420212223r_524252627r_628293031
Spanning Forest FNon-Tree ClosureRoot r_kAdded CNOTActive (u(a), u(b))Output Qubit Wires

Topological Grid Alignment & Post-Extraction Qubit Reuse

Because D_global is guaranteed acyclic and every port satisfies Lemma III.7 or Lemma III.8, CatStateExtractor extracts a CNOT circuit in linear time, followed by interval-coloring qubit reuse.

9 Qubits (−1 via reuse)•15 CX•Depth 8
Interactive 3-Stage Circuit Extraction Morph (Figure 7 of Paper)

Step through (b)→(c)→(d)\text{(b)} \to \text{(c)} \to \text{(d)} to see how (Gglobal,F,Dglobal)(G_{\text{global}}, F, D_{\text{global}}) is aligned onto qubit wires and translated into CNOT gates.

(d) Extracted Quantum Circuit: Every vertical (Z-spider, X-spider) pair becomes a CNOT gate (control • on the Z-spider wire, target ⊕ on the X-spider wire), degree-1 starts become |0⟩ (red) / |+⟩ (green) resets, and flag ends become meters.
7 data wires + 3 flag wires
q_0 (r_0)q_0q_1 (r_1)q_1q_2 (r_2)q_2q_3 (r_3)q_3q_4 (r_4)q_4q_5 (r_5)q_5q_6 (r_6)q_6flag_0flag_1flag_2|+⟩|+⟩|+⟩|0⟩|0⟩|0⟩|0⟩|0⟩|0⟩|0⟩ZZZ
|0⟩|0⟩ Reset (X-basis)|+⟩|+⟩ Reset (Z-basis)—+CX GateXX Measurement (green)ZZ / Flag Measurement (red)
Post-Extraction Qubit Reuse Mode

Select Qubit Reuse Strategy (Switch Dynamically Above Circuit)

Ancilla merges: 1 flag wires recycled
Simultaneous Qubits
9(7d + 2a)
Data Qubits (n)
7
Flag Measurements
3
CNOT Count
15
CNOT Depth
8
Total Circuit Depth
12

Compiled Quantum Circuit Diagram (9 Physical Qubits, 15 CNOTs, Depth 8)

Data wires q_0..q_6 persist to the output boundary; flag wires q_7..q_8 are measured and recycled when Qubit Reuse is enabled.

Wire / Qubitdata[0]×2data[1]data[2]data[3]data[4]data[5]data[6]anc[0]anc[1]
q_0q_1q_2q_3q_4q_5q_6|+⟩|0⟩|0⟩|0⟩|0⟩Z|+⟩|0⟩|+⟩|0⟩|0⟩ZZ
31 lines
RX 2
R 3
R 5
R 6
R 0
CX 2 0
CX 0 3
CX 2 5
CX 0 6
CX 2 0
M 0
RX 0
R 7
CX 0 7
CX 7 5
RX 1
R 8
CX 1 8
CX 1 6
R 4
CX 8 4
CX 8 3
CX 0 4
CX 7 3
CX 0 7
CX 1 8
M 8
M 7
DETECTOR rec[-2]
DETECTOR rec[-3]
DETECTOR rec[-1]

[[7, 1, 3]] Steane Code — ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle Simulation Results

Circuit-level depolarizing noise (p = 0.001, 1.0e+8 Stim shots per heuristic) comparing SpiderCSS against Flag at Origin (FaO) with 95% Wilson confidence intervals.

All 18 Codes ↓
Logical Error Rate (LER)
[2.3, 2.5] × 10^-5
FaO: [2.1, 2.2] × 10^-5(+10.0%)
Acceptance Rate (AR)
98.70%
FaO: 98.70%(-0.0%)
CNOTs / Flag Ancillas
15 CX • 3 Flags
FaO: 15 CX • 3 Flags
Min Circuit Depth (Depth-Opt)
Depth 5 (10 Q)
FaO: Depth 8 (10 Q)(−37.5% D)
Min Sim. Qubits (Qubits-Opt)
8 Qubits (D=12)
FaO: 8 Qubits (D=15)(−0.0% Q)

Evaluated Heuristics vs. Flag at Origin for [[7, 1, 3]]

Method / HeuristicCNOTsFlagsSim. Qubits Opt (Q / D)Depth Opt (Q / D)Logical Error Rate (95% CI)Acceptance Rate (95% CI)Action
Flag at Origin (FaO)
1538 / 1510 / 8
[2.1, 2.2] × 10^-5
[0.9870, 0.9871]
SpiderCSS (Earliest Start)Best LER
1538 / 1210 / 5
[2.3, 2.5] × 10^-5
[0.9870, 0.9871]
SpiderCSS (Seq. Dist. / Joint)
1538 / 1210 / 5
[2.3, 2.5] × 10^-5
[0.9870, 0.9871]
SpiderCSS (Crit. Path)
1538 / 1210 / 5
[2.4, 2.6] × 10^-5
[0.9870, 0.9871]
SpiderCSS (Active Spider)
1538 / 1210 / 5
[2.4, 2.6] × 10^-5
[0.9870, 0.9871]
SpiderCSS (Seq. Dist. SA)Active in Phase 3
1538 / 1210 / 5
[2.5, 2.7] × 10^-5
[0.9870, 0.9871]
Section V • Global Benchmark Explorer (arXiv:2610.03714)

SpiderCSS vs. Flag at Origin Across 18 Benchmarked CSS Codes

Interactive reproduction of Figure 1, Figure 8, and Table I from the paper across 95 Stim Monte Carlo simulation runs (distances d = 3 to 15, up to n = 144 physical qubits).

Mean LER Reduction
−33.7%
Mean AR Increase
+9.5%
Depth Reduction
−60.3%
Sim. Qubits Saved
−20.2%
Click any point to inspect code & heuristics
Figure 1(a) • Noise Performance

Logical Error Rate vs. Acceptance Rate Improvement (%)

Avg LER: +33.7%
Avg AR: +9.5%
Outperforms FaO on both LER & AR-100%-50%0%50%100%-10%0%10%20%30%40%50%[[7, 1, 3]][[9, 1, 3]][[25, 1, 5]][[49, 1, 5]][[20, 2, 6]][[49, 1, 7]][[95, 1, 7]][[47, 1, 11]]Improvement to Logical Error Rate (%) →Improvement to Acceptance Rate (%) →
Benchmarked CSS Code★Mean (+33.7% LER, +9.5% AR)+FaO Baseline (0%, 0%)
Figure 1(b) • Spacetime Footprint

Circuit Depth vs. Simultaneous Qubits Improvement (%)

Shallower Depth & Fewer Sim. Qubits-25%0%25%50%75%100%-20%-10%0%10%20%30%40%50%[[7, 1, 3]][[25, 1, 5]][[49, 1, 5]][[49, 1, 7]][[95, 1, 7]][[81, 1, 9]][[47, 1, 11]]Improvement to Circuit Depth (%) →Improvement to Sim. Qubits (%) →
▲Depth Opt. (Avg +60.3% D, +20.2% Q)■Footprint Opt. (Avg +13.1% D, +8.9% Q)

Table I: Resource Overhead, Logical Error Rate & Acceptance Rate Comparison

Bold entries indicate the best result for each CSS state. Click any column header to sort, or click Load in Studio ↑ to inspect that code in Phases 1–5.

QEC Code & State ↑MethodCNOT Count Flag Count Qubit Reuse TargetSim. Qubits Depth LER (95% Wilson CI) AR (95% Wilson CI) Studio
[[7, 1, 3]]
Steane ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin153sim. qubits815[2.1, 2.2] × 10^-5[0.9870, 0.9871]
depth108
SpiderCSS (Earliest Start)153sim. qubits812[2.3, 2.5] × 10^-5[0.9870, 0.9871]
depth105
[[9, 1, 3]]
rot. surface ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin269sim. qubits1120[17.7, 19.5] × 10^-6[0.9622, 0.9623]
depth186
SpiderCSS (Crit. Path)122sim. qubits95[9.3, 10.5] × 10^-6[0.9913, 0.9913]
depth114
[[17, 1, 5]]
color code ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin7421sim. qubits2247[4.9, 8.2] × 10^-7[0.9009, 0.9010]
depth3817
SpiderCSS (Seq. Dist. (Joint))7421sim. qubits2247[4.7, 8.0] × 10^-7[0.9107, 0.9108]
depth3613
[[25, 1, 5]]
rot. surface ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin9228sim. qubits3364[5.0, 8.5] × 10^-7[0.8735, 0.8736]
depth5320
SpiderCSS (Crit. Path)7821sim. qubits2938[3.3, 6.1] × 10^-7[0.9101, 0.9102]
depth468
[[49, 1, 5]]
triorthogonal ∣0+‾⟩|\mkern2mu\overline{\vphantom{0}+}\mkern2mu\rangle
Flag at Origin361105sim. qubits89195[10.0, 10.5] × 10^-5[0.4968, 0.4970]
depth15456
SpiderCSS (Earliest Start)361105sim. qubits80232[7.8, 8.3] × 10^-5[0.5281, 0.5283]
depth12829
[[20, 2, 6]]
self-dual ∣+0‾⟩⊗2|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle^{\otimes 2}
Flag at Origin14547sim. qubits40101[3.8, 11.3] × 10^-8[0.7895, 0.7896]
depth6751
SpiderCSS (Seq. Dist. (Joint))14547sim. qubits3991[0.5, 4.4] × 10^-8[0.8089, 0.8089]
depth6016
[[23, 1, 7]]
Golay ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin23780sim. qubits53142[3.5, 5.6] × 10^-7[0.6441, 0.6442]
depth10329
SpiderCSS (Active Spider)23780sim. qubits54143[1.9, 3.4] × 10^-7[0.6771, 0.6772]
depth8322
[[31, 1, 7]]
color code ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin21169sim. qubits53129[14.0, 27.3] × 10^-8[0.6954, 0.6956]
depth10055
SpiderCSS (Earliest Start)21169sim. qubits45136[5.5, 14.5] × 10^-8[0.7189, 0.7190]
depth8419
[[49, 1, 7]]
rot. surface ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin26285sim. qubits79174[11.4, 24.5] × 10^-8[0.6215, 0.6216]
depth13443
SpiderCSS (Earliest Start)22669sim. qubits65129[4.7, 13.2] × 10^-8[0.7121, 0.7122]
depth10118
[[95, 1, 7]]
triorthogonal ∣0+‾⟩|\mkern2mu\overline{\vphantom{0}+}\mkern2mu\rangle
Flag at Origin1175380sim. qubits243804[1.6, 2.0] × 10^-4[0.0259, 0.0260]
depth475386
SpiderCSS (Seq. Dist. (Joint))1173379sim. qubits184752[3.0, 3.4] × 10^-4[0.0372, 0.0373]
depth33244
[[49, 1, 9]]
color code ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin408136sim. qubits89256[3.1, 13.1] × 10^-8[0.4413, 0.4414]
depth185120
SpiderCSS (Seq. Dist. (SA))402133sim. qubits81265[0.5, 6.2] × 10^-8[0.4678, 0.4679]
depth14424
[[81, 1, 9]]
rot. surface ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin614206sim. qubits135375—[0.2454, 0.2459]
depth287126
SpiderCSS (Active Spider)486155sim. qubits116308—[0.3816, 0.3822]
depth19825
[[47, 1, 11]]
self-dual ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin1033388sim. qubits163659[27.7, 46.0] × 10^-7[0.0672, 0.0672]
depth435289
SpiderCSS (Crit. Path)971355sim. qubits185635[1.6, 6.9] × 10^-7[0.0838, 0.0839]
depth30338
[[71, 1, 11]]
color code ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
Flag at Origin829268sim. qubits163546—[0.1344, 0.1348]
depth339279
SpiderCSS (Active Spider)727251sim. qubits135475—[0.2060, 0.2065]
depth25828
[[144, 12, 12]]
gross ∣+0‾⟩⊗12|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle^{\otimes 12}
SpiderCSS (Active Spider)50181824sim. qubits8002993—[0.0504, 0.0512]*
depth119197
[[82, 2, 13]]
2bga ∣+0‾⟩⊗2|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle^{\otimes 2}
SpiderCSS (Active Spider)2586970sim. qubits4881587—[0.3453, 0.3472]*
depth64076
[[92, 2, 14]]
2bga ∣+0‾⟩⊗2|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle^{\otimes 2}
SpiderCSS (Active Spider)36471409sim. qubits6472164—[0.1346, 0.1359]*
depth85796
[[79, 1, 15]]
self-dual ∣+0‾⟩|\mkern2mu\overline{\vphantom{+}0}\mkern2mu\rangle
SpiderCSS (Active Spider)32571270sim. qubits5762032—[0.2005, 0.2020]*
depth70998

* Note: Logical error rates marked — were not estimated as the code-capacity syndrome lookup table exceeded memory. For the 4 largest codes (d ≥ 12), values marked with * indicate simulations performed at physical error rate p = 0.0001 instead of p = 0.001.