Skip to main content

Superfermion

Superfermion

A high-performance quantum computing framework with a Python API and a Rust simulation core. Statevector, MPS, stabilizer, and density matrix simulation methods with native adjoint differentiation, quantum error correction, and multi-framework interop.

Python 3.10+ Rust 1.85+ License: Apache 2.0


What is Superfermion?

Superfermion is a quantum computing framework that combines a Python-native API with a Rust acceleration core (Rayon multithreading + in-place statevector).

  • 4 simulation methods — statevector (CPU/GPU), MPS tensor network, stabilizer (Aaronson-Gottesman tableau), density matrix (Kraus channels)
  • Adjoint differentiation — 1 forward + 1 backward pass regardless of parameter count (44–198x faster than parameter-shift on deep circuits)
  • MPS tensor networks — Rust MPS with faer-based QR decomposition and lazy SWAP routing; scales to 200+ qubits for low-entanglement circuits
  • Stabilizer simulator — word-packed tableau; Clifford circuits at poly-time to ~1000 qubits
  • Quantum Error Correction — stabilizer code constructions (Repetition, Shor, Steane, Surface) + decoders (BP+OSD, greedy matching, Union-Find, Neural); additional codes in progress
  • Multi-framework ML — QuantumLayer (Flax), TorchQuantumLayer (PyTorch), TFQuantumLayer (TensorFlow)
  • 5 gradient methods — adjoint, parameter-shift, SPSA, QNG, Riemannian
  • Quantum algorithms — VQE, QAOA, Grover, QPE, HHL, Amplitude Estimation
  • Chemistry module — Jordan-Wigner + Bravyi-Kitaev transformations, UCCSD ansatz, PySCF bridge, molecular Hamiltonian library
  • Hardware compilation — gate decomposition, rotation merging, SABRE qubit routing, Pauli twirling; targets IBM, Rigetti, IonQ, IQM
  • QPU providers — IBM Quantum, IonQ, AWS Braket, OpenQuantum
  • Cross-framework bridges — Qiskit, Cirq, PennyLane, OpenQASM 2/3

Installation

pip install superfermion

Already installed? pip will not move an existing environment on its own, so upgrade in place:

pip install -U superfermion

From 0.1.20 the package also prints a one-line notice to stderr when a newer release is on PyPI. It checks at most once a day, in a background thread, and is silent when offline, in CI, or under pytest; disable it with SF_NO_UPDATE_CHECK=1.

Wheels are built once against the CPython stable ABI and tagged cp310-abi3, so a single binary per platform installs on CPython 3.10 and every later release, including versions published after the wheel was built:

Platform Architectures Wheel
Linux (glibc 2.28+) x86_64, aarch64 manylinux_2_28
Linux (musl / Alpine) x86_64, aarch64 musllinux_1_2
macOS universal2 (Intel + Apple Silicon) macosx
Windows amd64, arm64 win_amd64, win_arm64

Anything not covered by a wheel — PyPy, 32-bit targets, other architectures, and free-threaded builds (3.14t, 3.15t) — is built from the source distribution by pip, which needs Rust 1.85+ and ~3 GB of free disk. Free-threaded interpreters get a version-specific extension instead of a limited-API one; prebuilt free-threaded wheels are not published yet.

From source (development)

git clone https://github.com/Catstate101/superfermion.git
cd superfermion
pip install maturin
maturin develop --release        # builds crates/sf-bindings into the source tree
pip install -e ".[dev]"

Requirements: Python 3.10+, Rust 1.85+, ~3 GB free disk for the Rust build.

Optional dependency groups:

pip install -e ".[dev]"        # pytest, ruff, mypy, black
pip install -e ".[gpu]"        # JAX with CUDA 12
pip install -e ".[qpu]"        # IBM + AWS Braket SDKs
pip install -e ".[benchmarks]" # PennyLane, Qiskit Aer, pandas, matplotlib
pip install -e ".[chemistry]"  # PySCF, SciPy
pip install -e ".[viz]"        # matplotlib
pip install -e ".[all]"        # everything

Quick Start

import superfermion as sf

# Bell state
qc = sf.Circuit(2).h(0).cx(0, 1)
result = sf.run(qc, device="cpu", shots=1024)
print(result.counts)  # {'00': ~512, '11': ~512}

# Exact simulation with sf.simulate()
state = sf.simulate(qc, device="cpu")
print(state.numpy())       # [0.707+0j, 0, 0, 0.707+0j]
print(state.entropy())     # 0.0 (pure state)
print(state.purity())      # 1.0

# Expectation value (Rust-native)
zz_obs = [([3, 3], 1.0, 0.0)]  # ZZ observable
print(state.expectation(zz_obs))  # 1.0

# Parameterized circuit with gradient
qc = sf.Circuit(1).ry(sf.param("theta"), 0)
bound = qc.bind({"theta": 0.5})
state = sf.simulate(bound, device="cpu")
grads = state.grad([([3], 1.0, 0.0)], qc.to_ir(), {"theta": 0.5})
print(grads)  # {"theta": -0.479...}

