Skip to main content

PRISM-Q for Python

A quantum circuit simulator with a Rust core. PRISM-Q picks a state representation from each circuit's structure: a stabilizer tableau for Clifford circuits, a dense statevector for general ones, and a sparse map, matrix product state, product state or factored form where the circuit allows. The result names the backend that ran.

Install

pip install prism-q

Wheels cover CPython 3.11 and newer on Linux (x86_64, aarch64), macOS (arm64) and Windows (x64). Other platforms build from the source distribution, which needs a Rust toolchain.

Quick start

import prism_q

# Exact probabilities of a Bell state.
bell = prism_q.CircuitBuilder(2).h(0).cx(0, 1).build()
print(prism_q.simulate(bell).seed(42).run().probabilities)  # [0.5 0.  0.  0.5]

# Parse OpenQASM and sample shots. Counts are sampled, so they move with the seed.
qasm = """
OPENQASM 3.0;
qubit[2] q;
bit[2] c;
h q[0];
cx q[0], q[1];
c = measure q;
"""
result = prism_q.simulate(prism_q.parse_qasm(qasm)).seed(42).shots(1000)
print(result.counts())  # {'11': 493, '00': 507}

# The exact statevector as a NumPy array.
sv = prism_q.simulate(prism_q.circuits.ghz(3)).seed(42).state_vector()
print(sv.dtype, sv.shape)  # complex128 (8,)

Why the backend choice matters

from prism_q import CircuitBuilder, circuits, simulate

def backend(circuit):
    return simulate(circuit).seed(42).run().metadata.backend

print(backend(circuits.qft(16)))    # Statevector
print(backend(circuits.ghz(1000)))  # Stabilizer

ghz_t = CircuitBuilder(60).h(0)
for q in range(59):
    ghz_t.cx(q, q + 1)
print(backend(ghz_t.t(0).build()))  # Sparse

A 1,000-qubit GHZ circuit is all Clifford, so a stabilizer tableau holds it. One T gate on a 60-qubit GHZ circuit rules out the tableau, but only two of its 2^60 basis states are ever nonzero, so a sparse map holds it. Selection follows structural rules and host memory, not timed trials, so naming a backend with .backend(prism_q.BackendKind.statevector()) and its siblings can beat it on a circuit the rules misjudge. metadata.reason names the rule that fired.

What the package covers

  • CircuitBuilder, OpenQASM 3.0 parsing and export (Circuit.to_qasm), and text, SVG and Jupyter circuit drawing.
  • Classical control on measured bits (ClassicalCondition, guarded with an else branch) and measurement in a Pauli basis or of a Pauli product.
  • Circuit generators in prism_q.circuits: QFT, GHZ, QAOA, hardware-efficient ansatz, quantum volume and more.
  • Parameter sweeps without a rebuild (Parameters, PreparedCircuit) and adjoint gradients.
  • Noise models (NoiseModel, NoiseChannel, two-qubit Kraus channels included) for shot sampling.
  • Compiled Clifford samplers (CompiledSampler) with streamed marginals, parities and correlators, plus analytic noisy marginals (noisy_marginals_analytical).
  • QEC programs (QecProgram) with detector and observable sampling and feed-forward corrections.
  • NumPy output for probabilities, statevectors and QEC bit matrices. Circuits, parameters, noise models and QEC programs pickle, so they cross multiprocessing, Ray and Dask boundaries.

GPU

The Linux and Windows wheels include the CUDA backends; the macOS wheel does not. Nothing CUDA loads at import, so the package runs on the CPU anywhere. A GPU run needs an NVIDIA device with a system-installed CUDA 12 driver, and NVRTC, which the cuda12 extra installs from PyPI:

pip install "prism-q[cuda12]"

Without a driver or NVRTC, only GpuContext(...) raises. prism_q.gpu_info() reports the device or why it cannot be used. MPI-distributed execution is a Rust feature and is not in the wheels.

Bit ordering

Count keys and measurement bit indices are LSB-first: the leftmost character of a key is classical bit 0, and q[0] is the least significant qubit of a statevector index. Measuring q[i] into c[i], the state with only q[0] set reads "10...", not "...01".

Documentation

Contributing

Bug reports, questions and pull requests go to GitHub.

License

MIT OR Apache-2.0

Metadata

Release files for prism-q 0.39.0

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

Source distribution (sdist)

Source distribution for prism-q 0.39.0
File Size Uploaded Provenance Actions
prism_q-0.39.0.tar.gz 3.5 MB With provenance Details for prism_q-0.39.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for prism-q 0.39.0
File Actions
prism_q-0.39.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for prism_q-0.39.0-cp311-abi3-win_amd64.whl
prism_q-0.39.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for prism_q-0.39.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
prism_q-0.39.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for prism_q-0.39.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
prism_q-0.39.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for prism_q-0.39.0-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 22.5 MB

Release files / prism_q-0.39.0.tar.gz

Download URL prism_q-0.39.0.tar.gz
Size 3.5 MB
Tags Source
SHA-256 checksum
How to use checksums
568588fd93ea9da12f0757e753b2e7d9a60716a5c6fe8c9c53a58e413dc21497
BLAKE2b-256 checksum
How to use checksums
d030d7b66e4255819a6afc9ade212152ec6338cf4ceda176085ff1800832b04c
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 Nov 23, 2026.

Transparency log

Release files / prism_q-0.39.0-cp311-abi3-win_amd64.whl

Download URL prism_q-0.39.0-cp311-abi3-win_amd64.whl
Size 5.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
64ac9e90d88d36c820cf7305800850301200ecf25dc53525950957ce2a3af9ad
BLAKE2b-256 checksum
How to use checksums
6316f2fc4271b1e4b1524ff2dc1299c8f9657a6e1e1fa93a69923066ea742cb3
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 Nov 23, 2026.

Transparency log

Release files / prism_q-0.39.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL prism_q-0.39.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 5.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7a6b770301a24af1feb7e6827e3a8d4877d26712f79aab02d9b100eeff07092e
BLAKE2b-256 checksum
How to use checksums
199e1c2409f97f308d5532cd095da8fd9a6e404d0be20fe387feebb03386692b
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 Nov 23, 2026.

Transparency log

Release files / prism_q-0.39.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL prism_q-0.39.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 4.4 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
fa540d0975a5ecc797dabbba91abe069e57b994a7ed422c067039cfee87c517c
BLAKE2b-256 checksum
How to use checksums
f1501d01f8e67f61c4e183eac3ee2837245b476748df7832db6d1a316d7c178d
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 Nov 23, 2026.

Transparency log

Release files / prism_q-0.39.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL prism_q-0.39.0-cp311-abi3-macosx_11_0_arm64.whl
Size 3.9 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2f55749669fc3ca24a52a5fc1eaa6dbab3ebf9cd3771c22383a3ad509e04a410
BLAKE2b-256 checksum
How to use checksums
33cab4018c249efddd8d8a2114d5c463f6e00142d94ef83bd897827094ded7e1
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 Nov 23, 2026.

Transparency log

Security for prism-q 0.39.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 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for prism_q-0.39.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 Nov 23, 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