qsengine
A state-vector quantum simulator for Python. You build circuits in Python; a Rust core runs them on every CPU core or on any GPU, and hands back the results.
pip install qsengine
import qsengine
qc = qsengine.QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
print(qc.run(shots=1000, seed=1)) # {'00': 513, '11': 487}
Documentation and guides: qsengine.kaiwave.dev
Why qsengine
- Fast where it counts. Small circuits run on the CPU with almost no per-call overhead; from 14 qubits up, the GPU takes over. On a 22-qubit benchmark qsengine's GPU backend is about 5 times faster than Qiskit Aer.
- Any GPU, nothing to install. The GPU backend uses wgpu, so it runs on NVIDIA, AMD, Intel and Apple GPUs through Vulkan, DirectX 12 or Metal. No CUDA, no vendor toolkit.
- Works everywhere. Without a usable GPU the same code runs on the CPU, in full 64-bit precision.
- Small, plain API. One class, eleven gates, three ways to get a result. Mistakes raise a normal Python
ValueErroron the line that made them. - Built to learn with. The website walks from bra-ket notation to a complete Deutsch-Jozsa run, and every example on it is real qsengine output.
Install
pip install qsengine
One wheel per platform covers CPython 3.9 and newer on Windows, macOS and Linux. A GPU is optional.
Using it
A circuit has a fixed number of qubits, all starting in |0⟩. Gate methods record gates; nothing runs until you ask for a result.
import qsengine
qc = qsengine.QuantumCircuit(3)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.run(shots=1000) # measurement counts: {'000': ..., '111': ...}
qc.probabilities() # exact probabilities of all 8 basis states
qc.statevector() # exact complex amplitudes
| Gates | Methods |
|---|---|
| Single qubit | x, y, z, h, s, t |
| Rotations (radians) | rx(q, theta), ry(q, theta), rz(q, theta) |
| Two qubit | cx(control, target), cz(control, target) |
Bitstrings put qubit 0 on the right, the same convention as Qiskit. Pass seed to run() for repeatable counts.
Choosing a backend
Every method that runs a circuit takes backend="auto" (the default), "cpu" or "gpu".
| CPU | GPU | auto | |
|---|---|---|---|
| Precision | 64-bit | 32-bit (within 1e-5 of the CPU) | 64-bit below 14 qubits, 32-bit from 14 |
| Runs on | every CPU core | any NVIDIA, AMD, Intel or Apple GPU | whichever is faster |
| Without a GPU | works | raises RuntimeError |
falls back to the CPU |
The full API, every error message and a guide to each topic are in the documentation.
Performance
Each run simulates 5 layers of (H on every qubit, RZ on every qubit, CNOT chain) and samples 1000 shots. Best of several runs on a Ryzen 5 5500 with a Radeon RX 6600, Windows 10, Qiskit Aer 0.18.2.
| Qubits | Pure Python | qsengine CPU | qsengine GPU | Qiskit Aer |
|---|---|---|---|---|
| 6 | 2.2 ms | 0.11 ms | 1.3 ms | 3.7 ms |
| 10 | 30 ms | 0.30 ms | 1.2 ms | 5.8 ms |
| 14 | 740 ms | 2.4 ms | 1.3 ms | 11.7 ms |
| 18 | 16.2 s | 25 ms | 4.9 ms | 19 ms |
| 22 | not run | 1.03 s | 70 ms | 367 ms |
Below 14 qubits the CPU backend is 7 to 60 times faster than Aer; from 14 qubits the GPU backend is 3 to 9 times faster. Above about 17 qubits the CPU backend is slower than Aer, which fuses multi-qubit gates. These are one machine's numbers: reproduce them with benchmarks/benchmark.py.
Limitations
Version 1.0 measures every qubit at the end of the circuit. There is no SWAP gate and no mid-circuit measurement yet, so algorithms such as teleportation that branch on a measurement are not possible. A register holds at most 30 qubits (16 GiB of memory).
Building from source
You need a recent Rust toolchain (tested with 1.88) and Python 3.9 or newer.
git clone https://github.com/kaiwave/qsengine
cd qsengine
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install maturin pytest numpy
maturin develop --release # build and install into the venv
Tests:
cargo test --release # Rust tests (GPU tests skip without a GPU)
pytest # Python tests, checked against a NumPy reference
To build without the GPU backend, use cargo build --no-default-features for Rust.
The website lives in site/ (Next.js, static export, maths rendered with KaTeX at build time):
cd site
npm install
npm run dev # local preview
npm run build # static site in site/out/
Project layout
src/ Rust core and Python bindings
engine.rs CPU backend (64-bit, multithreaded with Rayon)
gpu.rs GPU backend (wgpu compute shader in shaders/)
circuit.rs QuantumCircuit: records gates, fuses them, runs them
python.rs PyO3 bindings for the qsengine Python module
qsengine.pyi Type hints for editors
tests/ Python tests against NumPy
benchmarks/ Benchmark script, results and plot
site/ Documentation and learning website
docs/RUST_GUIDE.md A guide to every Rust feature the engine uses
Licence
Metadata
Release files for qsengine 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qsengine-1.0.0.tar.gz | 39.4 kB | With provenance | Details for qsengine-1.0.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| qsengine-1.0.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for qsengine-1.0.0-cp39-abi3-win_amd64.whl |
| qsengine-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for qsengine-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| qsengine-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for qsengine-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| qsengine-1.0.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for qsengine-1.0.0-cp39-abi3-macosx_11_0_arm64.whl |
| qsengine-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for qsengine-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 10.5 MB
Release files / qsengine-1.0.0.tar.gz
| Download URL | qsengine-1.0.0.tar.gz |
|---|---|
| Size | 39.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9a955b4b2c135a566807bb93651b0fd5fb3797f588d2dc8ba07a62d4d937c5a
|
|
BLAKE2b-256 checksum How to use checksums |
301ae51b298170fbff4c91426ba96c1edc35a09e14e10e284ec2c16bdb03d793
|
| 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 29, 2026.
Transparency logRelease files / qsengine-1.0.0-cp39-abi3-win_amd64.whl
| Download URL | qsengine-1.0.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c414a075781bcd3bfe538b32e6a5dcac8a923ce2aa29db13ae66b159ec7abf0e
|
|
BLAKE2b-256 checksum How to use checksums |
8850cd60cadd8e8b8f1cf6766c89d6c67991db61173729b34226edc25b3b1ab7
|
| 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 29, 2026.
Transparency logRelease files / qsengine-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qsengine-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
876e71ff803ed00c84d32d27bba0101cfff7308b4606277808c9f10586cff5d6
|
|
BLAKE2b-256 checksum How to use checksums |
e553920d8ac5fb75bd518aaa0c4d4daeecde4d1f9e431093205ce31e14fe87ff
|
| 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 29, 2026.
Transparency logRelease files / qsengine-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | qsengine-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b22fe757bbb839c036d82686cfa9d1581f2f26861107d650e193e240e9c8cf20
|
|
BLAKE2b-256 checksum How to use checksums |
b2770dd71d56b3f4261619ab135611066d4884bd12c47c3c96c3b5edb2dabd83
|
| 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 29, 2026.
Transparency logRelease files / qsengine-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | qsengine-1.0.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b8811aa3cebe0da02caa3b5086b5a46a838d9887c72112620f5b02746106bb21
|
|
BLAKE2b-256 checksum How to use checksums |
6d697fbc09a21298d596c218c45a092d4c78913d8511f9028cdf338c718c1646
|
| 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 29, 2026.
Transparency logRelease files / qsengine-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | qsengine-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2eb9a296cde17b8bd6e25f69ecc2338e3586dfda1fd6e1075eca42e032023b8a
|
|
BLAKE2b-256 checksum How to use checksums |
4047953ad7f2553de2f4a4c690279b5871f9dac5aaf9f6e3030c1f6549dd655c
|
| 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 29, 2026.
Transparency logSecurity for qsengine 1.0.0
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 6 files in this release have been uploaded with provenance metadata.
Attestation for qsengine-1.0.0.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 29, 2026.
Transparency logA 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.