Architecture

Python is the API, Rust Does the Work. All performance-critical computation runs in Rust. Python provides the fluent API surface. JAX is used only in nn/quantum_layer.py for the Flax custom_vjp bridge.

Python API (superfermion/)
    |-- Circuit, run(), simulate(), State, MethodError, RunResult
    |-- devices/      RustDevice (CPU/GPU), IBM, IonQ, Braket providers
    |-- observables/   PauliString, SparsePauliOp, Hamiltonian, expval
    |-- qml/          gradients (adjoint, param-shift, SPSA, QNG, Riemannian, SR)
    |-- nn/           Thin ML bridges: Flax/PyTorch/TF → sf.State.grad()
    |-- algorithms/   VQE, QAOA, QSVM, QBM, QRL + Grover, QPE, HHL
    |-- chemistry/    JW/BK transforms, UCCSD ansatz, PySCF bridge
    |-- qec/          codes + 4 decoders
    |-- compiler/     gate decomposition, rotation merge, SABRE routing
    |-- bridge/       Qiskit, Cirq, PennyLane, QASM interop
    |-- noise/        NoiseModel (Kraus channels for density matrix)
    |
    +-- _sf_core  (Rust PyO3 extension: State, QuantumDAG, ...)

Rust workspace (crates/)
    |-- sf-ir/        QuantumStateImpl trait, DAG, statevector, MPS,
    |                 stabilizer, density matrix simulation engines
    |-- sf-compiler/  Pass manager, gate cancellation, rotation merge
    |-- sf-router/    SABRE routing, hardware topology
    |-- sf-qec/       Stabilizer codes, MWPM/UnionFind decoders
    |-- sf-gpu/       CUDA statevector simulation (cudarc, sm_75+)
    |-- sf-bindings/  PyO3 FFI — State, QuantumDAG, compile

Execution flow

sf.run(circuit, device="cpu", method="statevector", shots=N)
    │
    ▼
runner.py — resolve device, bind params, optional compile
    │
    ▼
RustDevice.execute(dag, method, shots)
    │
    ├── statevector    → dag.simulate()             [Rust, Rayon]
    ├── mps            → dag.simulate_mps()         [Rust, faer]
    ├── stabilizer     → dag.simulate_stabilizer()  [Rust, tableau]
    ├── density_matrix → dag.simulate_dm_noisy()    [Rust, Kraus]
    └── gpu            → dag.simulate_gpu()         [CUDA]
    │
    ▼
sf.State (Rust-native) → RunResult(counts, state, metadata)

Simulation Methods

Method Max Qubits Best For
statevector (default) ~25 CPU, ~30 GPU Exact simulation, gradient computation
mps 200+ Low-entanglement circuits (QAOA, VQE, GHZ)
stabilizer ~1000 Clifford-only circuits (QEC, randomized benchmarking)
density_matrix ~12 Noisy simulation with Kraus channels
# MPS simulation
result = sf.run(circuit, device="cpu", method="mps", shots=10000, bond_dim=64)

# Stabilizer simulation
result = sf.run(clifford_circuit, device="cpu", method="stabilizer", shots=10000)

# GPU simulation (requires CUDA)
result = sf.run(circuit, device="gpu", shots=0)

Benchmarks

Performance measured against Qiskit Aer 0.17 and PennyLane Lightning 0.45 on CPU (details in notebooks/). Speedups are regime-dependent; the caveats below are part of the claim.

Workload SF vs Competitor Speedup
Statevector (n=10–18) vs Qiskit Aer statevector up to ~5x (Aer faster at n≥20)
Stabilizer (n=10–500, 10k shots) vs Qiskit Aer stabilizer 3–7x
MPS GHZ (n=10–100, 10k shots) vs Qiskit Aer MPS 23–33x (GHZ is the best case for MPS)
Adjoint gradient (n=4–16, depth=1) vs PennyLane qml.grad 1.5–800x (PennyLane faster at n≥18)
Adjoint vs param-shift (n=10, depth 1–8) SF internal 44–198x (grows with depth)
Shot sampling (n=10–22, 100k shots) vs Qiskit Aer 1.4–11.7x (Aer wins at 1k–10k shots, n≥20)

Key Modules

Gradients

Method File Description
Adjoint qml/gradient/adjoint.py 1 forward + 1 backward pass; fastest for most QML
Parameter-shift qml/gradient/parameter_shift.py 2 forward passes per param; analytic
Finite difference qml/gradient/parameter_shift.py Centered difference fallback
SPSA qml/gradient/spsa.py Stochastic approximation; noisy-hardware friendly
Quantum Natural qml/gradient/qng.py Fubini-Study metric; faster convergence

Machine Learning Layers

from superfermion.nn.quantum_layer import QuantumLayer     # Flax (JAX)
from superfermion.nn.torch_layer import TorchQuantumLayer  # PyTorch
from superfermion.nn.tf_layer import TFQuantumLayer        # TensorFlow

Quantum Error Correction

from superfermion.qec import SurfaceCode2D, MWPMDecoder, QECManager

