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.dev1780910265
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.dev1780910265.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 60.9 MB
Release files / stim-1.17.dev1780910265.tar.gz
| Download URL | stim-1.17.dev1780910265.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be2923cba01ae58ade11e5f77a6e29ad97d07eec859aa3d0ec862792f692b62f
|
|
BLAKE2b-256 checksum How to use checksums |
f86c4c4747807e2658976aaed76d10798df94d6a7ad83f850ddd315f5cc9a307
|
| 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.dev1780910265-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1780910265-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
57c935a4a55b93f4d0d0ae5fd8325e563d86770f311ee29d8ea0a59ca48bf4bc
|
|
BLAKE2b-256 checksum How to use checksums |
e37292bcc234cf1bbf35b6bd1ee5a873cfedba6b23ab8c96b5e372eb13bdfe07
|
| 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.dev1780910265-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
79637f3aedca65c1a74b4768a32441566282fcc5b3a4784b2102828f93504d77
|
|
BLAKE2b-256 checksum How to use checksums |
009b2eddd7452d5b32aed61d365d6fa42509f2903b4cab003688e74cf58bbfe7
|
| 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.dev1780910265-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780910265-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 |
e179422030eeba16768fb6df3427caed18cdb0819a906d0438708a6d19a0dbc7
|
|
BLAKE2b-256 checksum How to use checksums |
52a1f2d6a6d8e81dfd9852f5270f6f10bf5b2c35df3c16068f45e04719b94e24
|
| 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.dev1780910265-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
f835ccae1470400a87fba8ebe3d5388195e8b86ebedbbcbab3d0b18bc8a0739b
|
|
BLAKE2b-256 checksum How to use checksums |
e166c8767c8a4fbcbbf6019cdb32ec3c204c6285c1e64ca96b66e16e1021c5c6
|
| 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.dev1780910265-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1780910265-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
149f0ebf94a3f618d46c47604c090e8e7725c4ffee27f65861a33d728f7c5a8c
|
|
BLAKE2b-256 checksum How to use checksums |
fc629d740a1d17f54aa679586fa0fe9e4b724b343dca3d8b748894494c6a3273
|
| 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.dev1780910265-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
71b36a9ad9c4459c26cf15777f39558a913dd5ff1c6716a4c7db5f14d0526e9c
|
|
BLAKE2b-256 checksum How to use checksums |
4608ac405edc8446899bf82a1f1093da43e755e6f219184da99581a406d4477b
|
| 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.dev1780910265-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780910265-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 |
ea8ab7bb036fba727ee2f226da3278346fab94a89d9c8442a099b596d21b9861
|
|
BLAKE2b-256 checksum How to use checksums |
3fa39bd02271c2272e75f19be56714f3a1160d3887925395ae4f0864254bc8c0
|
| 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.dev1780910265-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
92236f4118a02a627a652e9cb9f590d75da89531b4a8f5e76927d6b9ea30a680
|
|
BLAKE2b-256 checksum How to use checksums |
19ffe077aae94697110c423cd2c657a1c82c520ceff4305c1d7c5e2a97c7e93a
|
| 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.dev1780910265-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1780910265-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bf156429ebc531c563d213aea5753ffc3ab88d59aaad1ca02f49cb7038394197
|
|
BLAKE2b-256 checksum How to use checksums |
ce9243b3ba676c61915c59bb7e937bd678fe0e2c58b02e1e0d71449d01bf030b
|
| 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.dev1780910265-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
201b6dc1ef488b79453e2a0e1fefb584d6ba0240dbc162669c5599a1f6debded
|
|
BLAKE2b-256 checksum How to use checksums |
51c4d4cc17e1ea2d704bc791d77b611ce34b522b5294f1cd25f7a066c0f55a93
|
| 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.dev1780910265-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780910265-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 |
fbf68a1e905b56698ef8c97915d082f94650b6e1c2bed1cf4973a60007ec6b25
|
|
BLAKE2b-256 checksum How to use checksums |
db54a8220621502e868f3de3994f0a67fa722751781b52fe9205985dac15cf26
|
| 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.dev1780910265-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
75bfb77eb8786450763ea35317a5523b845e5e46d11ed1c2ec74cc330e348ac9
|
|
BLAKE2b-256 checksum How to use checksums |
7bb59223bda16ebaba9d8856165844565fbbd81a335d039a67860079f34dfbe3
|
| 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.dev1780910265-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1780910265-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
df3ddfafa3db59d57ec88e85bad985927f2291c3d5fa95f3c12f66f67deca4d8
|
|
BLAKE2b-256 checksum How to use checksums |
fd5c6861bb2c894614df9f3ef312f8d4b24424278ba8cfc6367372da60ce7933
|
| 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.dev1780910265-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780910265-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
dd98428bcc1f6ccc70f46374896759fe60dbc51bd7593c36a8e884d5412852ab
|
|
BLAKE2b-256 checksum How to use checksums |
7702c46cde7ca193f5029e34feb49ad9736a431e50cc360844deaf93b74d9e02
|
| 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.dev1780910265-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780910265-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 |
c69c0465690bd8c4da430407a193296412f2c280a36fc77b26a46616c116d324
|
|
BLAKE2b-256 checksum How to use checksums |
4588f6898848bc3a97d51139e5da3f6916918b76ae7d5b996a5a709fcfd79db2
|
| 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.dev1780910265-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
cfe788d5bb6649bc13fd1f70abcabd4282f063b07efac7c6bd038def43fba2b8
|
|
BLAKE2b-256 checksum How to use checksums |
adb986215a9ab2fd9ed5fb6fa6b3344dbfb2ec8e2cc466d5b987c7b90234290c
|
| 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.dev1780910265-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1780910265-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ca928d2969d0eabcf8d4a675ee9e101007eff2341021d3fd05ba378586cd560a
|
|
BLAKE2b-256 checksum How to use checksums |
488c9c38fc071a33ad0411521a147db97222753c281d3753e721b31bebf3fcaa
|
| 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.dev1780910265-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
bb380c1f200565ad0cc8b46d43be6478e935e8def7d3a084549f45712b0ea52b
|
|
BLAKE2b-256 checksum How to use checksums |
30baecb2e104d26cdec5988c63428121915a0b0f4fd926bbb609aeff669adb0c
|
| 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.dev1780910265-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780910265-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 |
06f3c9ee6f5af5f3a9b4f49e64d00b3bb108f81d00c91bdf9b0ac5786c585a08
|
|
BLAKE2b-256 checksum How to use checksums |
c0af97f9de09ef99e6a52a63238873dfc4f288ac93c4078ed20a98abc53e0f9a
|
| 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.dev1780910265-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780910265-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 |
63bfbbd46db186abbf93b1c4416ed61e62192add52b68af689c285c0fec1bea8
|
|
BLAKE2b-256 checksum How to use checksums |
6e693a211780087af427ca3e8f646e15a8d91f98fa7e2e89fcf080ec935ead44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|