This release is a pre-release and may not be stable for production use.
Stim
Stim is a fast simulator for quantum stabilizer circuits.
API references are available on the stim github wiki: https://github.com/quantumlib/stim/wiki
Stim can be installed into a python 3 environment using pip:
pip install stim
Once stim is installed, you can import stim and use it.
There are three supported use cases:
- Interactive simulation with
stim.TableauSimulator. - High speed sampling with samplers compiled from
stim.Circuit. - Independent exploration using
stim.Tableauandstim.PauliString.
Interactive Simulation
Use stim.TableauSimulator to simulate operations one by one while inspecting the results:
import stim
s = stim.TableauSimulator()
# Create a GHZ state.
s.h(0)
s.cnot(0, 1)
s.cnot(0, 2)
# Look at the simulator state re-inverted to be forwards:
t = s.current_inverse_tableau()
print(t**-1)
# prints:
# +-xz-xz-xz-
# | ++ ++ ++
# | ZX _Z _Z
# | _X XZ __
# | _X __ XZ
# Measure the GHZ state.
print(s.measure_many(0, 1, 2))
# prints one of:
# [True, True, True]
# or:
# [False, False, False]
High Speed Sampling
By creating a stim.Circuit and compiling it into a sampler, samples can be generated very quickly:
import stim
# Create a circuit that measures a large GHZ state.
c = stim.Circuit()
c.append("H", [0])
for k in range(1, 30):
c.append("CNOT", [0, k])
c.append("M", range(30))
# Compile the circuit into a high performance sampler.
sampler = c.compile_sampler()
# Collect a batch of samples.
# Note: the ideal batch size, in terms of speed per sample, is roughly 1024.
# Smaller batches are slower because they are not sufficiently vectorized.
# Bigger batches are slower because they use more memory.
batch = sampler.sample(1024)
print(type(batch)) # numpy.ndarray
print(batch.dtype) # numpy.uint8
print(batch.shape) # (1024, 30)
print(batch)
# Prints something like:
# [[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
# [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
# [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
# ...
# [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
# [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
# [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
# [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]
This also works on circuits that include noise:
import stim
import numpy as np
c = stim.Circuit("""
X_ERROR(0.1) 0
Y_ERROR(0.2) 1
Z_ERROR(0.3) 2
DEPOLARIZE1(0.4) 3
DEPOLARIZE2(0.5) 4 5
M 0 1 2 3 4 5
""")
batch = c.compile_sampler().sample(2**20)
print(np.mean(batch, axis=0).round(3))
# Prints something like:
# [0.1 0.2 0. 0.267 0.267 0.266]
You can also sample annotated detection events using stim.Circuit.compile_detector_sampler.
For a list of gates that can appear in a stim.Circuit, see the latest readme on github.
Independent Exploration
Stim provides data types stim.PauliString and stim.Tableau, which support a variety of fast operations.
import stim
xx = stim.PauliString("XX")
yy = stim.PauliString("YY")
assert xx * yy == -stim.PauliString("ZZ")
s = stim.Tableau.from_named_gate("S")
print(repr(s))
# prints:
# stim.Tableau.from_conjugated_generators(
# xs=[
# stim.PauliString("+Y"),
# ],
# zs=[
# stim.PauliString("+Z"),
# ],
# )
s_dag = stim.Tableau.from_named_gate("S_DAG")
assert s**-1 == s_dag
assert s**1000000003 == s_dag
cnot = stim.Tableau.from_named_gate("CNOT")
cz = stim.Tableau.from_named_gate("CZ")
h = stim.Tableau.from_named_gate("H")
t = stim.Tableau(5)
t.append(cnot, [1, 4])
t.append(h, [4])
t.append(cz, [1, 4])
t.prepend(h, [4])
assert t == stim.Tableau(5)
Release files for stim 1.17.dev1784096857
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stim-1.17.dev1784096857.tar.gz | 883.1 kB | Details |
Built distributions (wheels)
Total release size: 62.1 MB
Release files / stim-1.17.dev1784096857.tar.gz
| Download URL | stim-1.17.dev1784096857.tar.gz |
|---|---|
| Size | 883.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
920c089dbc0360d3da9a181e25a649fa1a1633ae909c414d66d1114832399d78
|
|
BLAKE2b-256 checksum How to use checksums |
31550c617dcfdb60c0f8b7cacf1f0ec07394757f1b42fd24ff143bf736cd6c66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1784096857-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8899dd9ffa1ecff94e766f9c96fd4ae286d56595ccc6f5ad367fc952a3825a67
|
|
BLAKE2b-256 checksum How to use checksums |
62fb04f1b76aa070cc5b7bb7878305b0846533655e25f53634bd8ddf049c026a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a92a15b802cdf7f7aaac54764916ca74a212583ed23dde93028c205facd11a01
|
|
BLAKE2b-256 checksum How to use checksums |
8604d8888421f5fca7189067446432ae50146563ca69b45f78dc07a9351597fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784096857-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2ad0a85853a1b49376134345f047dd4f04fa3fcfc5b7b69896266087401dff7d
|
|
BLAKE2b-256 checksum How to use checksums |
0c98b4ac0d4cc7762d0b5ad99781a6a5cc8373920268b22f7ab5b5549bf9f087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
612ebd7c443c8ce619421d216b1b0e510be73ccf9bf46301ffdb00465cde9957
|
|
BLAKE2b-256 checksum How to use checksums |
8b741b0954c7e665ff2e91f410fa230e6499e01643137ca6f339aedb4a977608
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1784096857-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
78753fb0e46945e47312a05b568d8ae29b045d468918b46584b807bedb7f0adc
|
|
BLAKE2b-256 checksum How to use checksums |
d4b7edcb0382209a2f1f3bef10bc518b7fbfd10466854863180b9b45988e7aaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
61ea96eb179caad762cdb63ea0cb368f7b7988fabee22ac5b97284446a3b4a0c
|
|
BLAKE2b-256 checksum How to use checksums |
fe1c3b379a47d66388804911cef4fa442222b6d575d92800e0fe22f298a669e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784096857-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2cc50b1732da85a19de866a4ee69f357a7f7784c6ecbb5a3a88382702b77ab73
|
|
BLAKE2b-256 checksum How to use checksums |
72f8a0fbc5fe5de1b4ff2afd3acc559bc7fbf0bead555eae75234818f5a584f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
0175e26a09a629902e8cc5c95d953463c16336ccb04624e09c95b0093a74a4d8
|
|
BLAKE2b-256 checksum How to use checksums |
cd7d3ca282e57180bf96c867d1a38955c8093bb89af1933bf5a0a8a83217dc6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1784096857-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4e1d7b7deeab6b56bfc979782ffbbeeffdd167ea3ce93b30c7618c2475cb64f4
|
|
BLAKE2b-256 checksum How to use checksums |
6f491a2ddc85ccece63c715a2abd077c355e333ddd5486d7c7c04ac208649806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
0e55f310cf9fc431814d9a17d8963a6c891b01d1ca35b0902a7bcdef75c5b8f0
|
|
BLAKE2b-256 checksum How to use checksums |
f0b0a0f65e9422b33730449f25db15936bd56a2bf99f33832463034451609aa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784096857-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
837beb710e48362959d88cb5c83f4c778c47bc1a5830c6732761c4fa342c058e
|
|
BLAKE2b-256 checksum How to use checksums |
03956c7151bbf96642bbac3784cbba4bfea0717d8e2c750c3cbe5eef68f13854
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
e4fdd69cef60abed15d76a88f5c16893a75659d650c680719dec3d7296ea4638
|
|
BLAKE2b-256 checksum How to use checksums |
092e97c1f4e060c04c9474459336476e412d0d8db39b0a5fb281e2a78d0f22ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1784096857-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6b82dcb6139e82310248bc4b1a5c50c90c8ffe0c4c364c6d400dc0add05d18b5
|
|
BLAKE2b-256 checksum How to use checksums |
ca2f492d2001ab558be6e9b07102796fbfc3dbe9c9a52f415be9d64d2110a750
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6e2fa2b9c98bd8b24aec72b4487da76a0622d4056e160547949b23b8387497a1
|
|
BLAKE2b-256 checksum How to use checksums |
31e20580c866125ee9f49dbf786976888d7ee944ffc80db5d940b75fcdcbcca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784096857-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
62bd8c8490331d1ff5a34bf83dbaf65c26b90a12f12be49b26d96caf086a9b92
|
|
BLAKE2b-256 checksum How to use checksums |
0db7b178bdedcd1b72a21a2ded41b7ab7ba122c48d0f5531601a9d6c4f7c0a96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
76929e9a587f2a7c57c7c330829f06c45edc82cae41fb8e03c556f135256c2b7
|
|
BLAKE2b-256 checksum How to use checksums |
4f824bb025b01d142eeb699bf31fa290afc1cc7ecf783c2708a5f9b0e8b1f0fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1784096857-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d6eb168ea9534528acff0f7487cbc36a84ae84ae395796daddd92a816b31ccdf
|
|
BLAKE2b-256 checksum How to use checksums |
ee1980e716f1986ea133202bf5e7a65fcda357bde8df8217cbdf49d817a8d626
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
19554052d4f6110b539608bdc17da99379a40a2396a298a57dc68ffbb47201cd
|
|
BLAKE2b-256 checksum How to use checksums |
7a90895a840d1831ebfd44f5ad4a69cd59365ea5da6529681aa18d33b43f95c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784096857-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
87d189ef0f1342e14fbe2232c2577b8f46f500a30ba4998b842663c59aacb0a1
|
|
BLAKE2b-256 checksum How to use checksums |
108aa4994577c2ddb3a816f7a0b384fd4dc3883a2c390c9d3fe3e1d2897f66eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784096857-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784096857-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
c6ab4500f4332c710e2160df37018ab29865bfea5487971f2781bf8b020c531e
|
|
BLAKE2b-256 checksum How to use checksums |
61b0f406f6904b8ea2c18553f9ebf6f3cb86847dd2191904d4b46a2b20187296
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|