Clifft¶
A fast exact simulator for near-Clifford quantum circuits.
What is Clifft?¶
Clifft is an exact simulator for quantum circuits whose dominant structure is Clifford, but whose behavior depends on localized non-Clifford operations. It accepts Stim circuits, extends them with non-Clifford gates, and compiles them into a high-performance symbolic-coordinate sampling plan.
Clifft factors each trajectory into an offline Clifford coordinate map, branch-dependent Pauli corrections represented by affine Boolean signs, and a dense active state. Coordinate transformations and symbolic dependencies are resolved ahead of time; each shot evaluates the prepared signs and active-state actions without evolving an online tableau or physical-qubit Pauli frame.
The main cost scales with \(2^k\) rather than \(2^n\), where \(n\) is the total number of qubits and \(k\) is the active width. The corresponding active-state dimension is \(2^k\). Non-Clifford operations can increase \(k\), while measurements can reduce it. For near-Clifford protocols with frequent measurements, such as magic-state preparation circuits, this can provide large memory and runtime savings over standard dense state-vector simulation.
Quick Example¶
Install via pip install clifft, then:
import clifft
# Compile a Stim-format circuit extended with T gates.
program = clifft.compile("""
H 0
CNOT 0 1
T 2
M 0 1 2
""")
# Sample measurement outcomes.
result = clifft.sample(program, shots=1000)
print(result.measurements[:5]) # First 5 shots.
Key Features¶
-
Stim Circuits with Non-Clifford Extensions
Existing Stim circuits compile directly. Add Clifft's non-Clifford gates when needed, then compile once and sample many shots through a familiar Python interface. OpenQASM 2, Qiskit, and Cirq inputs are also available.
-
Exact Near-Clifford Simulation
Simulate circuits with localized non-Clifford operations exactly, without approximating the quantum state.
-
Leakage and Loss
Model state-dependent leakage and loss, including measurement classification and back-action on the computational state. See the Leakage and Loss guide.
-
Active-Width Scaling
For circuits with bounded active width, memory and runtime scale with the localized active state rather than the full qubit count.
For QEC workflows, Clifft also supports detector-based post-selection, survivor sampling, and stratified importance sampling for rare-event estimation.
Get Started¶
Quick Start Try the Playground
What's New in 0.10.1¶
Clifft 0.10.1 fixes biased noise sampling in multi-shot leakage and loss simulations after a shot resumes through a continuation. It also adds a Logical Shor Noise Sweep on Neutral Atoms tutorial with four example circuits and a runnable script comparing approximate and exact treatment of state-dependent leakage and loss.
What's New in 0.10.0¶
Clifft 0.10.0 adds automatic packed batch sampling for eligible low-active-width CPU workloads and Apple Silicon NEON kernels for active-state operations. Advanced callers can use batch_size to tune the packed-lane capacity, while the default cost-aware policy balances throughput and memory.
In single-core benchmarks, v0.10 is faster than v0.9 on all eight measured workloads, with a 3.23x median improvement. It also leads SymFT on all eight, from 1.05x to 87.7x. See Performance for the figures, absolute throughput, dense Quantum Volume results, and measurement details.
The release also accepts supported unitary OpenQASM 2 circuits without Qiskit and moves production builds onto Clifft's native Clifford implementation. Stim remains an independent test oracle.
Read Packed Sampling in Clifft for the design, automatic policy, and v0.9 comparison. See Circuit Inputs for OpenQASM, Qiskit, and Cirq options, or CPU Execution and Tuning for detailed controls.
Earlier development updates¶
Read Parallel Sampling in Clifft for the v0.9.0 threading work and Symbolic Sampling in Clifft for the v0.8.0 compiler and sampler redesign.