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)
Metadata
Release files for stim 1.17.dev1791581592
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.dev1791581592.tar.gz | 885.3 kB | Details |
Built distributions (wheels)
Total release size: 62.1 MB
Release files / stim-1.17.dev1791581592.tar.gz
| Download URL | stim-1.17.dev1791581592.tar.gz |
|---|---|
| Size | 885.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e1d25895d4661ab2e02973353fb2d65b2d219285eacf14e4eb246f795cc4fa2
|
|
BLAKE2b-256 checksum How to use checksums |
055ee09552d422ce3c2c5c673986f1a259f0161bb5e593baa1ce9c943cb87641
|
| 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.dev1791581592-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1791581592-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ff5a354849ed2ad6f367818c29c414123c51033e92cd6c72a8c7ea1322447b89
|
|
BLAKE2b-256 checksum How to use checksums |
5227cce758265586fa430bcbe8ddbb5a5f636580e640abf24664ae71a071841f
|
| 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.dev1791581592-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
42564572ab5aaa3dfe0cad758a2a9b075db2215152c1f8d8da7fb60be263bd2e
|
|
BLAKE2b-256 checksum How to use checksums |
caf37400d4d3a93da2f9fe684fbf5ed06bc11a7e1e0b4f54dbcfa5eb3b5270fe
|
| 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.dev1791581592-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791581592-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 |
c1207a2c4c5efa03a7e766901b92bbf5f4d3f42732f572fce31c4907fe787eaf
|
|
BLAKE2b-256 checksum How to use checksums |
1b5d9fcf3ee525700f89437549ff5d6fc871e0d27c4ffcb8266e2f97aa88e261
|
| 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.dev1791581592-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
34e71e1aad119d573eb74eb77b8574a40474175133ef6e688a3f999a6b7cca13
|
|
BLAKE2b-256 checksum How to use checksums |
07351a2578ed18e5f34ed756ab8b1d0ebfbae0515be1ff7279b35fc2c0cf9abb
|
| 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.dev1791581592-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1791581592-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
048009ecc44f63bf9c2eb7b299c35b75a87034294abc3d8bd252ca36bb69c89f
|
|
BLAKE2b-256 checksum How to use checksums |
965ffd99a60605b83319495d9204cd0a09ff0bdb4a5f24506a5732913c3bcf19
|
| 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.dev1791581592-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
78df938cd0a548cef5d001c8fd5072445f3f12842d8464f41f89798aa61adc1d
|
|
BLAKE2b-256 checksum How to use checksums |
0b44d30cd8affb3efd83746709e53670a702f1a44199c0c52e40a17b4b04a397
|
| 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.dev1791581592-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791581592-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 |
cc712b18a5a2c64e6ce93628be5c1616946c91787edbb166d3198f66de7eb87a
|
|
BLAKE2b-256 checksum How to use checksums |
51487cc16add618ba1340ae8afe106bba1dfc7305c995624688a3f12f4adabb2
|
| 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.dev1791581592-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
f1a323bfc89d4015a6beb52e38b034788deec81df0f7c3bd3d11e5403dfe0407
|
|
BLAKE2b-256 checksum How to use checksums |
09b3a1494b5f67d6e0939cc2487cc8eda695d927976ab7349b00a7521dec29cf
|
| 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.dev1791581592-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1791581592-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
99a16c74d652f8328005ee7b098f066d6f9e3fe5cd5ac386b0caa4992d41845b
|
|
BLAKE2b-256 checksum How to use checksums |
1b06d639aec7baba7d8a31c63f194a4109dcf15ede41eabd98543a59c4a6b304
|
| 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.dev1791581592-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
6c342daaeba407e45c7d34057ad2abb300147f15baa1a4316e72412d4a1035ff
|
|
BLAKE2b-256 checksum How to use checksums |
8ed2c2d9516c4d2db99879bc3ab97b2ac6d9c998f1d8dcfb56f70e77cba6f334
|
| 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.dev1791581592-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791581592-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 |
06b86fb7031eb7c2aed6726e2193529a0814b46c9fd1d5291fe01246aacbac72
|
|
BLAKE2b-256 checksum How to use checksums |
a1998dab0751f62d3ce2bc534aabb2ea20b2a14a7c707adade460c4ed3fce915
|
| 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.dev1791581592-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
118431d0e3a2fc7db3867c98c2de3b7f8f14e0a9d008ff0319cc78a0511007ab
|
|
BLAKE2b-256 checksum How to use checksums |
ef92359f75aa88af9e9c8f9c25be1f25814422d6e57775ac156fa0929bae2d8d
|
| 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.dev1791581592-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1791581592-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
407672b8df164d1e4e76aa53026cb2bdf22c018baa494ac9d4d109882800a196
|
|
BLAKE2b-256 checksum How to use checksums |
90a0d013b89ac2789e8d3d3728384fdfbb44093a675baf2c47559ac05c5ce244
|
| 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.dev1791581592-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
bc4525228462c114eed1adfd4a58a82085226ff38e37f716320cb7babc97fe79
|
|
BLAKE2b-256 checksum How to use checksums |
08b71c7cd3fe6fac0169c1d907380c08b81390346fcf48ef90a78f0c54acf299
|
| 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.dev1791581592-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791581592-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 |
e80f483f6704d282832b45040220a2eda8f87fbc320410f3d457ed12867323e9
|
|
BLAKE2b-256 checksum How to use checksums |
88bb9be8e7d1e48a1f5d0b44e6257fd4dcfb5b4204fdfa1aad5dbda4d360effe
|
| 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.dev1791581592-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1791581592-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
4d6f34f9c98e4ab07c4b9a98273bc55565dde06bc7ebbaa34df15c3262d845cc
|
|
BLAKE2b-256 checksum How to use checksums |
89b6e323bcff5921cc6db88a2d6ccfc838135ad947229f4b12936914141b7ce0
|
| 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.dev1791581592-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1791581592-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a246ee5a90856c847e5b1e0052611d5b1eebc5886a8ac096a6f4243c5b5f6bf0
|
|
BLAKE2b-256 checksum How to use checksums |
3c80d7b75d15b1d41d0ad2bb87f03eb3232b44691e463ca57f065d89a2eaa7fe
|
| 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.dev1791581592-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
1947992c3401795dcc7fc6caacdafbea1fe7cfd8bbbcf8b0a4449ffa9db53ce3
|
|
BLAKE2b-256 checksum How to use checksums |
86289ae1969c8ef6d7fd408da497e86545ea8c568f493851b3efae2523d43d94
|
| 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.dev1791581592-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791581592-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 |
3852500537bcd5d5f50e094efb163449eebaaeee6458683bd94302d6c0047dd7
|
|
BLAKE2b-256 checksum How to use checksums |
e7f05696f6f735f9ef027e9d41e1527435bc677e1c7d2164b337b0e7350db7af
|
| 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.dev1791581592-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1791581592-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 |
20937798de9473482cbb44fe1dac20d8a2f9e1c62df6085f194a5f871f1a8692
|
|
BLAKE2b-256 checksum How to use checksums |
8ef39cd73a78407bfb8b0df6b0cb03a381dd9aee2e05905f179c873865750e50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|