Skip to content

Clifft

Clifft Clifft

A fast exact simulator for near-Clifford quantum circuits.

Unitary Foundation PyPI version Downloads CI codecov arXiv Discord Chat Contributor Covenant


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.

See Acknowledgments and references for the research and software that shaped Clifft.

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.12.0

Clifft 0.12.0 extends leakage and loss simulations with status checks that feed detectors and feedback, and configurable effects on gate partners to model Pauli noise and leakage spreading.

Two new default compiler passes use the prepared state to simplify commuting T rotations and arbitrary-angle rotations, reducing the dense state needed for sampling. Opt-in batch tuning measures and reports a reusable batch size for longer CPU sampling jobs. Read Richer Noise Models, Smaller Active States for examples of the new capabilities.

The new default passes can change compiled plans and fixed-seed samples while preserving distributions. See the full release notes for compatibility details.

What's New in 0.11.0

Clifft 0.11.0 continues improving CPU sampling through active-width scheduling and sampling noise only when it is needed. The opt-in scheduler searches for operation orders with lower peak active width or less work at larger widths; deferred noise draws let postselected shots avoid later noise work after rejection.

Early testing suggested that Clifft could be competitive with Stim on some Clifford error-detection circuits. The new Sinter-compatible sampler makes those workloads accessible through Sinter's experiment collection tools and is a first step toward exploring broader QEC workflows.

Experimental GPU work also continues, exploring workloads that could benefit from GPU memory capacity and bandwidth. The AMD HIP backend gains cooperative execution for wider active states, and the new NVIDIA CUDA backend opens another hardware path. Thanks to Jose Manuel Monsalve Diaz and AMD for the HIP contributions, and Farrokh Labib for the CUDA backend. Both remain experimental, require source builds, and are never selected automatically.

The shared test suite has grown alongside these execution choices: feature tests run across the modes that support them, and new backends inherit the existing tests for their supported features. Read Less Work per Shot in Clifft for the development story and local A/B measurements, or see the full release notes.

Full Changelog