Table of Contents
Fetching ...

Tsim: Fast Universal Simulator for Quantum Error Correction

Rafael Haenel, Xiuzhe Luo, Chen Zhao

Abstract

We present Tsim, an open-source high-throughput simulator for universal noisy quantum circuits targeting quantum error correction. Tsim represents quantum circuits as ZX diagrams, where Pauli channels are modeled as parameterized vertices. Diagrams are simplified via parameterized ZX rules, and then compiled for vectorized sampling with GPU acceleration. After the one-time compilation, one can sample detector or measurement shots in linear time in the number of Clifford gates and exponentially only in the number of non-Clifford gates. Tsim implements the Stim API and fully supports the Stim circuit format, extending it with T and arbitrary single-qubit rotation instructions. For low-magic circuits, Tsim throughput can match the sampling performance of Stim.

Tsim: Fast Universal Simulator for Quantum Error Correction

Abstract

We present Tsim, an open-source high-throughput simulator for universal noisy quantum circuits targeting quantum error correction. Tsim represents quantum circuits as ZX diagrams, where Pauli channels are modeled as parameterized vertices. Diagrams are simplified via parameterized ZX rules, and then compiled for vectorized sampling with GPU acceleration. After the one-time compilation, one can sample detector or measurement shots in linear time in the number of Clifford gates and exponentially only in the number of non-Clifford gates. Tsim implements the Stim API and fully supports the Stim circuit format, extending it with T and arbitrary single-qubit rotation instructions. For low-magic circuits, Tsim throughput can match the sampling performance of Stim.

Paper Structure

This paper contains 28 sections, 36 equations, 4 figures, 2 tables, 1 algorithm.

Figures (4)

  • Figure 1: Overview of the Tsim simulation pipeline. Quantum programs are translated into ZX diagrams in which Pauli noise channels appear as parameterized vertices with binary variables $e_i$. ZX simplification factors the diagram into a classical part, that represents the Tanner graph, and a quantum part containing the observable circuit. Both parts define a new basis of error mechanisms$f_i = \bigoplus_j T_{ij}\,e_j$. The observable diagram is used to compute marginal probabilities for autoregressive sampling. Here, each diagram is decomposed into a sum of Clifford terms via stabilizer rank decomposition Sutcliffe_2025 and compiled into binary JAX tensors $g_{tki}$. At sampling time, JIT-compiled XLA kernels contract $g_{tki}$ with batched noise configurations $f_i^{s}$ to evaluate marginal probabilities and autoregressively sample detector and observable bits.
  • Figure 2: (a) Shot sampling time comparison between Tsim and Stim for $d=3,5$ distillation circuits from sales2025experimental, $d=3$ cultivation circuit from gidney2024magic, and a $d=7$ rotated surface code (7 rounds). Tsim runtime is normalized by the number of stabilizer terms in the decomposition. For reference, unnormalized runtimes are shown in Fig. \ref{['fig:benchmark-unnormalized']}. (b) Runtime comparison between Tsim and quizx. Each data point corresponds to a randomly generated circuit of exponentiated Paulis of weight 2--4 and depth between 1 and 21. For Tsim, batch size is autotuned to maximize throughput. All CPU benchmarks were performed on an Apple M4 Pro. GPU benchmarks were conducted on an NVIDIA Grace Hopper GH200 system with a 72-core ARM Neoverse-V2 CPU.
  • Figure 3: Validation of Tsim against a statevector simulator gidney2024magic and PyZX tensor contraction for random circuits with terminal measurements.
  • Figure 4: Shot-runtime comparison between Tsim and Stim for $d=3,5$ distillation circuits from sales2025experimental, $d=3$ cultivation circuit from gidney2024magic, and a $d=7$ rotated surface code. All CPU benchmarks (blue dots) were performed on an Apple M4 Pro. GPU benchmarks were conducted on an NVIDIA Grace Hopper GH200 system with a 72-core ARM Neoverse-V2 CPU (green triangles) or an NVIDIA RTX 5090 GPU with AMD Ryzen 9 9900X (orange squares).