Tsim: Faster near-Clifford simulation with active statevectors and a new ZX engine
We are releasing Tsim 1.0.0, our first major version release. Building on key advances by Clifft and SymFT,[1,2] we have added a new active statevector backend, which replaces stabilizer-rank decomposition as the default for sampling. Together with a rewrite of the ZX engine in Rust, this allows Tsim to scale to much larger near-Clifford circuits and significantly reduces compilation times.
For example, Tsim samples the 463-qubit end-to-end magic-state cultivation circuit of Gidney et al.[3] five times faster than Stim[4] samples its Clifford version, in which every T gate is replaced by an S gate, a much easier problem.
Cultivation d=5, end-to-end463 qubits · 53 T gates · 2,744 detectors, 107 postselected (injection and cultivation)
Run details
- Machine
- One AMD Ryzen 9 9900X (12 cores, 24 threads, 64 GB) running Linux; every measurement runs in a fresh process, pinned to a single core with
taskset, with a budget of 1 thread. - Stim
- Stim cannot simulate T gates, so it samples the Clifford version of each circuit: T made S, T† made S†, with its frame simulator. Its line is dashed: it shows what a Clifford simulator costs on a circuit of the same size, not a simulation of the measured circuit. Stim cannot postselect either, so like SymFT where it cannot, its lane shows its rate without postselection when postselection is on.
- Sampling
- Attempted shots per second, median of 3 timed repetitions of at least 5 s each, after compilation and one untimed warm-up call. Shots rejected by postselection count as attempted, so a rate with postselection on is a cost per attempt, not per accepted shot. The rate covers the simulator's own call, which returns its shot data; Tsim and Stim return bit-packed detector rows, Clifft and SymFT survivor counts. Tsim samples with trajectory sharing on; Clifft with the batch size it calibrates during the warmup call (
batch_size="tune"). - Compilation
- Wall time from circuit text to a sampler ready to sample, median over 3 fresh processes, with imports done before the clock starts, shown with postselection off. Stim's includes the T-to-S text substitution. Clifft runs its default optimization passes plus its opt-in
ActiveWidthSchedulePass. - Postselection
- With postselection on, every detector is postselected, except on Cultivation d=5, end-to-end, where only the injection and cultivation detectors are (the convention of Gidney et al.). SymFT can only postselect on all detectors, so it does not support this setting; there its lane shows its rate without postselection. Compare draws each lane from postselection off (open mark) to on (filled mark); Stim, and SymFT where it cannot postselect, keep a single mark at their rate without postselection.
- K
- The largest number of qubits held in a dense statevector at once, as each simulator reports it. Sampling cost grows as 2K.
- Versions
- Tsim 1.0.0: bloqade-tsim 0.1.5 @ git 5af2731, numpy 2.4.4, numba 0.65.0, stim 1.15.0 · Clifft 0.12.0: clifft 0.12.0, numpy 2.5.4 · SymFT 0.1.1: symft 0.1.1, numpy 2.5.4 · Stim 1.16.0 (T→S, Clifford only): stim 1.16.0, numpy 2.4.4, numba 0.65.0
- Circuits
- Gidney et al. cultivation circuits, as used by the Clifft paper; SymFT benchmark suite.
From ZX diagrams to small statevectors
Tsim represents circuits as ZX diagrams, where Pauli noise appears as parameterized vertices. It then simplifies the diagram using the rules of the ZX calculus. This often significantly reduces the number of non-Clifford gates. Importantly, the ZX diagram often splits into two parts: a small connected component that represents the logical circuit (which requires far fewer qubits than the physical circuit) and a large number of individual detector components that represent the stabilizer measurements. The reduction is performed once and reused across shots, as described in the original Tsim paper.[5]
Previously, the remaining quantum component was decomposed into a sum of Clifford diagrams using stabilizer-rank decomposition.[6] In practice, this produces exponentially many terms as the non-Clifford gate count increases, making both compilation and sampling expensive. With the active statevector backend, Tsim instead applies key insights from Clifft and SymFT.[1,2] The small ZX diagram is converted back into a quantum circuit that represents a Pauli-based computation (PBC): all of its instructions are either Pauli-product measurements or Pauli-product rotations, where the signs of the rotation angles depend on the noise configuration of each shot.
1 / 8Stim circuit
The input is the Steane-encoded 5-to-1 magic-state distillation from the benchmarks above: five noisy magic states, each encoded in a 7-qubit code, distilled with transversal gates and measured.
- 35 qubits
- 10 non-Clifford gates
- 15 detectors
- 5 observables
R 6 13 20 27 34 R_X(-0.3040867239846964) 6 13 20 27 34 T_DAG 6 13 20 27 34 DEPOLARIZE1(0.05) 6 13 20 27 34 R 0 7 14 21 28 1 8 15 22 29 2 9 16 23 30 3 10 17 24 31 4 11 18 25 32 5 12 19 26 33 TICK SQRT_Y_DAG 0 7 14 21 28 1 8 15 22 29 2 9 16 23 30 3 10 17 24 31 4 11 18 25 32 5 12 19 26 33 TICK CZ 1 2 8 9 15 16 22 23 29 30 3 4 10 11 17 18 24 25 31 32 5 6 12 13 19 20 26 27 33 34 TICK SQRT_Y 6 13 20 27 34 TICK CZ 0 3 7 10 14 17 21 24 28 31 2 5 9 12 16 19 23 26 30 33 4 6 11 13 18 20 25 27 32 34 TICK SQRT_Y 2 9 16 23 30 3 10 17 24 31 4 11 18 25 32 5 12 19 26 33 6 13 20 27 34 TICK CZ 0 1 7 8 14 15 21 22 28 29 2 3 9 10 16 17 23 24 30 31 4 5 11 12 18 19 25 26 32 33 TICK SQRT_Y 1 8 15 22 29 2 9 16 23 30 4 11 18 25 32 TICK X 3 10 17 24 31 Z 5 12 19 26 33 1 8 15 22 29 TICK SQRT_X 0 1 2 3 4 5 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 28 29 30 31 32 33 34 CZ 0 7 1 8 2 9 3 10 4 11 5 12 6 13 14 21 15 22 16 23 17 24 18 25 19 26 20 27 DEPOLARIZE2(0.01) 0 7 1 8 2 9 3 10 4 11 5 12 6 13 14 21 15 22 16 23 17 24 18 25 19 26 20 27 SQRT_Y 0 1 2 3 4 5 6 21 22 23 24 25 26 27 DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 21 22 23 24 25 26 27 CZ 0 14 1 15 2 16 3 17 4 18 5 19 6 20 21 28 22 29 23 30 24 31 25 32 26 33 27 34 DEPOLARIZE2(0.01) 0 14 1 15 2 16 3 17 4 18 5 19 6 20 21 28 22 29 23 30 24 31 25 32 26 33 27 34 TICK SQRT_X_DAG 0 1 2 3 4 5 6 DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 CZ 0 28 1 29 2 30 3 31 4 32 5 33 6 34 DEPOLARIZE2(0.01) 0 28 1 29 2 30 3 31 4 32 5 33 6 34 TICK CZ 7 21 8 22 9 23 10 24 11 25 12 26 13 27 DEPOLARIZE2(0.01) 7 21 8 22 9 23 10 24 11 25 12 26 13 27 TICK SQRT_X_DAG 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 M 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 DETECTOR rec[-35] rec[-34] rec[-33] rec[-32] DETECTOR rec[-34] rec[-33] rec[-31] rec[-30] DETECTOR rec[-33] rec[-32] rec[-31] rec[-29] DETECTOR rec[-28] rec[-27] rec[-26] rec[-25] DETECTOR rec[-27] rec[-26] rec[-24] rec[-23] DETECTOR rec[-26] rec[-25] rec[-24] rec[-22] DETECTOR rec[-21] rec[-20] rec[-19] rec[-18] DETECTOR rec[-20] rec[-19] rec[-17] rec[-16] DETECTOR rec[-19] rec[-18] rec[-17] rec[-15] DETECTOR rec[-14] rec[-13] rec[-12] rec[-11] DETECTOR rec[-13] rec[-12] rec[-10] rec[-9] DETECTOR rec[-12] rec[-11] rec[-10] rec[-8] DETECTOR rec[-7] rec[-6] rec[-5] rec[-4] DETECTOR rec[-6] rec[-5] rec[-3] rec[-2] DETECTOR rec[-5] rec[-4] rec[-3] rec[-1] OBSERVABLE_INCLUDE(0) rec[-35] rec[-34] rec[-30] OBSERVABLE_INCLUDE(1) rec[-28] rec[-27] rec[-23] OBSERVABLE_INCLUDE(2) rec[-21] rec[-20] rec[-16] OBSERVABLE_INCLUDE(3) rec[-14] rec[-13] rec[-9] OBSERVABLE_INCLUDE(4) rec[-7] rec[-6] rec[-2]
Tsim turns the circuit into one ZX diagram. Each noise channel becomes spiders whose phases carry error bits e0 … e331, so a single diagram stands for every noise realization at once.
- 828 spiders
- 935 wires
- 332 error bits
ZX rewrites remove the Clifford structure. The error bits are then rewritten in a basis of independent noise bits f0 … f20: error patterns with the same effect on the outputs share a bit.
How the noise bits are made of error bits
- f0e10 ⊕ e12 ⊕ e14 ⊕ e16 ⊕ e25 ⊕ e27 ⊕ e29 ⊕ e31 ⊕ e39 ⊕ e41 ⊕ e43 ⊕ e45 ⊕ e52 ⊕ e56 ⊕ e60 ⊕ e64 ⊕ e109 ⊕ e111 ⊕ e113 ⊕ e115 ⊕ e137 ⊕ e141 ⊕ e145 ⊕ e149 ⊕ e167 ⊕ e171 ⊕ e175 ⊕ e179 ⊕ e192 ⊕ e193 ⊕ e194 ⊕ e195 ⊕ e196 ⊕ e197 ⊕ e198 ⊕ e199 ⊕ e206 ⊕ e207 ⊕ e210 ⊕ e211 ⊕ e214 ⊕ e215 ⊕ e218 ⊕ e219 ⊕ e263 ⊕ e265 ⊕ e267 ⊕ e269
- f1e12 ⊕ e14 ⊕ e18 ⊕ e20 ⊕ e27 ⊕ e29 ⊕ e33 ⊕ e35 ⊕ e41 ⊕ e43 ⊕ e47 ⊕ e49 ⊕ e56 ⊕ e60 ⊕ e68 ⊕ e72 ⊕ e111 ⊕ e113 ⊕ e117 ⊕ e119 ⊕ e141 ⊕ e145 ⊕ e153 ⊕ e157 ⊕ e171 ⊕ e175 ⊕ e183 ⊕ e187 ⊕ e194 ⊕ e195 ⊕ e196 ⊕ e197 ⊕ e200 ⊕ e201 ⊕ e202 ⊕ e203 ⊕ e210 ⊕ e211 ⊕ e214 ⊕ e215 ⊕ e222 ⊕ e223 ⊕ e226 ⊕ e227 ⊕ e265 ⊕ e267 ⊕ e271 ⊕ e273
- f2e14 ⊕ e16 ⊕ e18 ⊕ e22 ⊕ e29 ⊕ e31 ⊕ e33 ⊕ e37 ⊕ e43 ⊕ e45 ⊕ e47 ⊕ e51 ⊕ e60 ⊕ e64 ⊕ e68 ⊕ e76 ⊕ e113 ⊕ e115 ⊕ e117 ⊕ e121 ⊕ e145 ⊕ e149 ⊕ e153 ⊕ e161 ⊕ e175 ⊕ e179 ⊕ e183 ⊕ e191 ⊕ e196 ⊕ e197 ⊕ e198 ⊕ e199 ⊕ e200 ⊕ e201 ⊕ e204 ⊕ e205 ⊕ e214 ⊕ e215 ⊕ e218 ⊕ e219 ⊕ e222 ⊕ e223 ⊕ e230 ⊕ e231 ⊕ e267 ⊕ e269 ⊕ e271 ⊕ e275
- f3e11 ⊕ e13 ⊕ e15 ⊕ e17 ⊕ e24 ⊕ e25 ⊕ e26 ⊕ e27 ⊕ e28 ⊕ e29 ⊕ e30 ⊕ e31 ⊕ e54 ⊕ e55 ⊕ e58 ⊕ e59 ⊕ e62 ⊕ e63 ⊕ e66 ⊕ e67 ⊕ e82 ⊕ e86 ⊕ e90 ⊕ e94 ⊕ e123 ⊕ e125 ⊕ e127 ⊕ e129 ⊕ e165 ⊕ e169 ⊕ e173 ⊕ e177 ⊕ e234 ⊕ e235 ⊕ e238 ⊕ e239 ⊕ e242 ⊕ e243 ⊕ e246 ⊕ e247 ⊕ e277 ⊕ e279 ⊕ e281 ⊕ e283
- f4e13 ⊕ e15 ⊕ e19 ⊕ e21 ⊕ e26 ⊕ e27 ⊕ e28 ⊕ e29 ⊕ e32 ⊕ e33 ⊕ e34 ⊕ e35 ⊕ e58 ⊕ e59 ⊕ e62 ⊕ e63 ⊕ e70 ⊕ e71 ⊕ e74 ⊕ e75 ⊕ e86 ⊕ e90 ⊕ e98 ⊕ e102 ⊕ e125 ⊕ e127 ⊕ e131 ⊕ e133 ⊕ e169 ⊕ e173 ⊕ e181 ⊕ e185 ⊕ e238 ⊕ e239 ⊕ e242 ⊕ e243 ⊕ e250 ⊕ e251 ⊕ e254 ⊕ e255 ⊕ e279 ⊕ e281 ⊕ e285 ⊕ e287
- f5e15 ⊕ e17 ⊕ e19 ⊕ e23 ⊕ e28 ⊕ e29 ⊕ e30 ⊕ e31 ⊕ e32 ⊕ e33 ⊕ e36 ⊕ e37 ⊕ e62 ⊕ e63 ⊕ e66 ⊕ e67 ⊕ e70 ⊕ e71 ⊕ e78 ⊕ e79 ⊕ e90 ⊕ e94 ⊕ e98 ⊕ e106 ⊕ e127 ⊕ e129 ⊕ e131 ⊕ e135 ⊕ e173 ⊕ e177 ⊕ e181 ⊕ e189 ⊕ e242 ⊕ e243 ⊕ e246 ⊕ e247 ⊕ e250 ⊕ e251 ⊕ e258 ⊕ e259 ⊕ e281 ⊕ e283 ⊕ e285 ⊕ e289
- f6e10 ⊕ e12 ⊕ e14 ⊕ e16 ⊕ e25 ⊕ e27 ⊕ e29 ⊕ e31 ⊕ e52 ⊕ e56 ⊕ e60 ⊕ e64 ⊕ e80 ⊕ e81 ⊕ e84 ⊕ e85 ⊕ e88 ⊕ e89 ⊕ e92 ⊕ e93 ⊕ e109 ⊕ e111 ⊕ e113 ⊕ e115 ⊕ e138 ⊕ e139 ⊕ e142 ⊕ e143 ⊕ e146 ⊕ e147 ⊕ e150 ⊕ e151 ⊕ e291 ⊕ e293 ⊕ e295 ⊕ e297
- f7e12 ⊕ e14 ⊕ e18 ⊕ e20 ⊕ e27 ⊕ e29 ⊕ e33 ⊕ e35 ⊕ e56 ⊕ e60 ⊕ e68 ⊕ e72 ⊕ e84 ⊕ e85 ⊕ e88 ⊕ e89 ⊕ e96 ⊕ e97 ⊕ e100 ⊕ e101 ⊕ e111 ⊕ e113 ⊕ e117 ⊕ e119 ⊕ e142 ⊕ e143 ⊕ e146 ⊕ e147 ⊕ e154 ⊕ e155 ⊕ e158 ⊕ e159 ⊕ e293 ⊕ e295 ⊕ e299 ⊕ e301
- f8e14 ⊕ e16 ⊕ e18 ⊕ e22 ⊕ e29 ⊕ e31 ⊕ e33 ⊕ e37 ⊕ e60 ⊕ e64 ⊕ e68 ⊕ e76 ⊕ e88 ⊕ e89 ⊕ e92 ⊕ e93 ⊕ e96 ⊕ e97 ⊕ e104 ⊕ e105 ⊕ e113 ⊕ e115 ⊕ e117 ⊕ e121 ⊕ e146 ⊕ e147 ⊕ e150 ⊕ e151 ⊕ e154 ⊕ e155 ⊕ e162 ⊕ e163 ⊕ e295 ⊕ e297 ⊕ e299 ⊕ e303
- f9e25 ⊕ e27 ⊕ e29 ⊕ e31 ⊕ e39 ⊕ e41 ⊕ e43 ⊕ e45 ⊕ e55 ⊕ e59 ⊕ e63 ⊕ e67 ⊕ e82 ⊕ e83 ⊕ e86 ⊕ e87 ⊕ e90 ⊕ e91 ⊕ e94 ⊕ e95 ⊕ e122 ⊕ e123 ⊕ e124 ⊕ e125 ⊕ e126 ⊕ e127 ⊕ e128 ⊕ e129 ⊕ e164 ⊕ e165 ⊕ e168 ⊕ e169 ⊕ e172 ⊕ e173 ⊕ e176 ⊕ e177 ⊕ e236 ⊕ e237 ⊕ e240 ⊕ e241 ⊕ e244 ⊕ e245 ⊕ e248 ⊕ e249 ⊕ e305 ⊕ e307 ⊕ e309 ⊕ e311
- f10e27 ⊕ e29 ⊕ e33 ⊕ e35 ⊕ e41 ⊕ e43 ⊕ e47 ⊕ e49 ⊕ e59 ⊕ e63 ⊕ e71 ⊕ e75 ⊕ e86 ⊕ e87 ⊕ e90 ⊕ e91 ⊕ e98 ⊕ e99 ⊕ e102 ⊕ e103 ⊕ e124 ⊕ e125 ⊕ e126 ⊕ e127 ⊕ e130 ⊕ e131 ⊕ e132 ⊕ e133 ⊕ e168 ⊕ e169 ⊕ e172 ⊕ e173 ⊕ e180 ⊕ e181 ⊕ e184 ⊕ e185 ⊕ e240 ⊕ e241 ⊕ e244 ⊕ e245 ⊕ e252 ⊕ e253 ⊕ e256 ⊕ e257 ⊕ e307 ⊕ e309 ⊕ e313 ⊕ e315
- f11e29 ⊕ e31 ⊕ e33 ⊕ e37 ⊕ e43 ⊕ e45 ⊕ e47 ⊕ e51 ⊕ e63 ⊕ e67 ⊕ e71 ⊕ e79 ⊕ e90 ⊕ e91 ⊕ e94 ⊕ e95 ⊕ e98 ⊕ e99 ⊕ e106 ⊕ e107 ⊕ e126 ⊕ e127 ⊕ e128 ⊕ e129 ⊕ e130 ⊕ e131 ⊕ e134 ⊕ e135 ⊕ e172 ⊕ e173 ⊕ e176 ⊕ e177 ⊕ e180 ⊕ e181 ⊕ e188 ⊕ e189 ⊕ e244 ⊕ e245 ⊕ e248 ⊕ e249 ⊕ e252 ⊕ e253 ⊕ e260 ⊕ e261 ⊕ e309 ⊕ e311 ⊕ e313 ⊕ e317
- f12e10 ⊕ e11 ⊕ e12 ⊕ e13 ⊕ e14 ⊕ e15 ⊕ e16 ⊕ e17 ⊕ e25 ⊕ e27 ⊕ e29 ⊕ e31 ⊕ e38 ⊕ e39 ⊕ e40 ⊕ e41 ⊕ e42 ⊕ e43 ⊕ e44 ⊕ e45 ⊕ e52 ⊕ e53 ⊕ e56 ⊕ e57 ⊕ e60 ⊕ e61 ⊕ e64 ⊕ e65 ⊕ e81 ⊕ e82 ⊕ e85 ⊕ e86 ⊕ e89 ⊕ e90 ⊕ e93 ⊕ e94 ⊕ e108 ⊕ e109 ⊕ e110 ⊕ e111 ⊕ e112 ⊕ e113 ⊕ e114 ⊕ e115 ⊕ e123 ⊕ e125 ⊕ e127 ⊕ e129 ⊕ e136 ⊕ e137 ⊕ e140 ⊕ e141 ⊕ e144 ⊕ e145 ⊕ e148 ⊕ e149 ⊕ e166 ⊕ e167 ⊕ e170 ⊕ e171 ⊕ e174 ⊕ e175 ⊕ e178 ⊕ e179 ⊕ e193 ⊕ e195 ⊕ e197 ⊕ e199 ⊕ e208 ⊕ e209 ⊕ e212 ⊕ e213 ⊕ e216 ⊕ e217 ⊕ e220 ⊕ e221 ⊕ e319 ⊕ e321 ⊕ e323 ⊕ e325
- f13e12 ⊕ e13 ⊕ e14 ⊕ e15 ⊕ e18 ⊕ e19 ⊕ e20 ⊕ e21 ⊕ e27 ⊕ e29 ⊕ e33 ⊕ e35 ⊕ e40 ⊕ e41 ⊕ e42 ⊕ e43 ⊕ e46 ⊕ e47 ⊕ e48 ⊕ e49 ⊕ e56 ⊕ e57 ⊕ e60 ⊕ e61 ⊕ e68 ⊕ e69 ⊕ e72 ⊕ e73 ⊕ e85 ⊕ e86 ⊕ e89 ⊕ e90 ⊕ e97 ⊕ e98 ⊕ e101 ⊕ e102 ⊕ e110 ⊕ e111 ⊕ e112 ⊕ e113 ⊕ e116 ⊕ e117 ⊕ e118 ⊕ e119 ⊕ e125 ⊕ e127 ⊕ e131 ⊕ e133 ⊕ e140 ⊕ e141 ⊕ e144 ⊕ e145 ⊕ e152 ⊕ e153 ⊕ e156 ⊕ e157 ⊕ e170 ⊕ e171 ⊕ e174 ⊕ e175 ⊕ e182 ⊕ e183 ⊕ e186 ⊕ e187 ⊕ e195 ⊕ e197 ⊕ e201 ⊕ e203 ⊕ e212 ⊕ e213 ⊕ e216 ⊕ e217 ⊕ e224 ⊕ e225 ⊕ e228 ⊕ e229 ⊕ e321 ⊕ e323 ⊕ e327 ⊕ e329
- f14e14 ⊕ e15 ⊕ e16 ⊕ e17 ⊕ e18 ⊕ e19 ⊕ e22 ⊕ e23 ⊕ e29 ⊕ e31 ⊕ e33 ⊕ e37 ⊕ e42 ⊕ e43 ⊕ e44 ⊕ e45 ⊕ e46 ⊕ e47 ⊕ e50 ⊕ e51 ⊕ e60 ⊕ e61 ⊕ e64 ⊕ e65 ⊕ e68 ⊕ e69 ⊕ e76 ⊕ e77 ⊕ e89 ⊕ e90 ⊕ e93 ⊕ e94 ⊕ e97 ⊕ e98 ⊕ e105 ⊕ e106 ⊕ e112 ⊕ e113 ⊕ e114 ⊕ e115 ⊕ e116 ⊕ e117 ⊕ e120 ⊕ e121 ⊕ e127 ⊕ e129 ⊕ e131 ⊕ e135 ⊕ e144 ⊕ e145 ⊕ e148 ⊕ e149 ⊕ e152 ⊕ e153 ⊕ e160 ⊕ e161 ⊕ e174 ⊕ e175 ⊕ e178 ⊕ e179 ⊕ e182 ⊕ e183 ⊕ e190 ⊕ e191 ⊕ e197 ⊕ e199 ⊕ e201 ⊕ e205 ⊕ e216 ⊕ e217 ⊕ e220 ⊕ e221 ⊕ e224 ⊕ e225 ⊕ e232 ⊕ e233 ⊕ e323 ⊕ e325 ⊕ e327 ⊕ e331
- f15e1 ⊕ e3 ⊕ e7 ⊕ e10 ⊕ e11 ⊕ e12 ⊕ e13 ⊕ e20 ⊕ e21 ⊕ e24 ⊕ e25 ⊕ e26 ⊕ e27 ⊕ e34 ⊕ e35 ⊕ e52 ⊕ e54 ⊕ e56 ⊕ e58 ⊕ e72 ⊕ e74 ⊕ e83 ⊕ e87 ⊕ e103 ⊕ e109 ⊕ e111 ⊕ e119 ⊕ e122 ⊕ e124 ⊕ e132 ⊕ e137 ⊕ e141 ⊕ e157 ⊕ e164 ⊕ e167 ⊕ e168 ⊕ e171 ⊕ e184 ⊕ e187 ⊕ e192 ⊕ e193 ⊕ e194 ⊕ e195 ⊕ e202 ⊕ e203 ⊕ e206 ⊕ e207 ⊕ e210 ⊕ e211 ⊕ e226 ⊕ e227 ⊕ e234 ⊕ e235 ⊕ e236 ⊕ e237 ⊕ e238 ⊕ e239 ⊕ e240 ⊕ e241 ⊕ e254 ⊕ e255 ⊕ e256 ⊕ e257 ⊕ e263 ⊕ e265 ⊕ e273 ⊕ e277 ⊕ e279 ⊕ e287 ⊕ e305 ⊕ e307 ⊕ e315
- f16e2 ⊕ e3 ⊕ e15 ⊕ e17 ⊕ e19 ⊕ e23 ⊕ e25 ⊕ e28 ⊕ e30 ⊕ e31 ⊕ e32 ⊕ e36 ⊕ e37 ⊕ e55 ⊕ e62 ⊕ e66 ⊕ e67 ⊕ e70 ⊕ e78 ⊕ e79 ⊕ e90 ⊕ e94 ⊕ e98 ⊕ e106 ⊕ e127 ⊕ e129 ⊕ e131 ⊕ e135 ⊕ e173 ⊕ e177 ⊕ e181 ⊕ e189 ⊕ e242 ⊕ e246 ⊕ e247 ⊕ e250 ⊕ e258 ⊕ e259 ⊕ e283 ⊕ e289
- f17e3 ⊕ e4 ⊕ e7 ⊕ e9 ⊕ e24 ⊕ e25 ⊕ e26 ⊕ e27 ⊕ e34 ⊕ e35 ⊕ e38 ⊕ e39 ⊕ e40 ⊕ e41 ⊕ e48 ⊕ e49 ⊕ e53 ⊕ e54 ⊕ e55 ⊕ e57 ⊕ e58 ⊕ e59 ⊕ e73 ⊕ e74 ⊕ e75 ⊕ e80 ⊕ e84 ⊕ e100 ⊕ e108 ⊕ e110 ⊕ e118 ⊕ e136 ⊕ e137 ⊕ e138 ⊕ e139 ⊕ e140 ⊕ e141 ⊕ e142 ⊕ e143 ⊕ e156 ⊕ e157 ⊕ e158 ⊕ e159 ⊕ e165 ⊕ e166 ⊕ e167 ⊕ e169 ⊕ e170 ⊕ e171 ⊕ e185 ⊕ e186 ⊕ e187 ⊕ e193 ⊕ e195 ⊕ e203 ⊕ e208 ⊕ e209 ⊕ e212 ⊕ e213 ⊕ e228 ⊕ e229 ⊕ e234 ⊕ e235 ⊕ e238 ⊕ e239 ⊕ e254 ⊕ e255 ⊕ e277 ⊕ e279 ⊕ e287 ⊕ e291 ⊕ e293 ⊕ e301 ⊕ e319 ⊕ e321 ⊕ e329
- f18e3 ⊕ e6 ⊕ e7 ⊕ e9 ⊕ e15 ⊕ e17 ⊕ e19 ⊕ e23 ⊕ e24 ⊕ e25 ⊕ e26 ⊕ e28 ⊕ e30 ⊕ e31 ⊕ e32 ⊕ e34 ⊕ e36 ⊕ e37 ⊕ e38 ⊕ e39 ⊕ e40 ⊕ e41 ⊕ e48 ⊕ e49 ⊕ e53 ⊕ e54 ⊕ e55 ⊕ e57 ⊕ e58 ⊕ e62 ⊕ e66 ⊕ e67 ⊕ e70 ⊕ e73 ⊕ e74 ⊕ e78 ⊕ e79 ⊕ e81 ⊕ e82 ⊕ e83 ⊕ e85 ⊕ e86 ⊕ e87 ⊕ e90 ⊕ e94 ⊕ e98 ⊕ e101 ⊕ e102 ⊕ e103 ⊕ e106 ⊕ e108 ⊕ e110 ⊕ e118 ⊕ e122 ⊕ e123 ⊕ e124 ⊕ e125 ⊕ e127 ⊕ e129 ⊕ e131 ⊕ e132 ⊕ e133 ⊕ e135 ⊕ e136 ⊕ e140 ⊕ e156 ⊕ e164 ⊕ e166 ⊕ e168 ⊕ e170 ⊕ e173 ⊕ e177 ⊕ e181 ⊕ e184 ⊕ e186 ⊕ e189 ⊕ e192 ⊕ e194 ⊕ e202 ⊕ e206 ⊕ e207 ⊕ e208 ⊕ e209 ⊕ e210 ⊕ e211 ⊕ e212 ⊕ e213 ⊕ e226 ⊕ e227 ⊕ e228 ⊕ e229 ⊕ e234 ⊕ e235 ⊕ e236 ⊕ e237 ⊕ e238 ⊕ e239 ⊕ e240 ⊕ e241 ⊕ e242 ⊕ e246 ⊕ e247 ⊕ e250 ⊕ e254 ⊕ e255 ⊕ e256 ⊕ e257 ⊕ e258 ⊕ e259 ⊕ e263 ⊕ e265 ⊕ e273 ⊕ e277 ⊕ e279 ⊕ e283 ⊕ e287 ⊕ e289 ⊕ e305 ⊕ e307 ⊕ e315 ⊕ e319 ⊕ e321 ⊕ e329
- f19e3 ⊕ e5 ⊕ e8 ⊕ e24 ⊕ e25 ⊕ e26 ⊕ e27 ⊕ e34 ⊕ e35 ⊕ e38 ⊕ e40 ⊕ e48 ⊕ e53 ⊕ e54 ⊕ e55 ⊕ e57 ⊕ e58 ⊕ e59 ⊕ e73 ⊕ e74 ⊕ e75 ⊕ e81 ⊕ e85 ⊕ e101 ⊕ e108 ⊕ e110 ⊕ e118 ⊕ e136 ⊕ e140 ⊕ e156 ⊕ e165 ⊕ e166 ⊕ e169 ⊕ e170 ⊕ e185 ⊕ e186 ⊕ e192 ⊕ e194 ⊕ e202 ⊕ e206 ⊕ e207 ⊕ e208 ⊕ e209 ⊕ e210 ⊕ e211 ⊕ e212 ⊕ e213 ⊕ e226 ⊕ e227 ⊕ e228 ⊕ e229 ⊕ e234 ⊕ e235 ⊕ e238 ⊕ e239 ⊕ e254 ⊕ e255 ⊕ e263 ⊕ e265 ⊕ e273 ⊕ e277 ⊕ e279 ⊕ e287 ⊕ e319 ⊕ e321 ⊕ e329
- f20e0 ⊕ e1 ⊕ e5 ⊕ e7 ⊕ e9 ⊕ e11 ⊕ e13 ⊕ e15 ⊕ e17 ⊕ e19 ⊕ e21 ⊕ e23 ⊕ e27 ⊕ e28 ⊕ e30 ⊕ e31 ⊕ e32 ⊕ e35 ⊕ e36 ⊕ e37 ⊕ e38 ⊕ e39 ⊕ e40 ⊕ e41 ⊕ e48 ⊕ e49 ⊕ e53 ⊕ e57 ⊕ e59 ⊕ e62 ⊕ e66 ⊕ e67 ⊕ e70 ⊕ e73 ⊕ e75 ⊕ e78 ⊕ e79 ⊕ e81 ⊕ e83 ⊕ e85 ⊕ e87 ⊕ e90 ⊕ e94 ⊕ e98 ⊕ e101 ⊕ e103 ⊕ e106 ⊕ e108 ⊕ e110 ⊕ e118 ⊕ e122 ⊕ e124 ⊕ e127 ⊕ e129 ⊕ e131 ⊕ e132 ⊕ e135 ⊕ e136 ⊕ e140 ⊕ e156 ⊕ e164 ⊕ e165 ⊕ e166 ⊕ e168 ⊕ e169 ⊕ e170 ⊕ e173 ⊕ e177 ⊕ e181 ⊕ e184 ⊕ e185 ⊕ e186 ⊕ e189 ⊕ e192 ⊕ e194 ⊕ e202 ⊕ e206 ⊕ e207 ⊕ e208 ⊕ e209 ⊕ e210 ⊕ e211 ⊕ e212 ⊕ e213 ⊕ e226 ⊕ e227 ⊕ e228 ⊕ e229 ⊕ e236 ⊕ e237 ⊕ e240 ⊕ e241 ⊕ e242 ⊕ e246 ⊕ e247 ⊕ e250 ⊕ e256 ⊕ e257 ⊕ e258 ⊕ e259 ⊕ e263 ⊕ e265 ⊕ e273 ⊕ e283 ⊕ e289 ⊕ e305 ⊕ e307 ⊕ e315 ⊕ e319 ⊕ e321 ⊕ e329
- 51 spiders from 828
- 21 noise bits from 332 error bits
The simplified diagram falls apart into 16 independent components. The 15 detectors each hang on a single noise bit, so Tsim samples them directly, without simulating anything. What remains is one quantum component with the 5 logical outputs: the distillation itself, with the Steane code gone.
- 21 spiders
Tsim reads the quantum component as 10 Pauli-product rotations and 5 measurements on 5 qubits, starting from |0…0⟩. Rotations that do not commute with the current stabilizers widen the state; measurements narrow it. In the order read off the diagram, the active width climbs to K = 5: 32 amplitudes.
Operations may run in any order in which every anticommuting pair keeps its order. Tsim builds an order greedily. Each round first runs what is free: measurements whose predecessors have run, and rotations that do not widen the state. If measurements still wait, it tries each of them, running the operations it depends on, and keeps the one whose trial reaches the smallest width.
For each of the 5 waiting measurements, Tsim walks up through the earlier operations, bottom to top, and commutes each past the measurement if it can: that is, if it commutes with the measurement and with every operation that stayed. The operations that stay must run first. Tsim tries all measurements and picks the one whose operations reach the smallest width.
obs[0] wins with a peak of K = 3. Its 6 operations run, then the measurement, which brings the width back to 2.
For each of the 4 waiting measurements, Tsim walks up through the earlier operations, bottom to top, and commutes each past the measurement if it can: that is, if it commutes with the measurement and with every operation that stayed. The operations that stay must run first. Tsim tries all measurements and picks the one whose operations reach the smallest width.
obs[4] wins with a peak of K = 3. Its 2 operations run, then the measurement, which brings the width back to 2.
For each of the 3 waiting measurements, Tsim walks up through the earlier operations, bottom to top, and commutes each past the measurement if it can: that is, if it commutes with the measurement and with every operation that stayed. The operations that stay must run first. Tsim tries all measurements and picks the one whose operations reach the smallest width.
obs[1] wins with a peak of K = 3, tied with others; the earliest wins. Its 1 operation run, then the measurement, which brings the width back to 2.
The remaining 3 operations run for free, without widening the state. The scheduled program peaks at K = 3: 8 amplitudes instead of 32.
| # | Pauli | Operation | Noise | K |
|---|---|---|---|---|
| 1 | rotate 0.098π | f20 | 1 | |
| 2 | rotate 0.098π | f20 | 2 | |
| 3 | rotate 0.098π | f20 | 3 | |
| 4 | rotate 0.098π | – | 4 | |
| 5 | rotate 0.098π | – | 5 | |
| 6 | rotate π/8 | f20 | 5 | |
| 7 | rotate −π/8 | f20 | 5 | |
| 8 | rotate −π/8 | – | 5 | |
| 9 | rotate −π/8 | – | 5 | |
| 10 | rotate π/8 | f20 | 5 | |
| 11 | measure → obs[0] | f15 ⊕ f16 ⊕ f19 | 4 | |
| 12 | measure → obs[1] | f18 | 3 | |
| 13 | measure → obs[2] | f15 ⊕ f16 ⊕ f17 | 2 | |
| 14 | measure → obs[3] | f16 ⊕ f18 ⊕ f19 | 1 | |
| 15 | measure → obs[4] | f15 ⊕ f16 ⊕ f18 | 0 | |
The scheduled program acts on 5 qubits, but its active width never exceeds K = 3. Tsim makes this concrete by inserting pairs of Clifford gates that conjugate Paulis into lower-weight ones, so that some qubits are never touched. Every operation then acts on the 3 axes a0–a2 of an array of 8 amplitudes. The other qubits stay in |0⟩, where a Z does nothing, so it drops out (faded).
A rotation with an X on a qubit in |0⟩ takes a free axis: the Clifford gates move that X there. A measurement acts on the array as it is; then the Clifford gates fold it onto one axis, which returns to |0⟩ and is free again.
| # | Pauli | Rewritten | Compacted | Operation |
|---|---|---|---|---|
| 1 | rotate 0.098π | |||
| 2 | rotate 0.098π | |||
| 5 | rotate 0.098π | |||
| 6 | rotate π/8 | |||
| 9 | rotate −π/8 | |||
| 10 | rotate π/8 | |||
| 11 | measure → obs[0] | |||
| 4 | rotate 0.098π | |||
| 8 | rotate −π/8 | |||
| 15 | measure → obs[4] | |||
| 3 | rotate 0.098π | |||
| 12 | measure → obs[1] | |||
| 7 | rotate −π/8 | |||
| 13 | measure → obs[2] | |||
| 14 | measure → obs[3] |
Each shot draws its own noise bits, but only those that flip the sign of a rotation reach the statevector. Here that is just f20, so all shots start in 2 groups, one statevector each. The other noise bits sit on measurements, where they only relabel the outcome: Tsim XORs them into each shot's results at the end.
The measurements themselves are random. At each one, a group splits in two, and Tsim draws from a binomial how many of its shots take each outcome. An outcomeb can also flip later signs, as b2 does for operation 7. With 5 random measurements, that makes at most 2 × 25 = 64 trajectories of 8 amplitudes each.
| # | Pauli on the array | Operation | Depends on | Trajectories |
|---|---|---|---|---|
| 1 | rotate 0.098π | f20 | 2 | |
| 2 | rotate 0.098π | f20 | 2 | |
| 5 | rotate 0.098π | – | 2 | |
| 6 | rotate π/8 | f20 | 2 | |
| 9 | rotate −π/8 | – | 2 | |
| 10 | rotate π/8 | f20 | 2 | |
| 11 | measure → obs[0] | b0splits | 4 | |
| 4 | rotate 0.098π | – | 4 | |
| 8 | rotate −π/8 | – | 4 | |
| 15 | measure → obs[4] | b1splits | 8 | |
| 3 | rotate 0.098π | f20 | 8 | |
| 12 | measure → obs[1] | b2splits | 16 | |
| 7 | rotate −π/8 | f20b2 | 16 | |
| 13 | measure → obs[2] | b3splits | 32 | |
| 14 | measure → obs[3] | b4splits | 64 |
- obs[0] = f15 ⊕ f16 ⊕ f19 ⊕ b0
- obs[1] = f18 ⊕ b0 ⊕ b1 ⊕ b2
- obs[2] = f15 ⊕ f16 ⊕ f17 ⊕ b0 ⊕ b3
- obs[3] = f16 ⊕ f18 ⊕ f19 ⊕ b0 ⊕ b2 ⊕ b4
- obs[4] = f15 ⊕ f16 ⊕ f18 ⊕ b0 ⊕ b1
Trajectories in one call: 10 shots → 9 · 100 shots → 39 · 1,000 shots → 64 · 10,000 shots → 64 · 65,536 shots → 64
Importantly, the final PBC often requires far fewer qubits than the original circuit, so it can be simulated with a statevector simulator. As in Clifft,[1] we call the number of qubits of the PBC its active width.
Compressing Circuits
The active width of common QEC circuits can be surprisingly small. For end-to-end magic-state cultivation, for example, the 463-qubit circuit is compressed into a statevector with an active width of 6. Tsim’s ZX reduction is particularly effective at reaching a low active width. In the d=7 cultivation workload from SymFT [2], Tsim reaches a peak width of 8, compared with 19 for Clifft and SymFT, as shown in the table below. This means that a statevector with 256 coefficients is enough to represent the circuit instead of 524,288 - a reduction by a factor of 2,048.
| Active width K | ||||
|---|---|---|---|---|
| Circuit | Qubits | Tsim 1.0.0 | Clifft 0.12.0 | SymFT 0.1.1 |
| Distillation d=5 | 85 | 3 (lowest) | 3 (lowest) | 5 |
| Cultivation d=5 | 42 | 6 (lowest) | 10 | 10 |
| Cultivation d=5, end-to-end | 463 | 6 (lowest) | 10 | 10 |
| Cultivation d=7 (SymFT) | 80 | 8 (lowest) | 19 | 19 |
| Coherent surface d=3, r=1 | 26 | 0 (lowest) | 0 (lowest) | 4 |
| Coherent surface d=3, r=3 | 26 | 4 (lowest) | 4 (lowest) | 7 |
| Coherent surface d=5, r=1 | 64 | 0 (lowest) | 0 (lowest) | 12 |
| Coherent surface d=5, r=5 | 64 | 11 (lowest) | 13 | 22 |
Benchmarks
Tsim’s ZX engine has been rewritten in Rust, which makes compilation significantly faster. Additionally, Tsim can speed up sampling by sharing statevectors between shots whose noise configurations have the same effect. In our benchmarks, this trajectory sharing approach makes sampling more than an order of magnitude faster on small circuits. Below, we compare Tsim 1.0.0 with Clifft 0.12.0 and SymFT 0.1.1 on 10 circuits from the Clifft and SymFT benchmark suites.
Run details
- Machine
- One AMD Ryzen 9 9900X (12 cores, 24 threads, 64 GB) running Linux; every measurement runs in a fresh process.
- Sampling
- Attempted shots per second, median of 3 timed repetitions of at least 5 s each, after compilation and one untimed warm-up call. Shots rejected by postselection count as attempted, so a rate with postselection on is a cost per attempt, not per accepted shot. Clifft samples with the batch size it calibrates during the warmup call (
batch_size="tune"), as its own benchmark suite does. - Compilation
- Wall time from circuit text to a sampler ready to sample, median over 3 fresh processes, with imports done before the clock starts, shown at 1 thread with postselection off. First-call JIT compilation inside sampling is not included. Clifft runs its default optimization passes plus its opt-in
ActiveWidthSchedulePass(a search over operation orderings) with default settings, on every circuit, for both compilation and sampling. - Threads
- Every engine gets the same budget, 1 or 10 threads: the harness caps the OpenMP and numba thread pools and passes the budget to engines that take a
threadsargument. - Postselection
- With postselection on, every detector is postselected, except on Cultivation d=5, end-to-end, where only the injection and cultivation detectors are (the convention of Gidney et al.). SymFT can only postselect on all detectors, so it has no number there. Circuits without detectors show their postselection-off measurement in both views.
- Output
- Output contracts differ: Tsim returns full detector and observable arrays, bit-packed (8 detectors per byte) and counted inside the timed region; Clifft and SymFT return survivor counts.
- Views
- One row per circuit, one lane per simulator, on a shared log axis. Relative view puts the slowest engine in each row at 1×. Compare draws each lane from the baseline setting (open mark: 1 thread, postselection off, sharing off) to the target (filled mark) and labels it with how many times faster the target is. Hover or focus a row for details, or download the CSV.
- K
- The largest number of qubits held in a dense statevector at once, as each simulator reports it (Tsim: component width; Clifft:
peak_active_width; SymFT:max_active_qubits). Sampling cost grows as 2K. - Versions
- Tsim 1.0.0: bloqade-tsim 0.1.5 @ git 73656a2, numpy 2.4.4, numba 0.65.0, stim 1.15.0 · Clifft 0.12.0: clifft 0.12.0, numpy 2.5.4 · SymFT 0.1.1: symft 0.1.1, numpy 2.5.4
- Circuits
- Each circuit name links to its source on GitHub, at the commit measured. Sources: Clifft paper benchmarks; Gidney et al. cultivation circuits, as used by the Clifft paper; SymFT benchmark suite.
Simulators as compilers
We are excited about the recent advances in universal near-Clifford simulation. In particular, we want to emphasize the close connection between simulators and compilers, a point first made by Clifft: compiler passes transform an intermediate representation of the quantum program before the simulator executes it. By reducing the active width, such passes can bring circuits within reach that would otherwise be too expensive to simulate.
The clifft-bench project tracks these improvements across releases. For example, Clifft 0.10’s compiler improvements reduced the active width of the coherent surface-code d=5, r=5 benchmark from 24 to 13. This illustrates how much can be gained by simplifying the program before optimizing its numerical execution. We are working to contribute Tsim’s ZX-based compiler pass to Clifft, to bring similar speedups to other widely used simulators as well.
Summary
Tsim 1.0.0 introduces some key advances:
- Active statevector backend. Building on Clifft and SymFT, Tsim compresses a circuit into an equivalent circuit on far fewer qubits. It replaces stabilizer-rank decomposition as the default for sampling.
- ZX simplification first. Tsim’s ZX reduction reaches the lowest active width of the three simulators on every circuit in our benchmark, which translates directly into faster sampling.
- Trajectory sharing. Shots whose noise affects the circuit in the same way share one statevector, which reduces both the work per shot and the memory needed.
- A ZX engine rewritten in Rust, which makes compilation significantly faster.
Tsim now achieves state-of-the-art performance for near-Clifford circuits with Pauli noise. More accurate noise models include atom loss and leakage, which Tsim currently does not support. QEC programs beyond the gadget level also require real-time decoding. These call for different simulation strategies, such as those in PPVM, our first step toward a quantum digital twin. To build circuits with feedforward and real-time decoding, try QEC Studio.
Acknowledgements
We thank Bradley A. Chase for insightful discussions. We also thank Bradley A. Chase and Farrokh Labib for building and open-sourcing Clifft, and Wang Fang, Huazhe Lou and Riling Li for building and open-sourcing SymFT. Their work provided the foundation for Tsim’s new backend.
Cite this post
@misc{haenel2026tsim,
author = {Rafael Haenel and Xiu-Zhe Luo},
title = {Tsim: Faster near-Clifford simulation with active statevectors and a new {ZX} engine},
howpublished = {Bloqade blog, QuEra Computing},
year = {2026},
month = {nov},
url = {https://bloqade.quera.com/blog/introducing-tsim-1-0-0/},
}References
- B. A. Chase and F. Labib, “Clifft: Fast Exact Simulation of Near-Clifford Quantum Circuits,” arXiv:2604.27058 (2026). ↩︎ ↩︎2 ↩︎3
- W. Fang, H. Lou, and R. Li, “SymFT: Universal Fault-Tolerant Quantum Circuit Simulation via Symbolic Clifford–Pauli Frames and Stabilizer Coordinates,” arXiv:2607.28600 (2026). ↩︎ ↩︎2 ↩︎3
- C. Gidney, N. Shutty, and C. Jones, “Magic State Cultivation: Growing T States as Cheap as CNOT Gates,” arXiv:2409.17595 (2024). ↩︎
- C. Gidney, “Stim: A Fast Stabilizer Circuit Simulator,” Quantum 5, 497 (2021). ↩︎
- R. Haenel, X.-Z. Luo, and C. Zhao, “Tsim: Fast Universal Simulator for Quantum Error Correction,” arXiv:2604.01059 (2026). ↩︎
- S. Bravyi et al., “Simulation of Quantum Circuits by Low-Rank Stabilizer Decompositions,” Quantum 3, 181 (2019). ↩︎