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.38.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.38.0
File Size Uploaded Provenance Actions
prism_q-0.38.0.tar.gz 3.5 MB With provenance Details for prism_q-0.38.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for prism-q 0.38.0
File Actions
prism_q-0.38.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for prism_q-0.38.0-cp311-abi3-win_amd64.whl
prism_q-0.38.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.38.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
prism_q-0.38.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for prism_q-0.38.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
prism_q-0.38.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for prism_q-0.38.0-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 21.5 MB

Release files / prism_q-0.38.0.tar.gz

Download URL prism_q-0.38.0.tar.gz
Size 3.5 MB
Tags Source
SHA-256 checksum
How to use checksums
d7e5ef7ebf16ca45d16086400b446e54a93a000a3dea654963067aa996c4386b
BLAKE2b-256 checksum
How to use checksums
0141cdd98e10482af45e70faa7fed305433d1a5041c3e0871c2313ec605bb7d8
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 9, 2026.

Transparency log

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

Download URL prism_q-0.38.0-cp311-abi3-win_amd64.whl
Size 5.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
93822d7ed124e5e5aa07782dfc8df59dbed4d3ee5e5b4a0258fae900981e991c
BLAKE2b-256 checksum
How to use checksums
58dd451aaa4c779a5ebf8a59944a5d8171588cd53636965798fed285793a1eca
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 9, 2026.

Transparency log

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

Download URL prism_q-0.38.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.9 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c164a078214f818a0839510a3c63290bafe7cbb479376f046574eec963d17b32
BLAKE2b-256 checksum
How to use checksums
34149e8426af322f1848eaa18247054b84f6490d83c1a8eb7606bb63a40445f5
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 9, 2026.

Transparency log

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

Download URL prism_q-0.38.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 4.1 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ca963a0031287c1f977dd15ce6d8100e17d4c1580ea641ebb22fde65252f5567
BLAKE2b-256 checksum
How to use checksums
bc022f93be332f4a3dcea9805548a41dbd35fa49202525b54ec3027532f29a5e
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 9, 2026.

Transparency log

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

Download URL prism_q-0.38.0-cp311-abi3-macosx_11_0_arm64.whl
Size 3.7 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2434cf63bd87bc0d7b30927dbd709a691ddcde5e8f4af6a3224775ed87bd1b22
BLAKE2b-256 checksum
How to use checksums
8512907c2e137f53d8bdcb9181fb3700b364db140555263ab31a178e689ef66c
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 9, 2026.

Transparency log

Security for prism-q 0.38.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.38.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 9, 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