code = SurfaceCode2D(distance=3)
circuit = code.build()

Cross-Framework Bridge

from superfermion.bridge import from_qiskit, to_qiskit, from_pennylane, to_cirq

sf_circuit = from_qiskit(qiskit_circuit)
qiskit_circuit = to_qiskit(sf_circuit)

Documentation

Full documentation is available at superfermion.com (or superfermion-docs.pages.dev).

Document Content
docs/usage_guide.md Canonical API reference with runnable examples
docs/architecture.md Hexagonal architecture, module map, execution flow
CONTRIBUTING.md Contribution guide
CHANGELOG.md Release history

Citing

@misc{superfermion-2026,
  title  = {SuperFermion: a high-performance quantum-circuit simulator
            with native adjoint differentiation},
  author = {SuperFermion Team},
  year   = {2026},
  url    = {https://github.com/Catstate101/superfermion}
}

License

Apache License 2.0.

Metadata

Release files for superfermion 0.1.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superfermion 0.1.21
File Size Uploaded Provenance Actions
superfermion-0.1.21.tar.gz 518.8 kB With provenance Details for superfermion-0.1.21.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for superfermion 0.1.21
File Actions
superfermion-0.1.21-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for superfermion-0.1.21-cp310-abi3-win_arm64.whl
superfermion-0.1.21-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for superfermion-0.1.21-cp310-abi3-win_amd64.whl
superfermion-0.1.21-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for superfermion-0.1.21-cp310-abi3-musllinux_1_2_x86_64.whl
superfermion-0.1.21-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for superfermion-0.1.21-cp310-abi3-musllinux_1_2_aarch64.whl
superfermion-0.1.21-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for superfermion-0.1.21-cp310-abi3-manylinux_2_28_x86_64.whl
superfermion-0.1.21-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for superfermion-0.1.21-cp310-abi3-manylinux_2_28_aarch64.whl
superfermion-0.1.21-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.10 abi3 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details for superfermion-0.1.21-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 16.5 MB

Release files / superfermion-0.1.21.tar.gz

Download URL superfermion-0.1.21.tar.gz
Size 518.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5caec3e202b8d54e10258f8f11c9b08243a303575dddf6d5825a62c86ed78e9d
BLAKE2b-256 checksum
How to use checksums
17134e19c80c89758706405d5d781673bda9528e4a1790bf7cb4e192034983b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-win_arm64.whl

Download URL superfermion-0.1.21-cp310-abi3-win_arm64.whl
Size 1.7 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
ad55596bddd3f6a41b95e0fa1e9aba353628babac8fd65cdbedf4a2bcc2d75c4
BLAKE2b-256 checksum
How to use checksums
544d95eca9399be5383a0d00be49bc54bc639326f26565aab5d0fc72a0641fb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-win_amd64.whl

Download URL superfermion-0.1.21-cp310-abi3-win_amd64.whl
Size 2.0 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2d30998c5d2eddf204cb51be0a7ac7dba98f8e53ee1b1919ff6d8927e5885d03
BLAKE2b-256 checksum
How to use checksums
008bdc26be15574b84d037660104098225645145489af9bab2caf2b0f95051de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL superfermion-0.1.21-cp310-abi3-musllinux_1_2_x86_64.whl
Size 2.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
3f1b44599d75789db14f939a2c2bd61bc6526c3960e0958148a589e1933e74eb
BLAKE2b-256 checksum
How to use checksums
febc1afe8973163e28408efed881fc44dfdcf9e09d6dc51ab59a7045c712d8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL superfermion-0.1.21-cp310-abi3-musllinux_1_2_aarch64.whl
Size 2.1 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
7d447ad6779dda8a42e75df817f75978e44f94c46c2f6fbf883fc3b6514b9783
BLAKE2b-256 checksum
How to use checksums
a1720b343d8b3d794745ba4125d0137a0b665575759582c3a5741a9bcd53f528
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL superfermion-0.1.21-cp310-abi3-manylinux_2_28_x86_64.whl
Size 2.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
bc181cbe7cff0171789e14aa60679620926444896d15dc4e0d9acaeb001b7ca6
BLAKE2b-256 checksum
How to use checksums
914a33a9e2c32ca89e99122604e654ada31065a0b713f58464a04073cd5cc268
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL superfermion-0.1.21-cp310-abi3-manylinux_2_28_aarch64.whl
Size 2.0 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
7d31f17786a090a362124ef4f6f16b9ce2acba817304887395130fb70cac2bd2
BLAKE2b-256 checksum
How to use checksums
8c52c9b2249e24e3679f1140ffab1dd25223961d312562dd187bdcb88e978972
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / superfermion-0.1.21-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL superfermion-0.1.21-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 3.7 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fd568fd923452d07c98b59e06dacda2344789bdeb588c33184fb5057dc27767f
BLAKE2b-256 checksum
How to use checksums
e2cc319ef172e4097779eee76a5d2f6c81b23f2e89d5ca931dfce9f24879e65d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for superfermion 0.1.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for superfermion-0.1.21.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page