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.dev1782863113
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.dev1782863113.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 62.0 MB
Release files / stim-1.17.dev1782863113.tar.gz
| Download URL | stim-1.17.dev1782863113.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dae5bbee6c1b91d5c003328a27d91891f126d65625a839d33a97934cddced1e0
|
|
BLAKE2b-256 checksum How to use checksums |
78d5f6f6af7f5db653c4df84b7970fb97a9f8b2506d2ae363ee6388ef200978d
|
| 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.dev1782863113-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1782863113-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
342ecfe15840a4e89894a0562c6f2a2013d2d8952088cefd71a4042a4f629f6d
|
|
BLAKE2b-256 checksum How to use checksums |
12702bafc001c9e04f73f656d858d2b7ec71f9b5b6efff89c63374419ec8ca69
|
| 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.dev1782863113-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
62d65ab2ea3fb8dd28a3923a2925bb1f13e61e1597201ea1b8022a185d1fba82
|
|
BLAKE2b-256 checksum How to use checksums |
f2548762e8afd3e6a969867308036f2563342932a067644bc83d108f50021066
|
| 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.dev1782863113-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782863113-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 |
7542c7bb223b4e8aef2b3e407639b484c8b93a96ce522d1226e1043a12d809b8
|
|
BLAKE2b-256 checksum How to use checksums |
b0d282b863785b1791338327aff35b0d3fd36a5a4799facaba4075bc696f3140
|
| 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.dev1782863113-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
f94c876dcf776e11017df213fb93960e73197b45f5e6b1a8a94131eb8a52b3f8
|
|
BLAKE2b-256 checksum How to use checksums |
09bc64d55c1867d64cab17019759df70aeb8d6eb6c4b34c376b60a4f6cf7965f
|
| 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.dev1782863113-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1782863113-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
586a9c2a2e469d05bde4abaae184f53bd075b47c2d1ffce1c157321ab866fa19
|
|
BLAKE2b-256 checksum How to use checksums |
1feacee8560bb2adcb428c6fcd2f1a72bffd846a0e50c6d8ef3c1ef695630ded
|
| 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.dev1782863113-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
a0391b26cebef07d320c739aa149f1d67df3bc2585b0c8c74e48a730e6881853
|
|
BLAKE2b-256 checksum How to use checksums |
535dc7075a3444f70fd14488df930f624b340ff42263e0d56c2fe90e98c452ff
|
| 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.dev1782863113-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782863113-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 |
35a080710722ca80920e375a0fab74bd30f3f46f1b43845c820dab200da9fdd9
|
|
BLAKE2b-256 checksum How to use checksums |
a5ad714113880001af0d50276bbad7b71bb3c3f9cef1fe7347b2618deaba37fc
|
| 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.dev1782863113-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
a9eff68b22b74cc2774bcc7bc46c6975f1a96717aadb10cb1a6c3725aff3a5a6
|
|
BLAKE2b-256 checksum How to use checksums |
b2c44864105e8c50eff1ecc35a595291ea657fe91af33319cf1d079bae2a158e
|
| 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.dev1782863113-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1782863113-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
14310f01e2c239c782b16a1720a86b65404a527b10eeb842989d9119db236865
|
|
BLAKE2b-256 checksum How to use checksums |
a7fd6ddda6280dc75f86d534ba3cc3a002a5368981877e062e4a4f62fb25b7c8
|
| 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.dev1782863113-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
4d24f4ec38181ec0bb2c30d6da03807a28f358e41e7d2b4900abe75e2bb9b0e5
|
|
BLAKE2b-256 checksum How to use checksums |
f5f3d6c792f268c132fd37cec7b1de264ae1fbe08602665e0e44a8fd4ff732e6
|
| 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.dev1782863113-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782863113-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 |
ae7248e6811b026d835a5a5bd9c0efb9cbda31691a5375f66c556e24f7a586f7
|
|
BLAKE2b-256 checksum How to use checksums |
84c887a414f83449005907b06fbf0dc13f6728a54087950286cef52928bfcaf9
|
| 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.dev1782863113-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
1ce91d781aa00b930ac5abf6459216286e5fa4a9a1a456c2d4782810b5d3bdfb
|
|
BLAKE2b-256 checksum How to use checksums |
05f6cfc04873e649bc220630314e6d5e184eccaec4c9b6b88c0bc79fa0710a53
|
| 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.dev1782863113-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1782863113-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2a3aa519dea788bb8ea3eaa630f08ab6a04e42b391ee486929f0057a0735414d
|
|
BLAKE2b-256 checksum How to use checksums |
76d4a94fe1de173d13508164f42675da964ff6257c647f033d25262cc39edf41
|
| 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.dev1782863113-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
66b791dc1e3f1aad727b356073637c2fedd864eac1f2bfc03c54157fede6fad9
|
|
BLAKE2b-256 checksum How to use checksums |
f43040f6f40cdfe5dd48adaf9599474a8beaff9b6b0851f730b1445679da08ca
|
| 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.dev1782863113-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782863113-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 |
45fcc47ec7d832be1491abf24c91fb8e814859d9dcd443f2f107221fd06697f5
|
|
BLAKE2b-256 checksum How to use checksums |
d9a2dd3beea7718bb4feb60c75bdb31bcd7b8bca2fd4a240a45cb15f4c243ecb
|
| 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.dev1782863113-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
293535a46ba32a47beaf0f42703436a79f5d36b437cdf32ec7941418c65b1596
|
|
BLAKE2b-256 checksum How to use checksums |
d9302f49d44a8030aca1f0cadff09cd6b4e6ab92e606d2976ff9523df38da1f4
|
| 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.dev1782863113-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1782863113-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5394ace9e0271682325585e6ac1e8ad6ae9ea14213217fdfd8569bbdb316f489
|
|
BLAKE2b-256 checksum How to use checksums |
2f804ac9102fc02ce82d3f2d9d79a3a156016a0c322ab575a77b8f588a48e087
|
| 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.dev1782863113-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
7499641ff17dd2b59c1ba67f13f774208dd9ca766722a6cb5991e04a9e7b1c56
|
|
BLAKE2b-256 checksum How to use checksums |
0b73786af7f66d128938948ae6d78ddcc423902c217c719c70121522baf33427
|
| 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.dev1782863113-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782863113-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 |
b3c19a463c25ccb6d2c1d30ec55b3f7a98419beb47a954b709e64daf30b24d8f
|
|
BLAKE2b-256 checksum How to use checksums |
86b234cc294d663891e55ad47e867bd1772b4dc0b81d610eb1f28a343c27beee
|
| 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.dev1782863113-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782863113-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 |
b4b5a320a5adbe9a334e22b02c7fafcf73b70160a8a8e809a9a209e72d508c66
|
|
BLAKE2b-256 checksum How to use checksums |
7fe944648bcc940a0a6a216db5ae0385dc9059e7c6f15da6c4ea0b4c3f2d3644
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|