Skip to content

qsimlab

Exact quantum circuit simulation for Python. A Rust core with seven engines and a cost-model planner that picks the fastest exact one for each circuit. numpy in, numpy out.

import qsimlab as qs

# GHZ state on 3 qubits
c = qs.Circuit(3).h(0).cx(0, 1).cx(1, 2)

qs.simulate(c, qs.amplitudes(["000", "111"])).amplitudes
# array([0.7071+0.j, 0.7071+0.j])

qs.simulate(c, qs.expectation(["Z0 Z2", "X0 X1 X2"])).values
# array([1., 1.])
  • Exact by default


    No truncation or approximation unless a result says so. Every engine is differential-tested against an independent reference state vector.

  • The planner picks the engine


    State vector, stabilizer tableau, sparse, MPS, hybrid Schrödinger–Feynman, compressed Clifford+T and batched noisy-Clifford sampling, chosen per connected component by a cost model. Pass explain=True to see why.

  • Error correction


    Surface, repetition and colour-code memory circuits, detector sampling, detector error models, decoders and logical error rates.

    QEC guide

  • Shor at gate level


    Factor semiprimes by exact simulation of the full X/CNOT/Toffoli circuit, with resource counts and noise studies.

    Shor guide

  • Why is it hard?


    Magic, stabilizer rank and simulability analysis that explain a circuit's cost, mostly without simulating it.

    Analysis guide

  • Works with your stack


    Convert to and from Qiskit, Cirq, Stim and OpenQASM 2. Typed API, abi3 wheels, no runtime dependencies beyond numpy.

    Interop reference

Built on research

qsimlab is the Python face of qsim-lab, where every headline result goes through an independent audit before it is merged. A few of them:

Result Number
Gate-level Shor, generic semiprime 31-bit N factored by exact simulation of the full 132-qubit circuit
Detector sampling vs Stim 1.16 9–12× faster on x86 at ≥ 10⁵ shots, identical output distribution
Weight-6 qLDPC codes [[224,18,12]] and [[288,34,8]], beyond every published weight-6 code
Engine planner held-out regret 1.07–1.11 when choosing the exact engine

More in Research and the full results summary.

Status

qsimlab is alpha (v0.1). The core API (circuit, sim, errors, interop) is stable under the API contract. qec, shor and analysis are provisional.