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.dev1779429497
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.dev1779429497.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 59.6 MB
Release files / stim-1.17.dev1779429497.tar.gz
| Download URL | stim-1.17.dev1779429497.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca86764bd0a19d9f0175f8f0b7e599f817fd03b326ad2daea9110f6e7c97ae7c
|
|
BLAKE2b-256 checksum How to use checksums |
0bce499836f9ca759106bf4f28f716a20cb6bbb091cdfd4a7734f91c8d1a7d6d
|
| 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.dev1779429497-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1779429497-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a525aae14e50ba419cc238a680f1759259345aadeb047a2056a014f6a9f88383
|
|
BLAKE2b-256 checksum How to use checksums |
52ce3a699006b39878f094381495860866b6e82f8bb9ae2ca7f95b82c16d4530
|
| 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.dev1779429497-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
73219bb739b64bff732eec384f3d501ce436ef192158afc20943675df88a26dd
|
|
BLAKE2b-256 checksum How to use checksums |
f70477e8b94306dc364364b50a465a4381c35e5e7706fbdb3101faf5dde85e1e
|
| 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.dev1779429497-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1779429497-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 |
8a739464e7b4c2167b6c187c0c2c3a48de89ac17503d0f5b0251742016722348
|
|
BLAKE2b-256 checksum How to use checksums |
5af1a70983ab6c3b2f6f2c44a29a747f59624112e7c29fa0aa985a187c652fe6
|
| 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.dev1779429497-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
5a2bc9a43fde631fdb7d6b3bf8027ec0594decc3915aba2c057f9d7121c44f15
|
|
BLAKE2b-256 checksum How to use checksums |
27c11c947099c2b5ff4beacf407ad09d0684caab28346c777ec39cfd3d1a9e6c
|
| 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.dev1779429497-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1779429497-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6367e6243a46edd767387d135853c373c97878d26590ca2acba501744d5ed78c
|
|
BLAKE2b-256 checksum How to use checksums |
d49d74c941a93e89622724888fa7d33f0ec34f2040ac152b2a06df622ac036d2
|
| 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.dev1779429497-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
6b5cd1c5436c2b9650633f9079f446b3e9c8f4b68ecc027d4d7d26034ac55d18
|
|
BLAKE2b-256 checksum How to use checksums |
cdd8d6e5bd86dcbe4c4f2a269ca0f674127fc523fe66e7797416b1b86d2cda27
|
| 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.dev1779429497-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1779429497-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 |
6d3deeb17fe894cce61c84086bd52a428f74074dd19d5630563c389b9235bda2
|
|
BLAKE2b-256 checksum How to use checksums |
2ae5a892921081f4de0bbb42157fac6c177198ca9aae25835089d0e708d3cdf2
|
| 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.dev1779429497-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
67b6dd434d02e8434f25cb1bf39d6383a27ed3941274775fe274d2a1391f3b7f
|
|
BLAKE2b-256 checksum How to use checksums |
213faef7bba0a24bda79b9f60977454bf9a5c0ea7498ca9684578b26a070ab10
|
| 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.dev1779429497-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1779429497-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
873ed6c18d9e35f8fa2282f33e2a80ae77042902898b2f27a8982783d30c62a9
|
|
BLAKE2b-256 checksum How to use checksums |
edf1479febcfd8621c76ce733ae80f07368d6834eecfca0b7cd302754cbdb0de
|
| 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.dev1779429497-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
77268ee8ddd15b338826260a4a23b2c019c3ee4f34739671fa175d0c9c564ef0
|
|
BLAKE2b-256 checksum How to use checksums |
a21ae4a72aa75be3d90630aefacb4b45b87dbe459205d6463233c0b43a425a3e
|
| 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.dev1779429497-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1779429497-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 |
911e2870d8a0d169d34db05d59a892f66c2a8631ffa7a50f799cffe4602b86ca
|
|
BLAKE2b-256 checksum How to use checksums |
c0d92a56216cd1135af0c413c8ca82379456bc0c3a756eed636409c0d01696b0
|
| 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.dev1779429497-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
4399791e4478ad1a4462adedada89be8812d72b139419238ecda1b64728b0384
|
|
BLAKE2b-256 checksum How to use checksums |
62c7f709a3caed21ab6fbd3ffcd63a58b5800d7da770d887890b41ddb0614845
|
| 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.dev1779429497-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1779429497-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fadf087818f36e670cc9ac3d7211ebe93bddd33f3009ae6247185b8d517aedf6
|
|
BLAKE2b-256 checksum How to use checksums |
bdf36e4958ccf3b3211e1a414d6d55d4da3603bba8eaf32d2282482ffbffc18c
|
| 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.dev1779429497-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
198c127c5289f5f180ed0357e14e2c91685304ac615c7d7e108d98ba05284fce
|
|
BLAKE2b-256 checksum How to use checksums |
852dab78c5d81753ddb167988e3b7a6d785baa40d90ac56c4df0a9621decbcbc
|
| 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.dev1779429497-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1779429497-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 |
15cc5276679d9425469b7de4496eb8ae50ba569df85548604faf3b4d7d20422e
|
|
BLAKE2b-256 checksum How to use checksums |
784807ddea811f7fc637ca0dac4d4d91f271e8f4302dbea4c41deef492ee188a
|
| 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.dev1779429497-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
f7eefb043ca437b25d216424b9231952089e77f526b03c0b394f3fadef994ae3
|
|
BLAKE2b-256 checksum How to use checksums |
74f4721f0abfa884e2b654267f9fae4da1861197c8d30c0647d465e0a04dcc5b
|
| 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.dev1779429497-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1779429497-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8f7be382f2a1c93002ccb5cc83dbd437b84a5f62b6e97ea5209be06cbd3c5086
|
|
BLAKE2b-256 checksum How to use checksums |
e588ba2d27fe3ddcb856e7db4a17d3c5d726afdc466d78e79ba613dc8150de51
|
| 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.dev1779429497-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
8a70344a4ff8e28ad19c127e3cb98aebb164bdd3261e43f023da74e52dd113d3
|
|
BLAKE2b-256 checksum How to use checksums |
e02d07b14d80437e36cbdac9e1699ecf5ac80b24c83bc1ceda57a6fe28638313
|
| 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.dev1779429497-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1779429497-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 |
0c53aabe649b0f27fbfa7b14fe68184fc60cc467538884f620cfe81356da4a1a
|
|
BLAKE2b-256 checksum How to use checksums |
0efc3bd09a28f46d89e60a9e1c8c9c9a92f7f68009533cdccce85fe532a97af9
|
| 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.dev1779429497-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1779429497-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 |
ef7995ccab09d60a4f9b4241565a925dc73089dfc9de53c9fb42b4d7c3643f67
|
|
BLAKE2b-256 checksum How to use checksums |
4c2a97ab2d5d81b2f3f351115175ecd1dcea1a247435b75ad52ba210b336d056
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|