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.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stim-1.16.0.tar.gz | 882.5 kB | Without provenance | Details for stim-1.16.0.tar.gz |
Built distributions (wheels)
Total release size: 60.9 MB
Release files / stim-1.16.0.tar.gz
| Download URL | stim-1.16.0.tar.gz |
|---|---|
| Size | 882.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9092a996429dcf616d8d4ca01fec886b7b310caf9425a39fcfe499005636bd52
|
|
BLAKE2b-256 checksum How to use checksums |
77bdc0f5d6241cdb806400a63e0c7febe22982ddf1c8761142bb0ea6b51d3f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp314-cp314-win_amd64.whl
| Download URL | stim-1.16.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ed3aa70f82690946ba6f70abb9dad448d49ab9499fa5161de5f286da87c30ab1
|
|
BLAKE2b-256 checksum How to use checksums |
f585be0fe295a5c5426aec0a2f8497360d9db8083d62c04de81bf744d29a131e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.0-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 |
f94040cbeeff786e7fb8860249e54d9ba3f777b5b098d21f1eccd072d3a3c32a
|
|
BLAKE2b-256 checksum How to use checksums |
fcb28535802f6eb5230678b067cde35b81fc612c612698f192b31164c6a19b9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.16.0-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 |
1fa60a13ef921d6e6aea420e2fe7551d71a4a07b513d86da89e39259dd3739f9
|
|
BLAKE2b-256 checksum How to use checksums |
b2d1a898d8e587a8718daabaf886f2d0c22c126a691886765096a0776b5b463c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.16.0-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 |
1e78fe10ab4c28af9ceb57ac8ed895f3efcde9607d851ef931c53d1f6f80bc8e
|
|
BLAKE2b-256 checksum How to use checksums |
5bf84266593404f455c676bfe95785f865d77e98578fc4a35af9835653a65598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp313-cp313-win_amd64.whl
| Download URL | stim-1.16.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
55231457b5897b0ef798059aae01d9e8247fc8b2089e8a27f9f4bb13b0342af2
|
|
BLAKE2b-256 checksum How to use checksums |
d715db7f4b80a0903e0962f5d824ca8cb5a962836399bd45fda59961782ebb20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.0-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 |
f22a009bad1e7816aeb70bdeafb6789e4840710da070f69cde91e2ac6cf1e800
|
|
BLAKE2b-256 checksum How to use checksums |
ddd16a9bca80b6ffe0fc4a3b0375ac18ff9fb1e815d152691332e55d1a9e5fa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.16.0-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 |
66dbc6532169df84d127ceede353b15445e845a94aa008c5d0a4062b51cc2b02
|
|
BLAKE2b-256 checksum How to use checksums |
21409499fb076b819b479bffad35afd34e84a93c86f117fb5431dab211adff4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.0-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 |
1822adb4920f4616b253792fe1893ad07a9bea8cbc45b2f4cdf7c75a8083cd00
|
|
BLAKE2b-256 checksum How to use checksums |
e4cfaeb85a75eca23907ba32c09c95340489a60ff608a9a18ebd26b9ae2e2323
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp312-cp312-win_amd64.whl
| Download URL | stim-1.16.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
85b9c544c65377a42c6b5c9a57616a5ed5580e1cabb286a604800a045c7a12fb
|
|
BLAKE2b-256 checksum How to use checksums |
bb650ddfa6f76c4a137aefeee4d51a65945e0ec77cc2221322f13a5768f4c488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.0-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 |
883b24c3c95fa69818e931e8b60daf4fc8195d159d321e7548d8706dbac16558
|
|
BLAKE2b-256 checksum How to use checksums |
e471db565f5bd0f273414e90d85551eed1c75f7b689847bd605a7cf0c4c0386d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.16.0-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 |
b8580dfbe5ff27594dd15a83b24262630b82cf089d1463d29dbee90ffbc6898b
|
|
BLAKE2b-256 checksum How to use checksums |
51e345a8c0889f4629027cbdd8ed8e9f5824b5bd8b12b0f5d24be27ec0c2a3dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.0-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 |
3e2883216fb4f57411531c99dfa1838c0d8201c619ccd01b197b9afd54d326cf
|
|
BLAKE2b-256 checksum How to use checksums |
20d98b70c39860e67e233178a9ef595c15a7ec718f0b88bc424ae2c6ad8f97da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp311-cp311-win_amd64.whl
| Download URL | stim-1.16.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b367f90826e796417932ea46c0e53d80e3c5bebac0c6633c0aa07a8fcaa4298b
|
|
BLAKE2b-256 checksum How to use checksums |
b887a845b9d17ab5e352eee30169a58bd8213e85ff47c6340daff2f8a25ed28e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.0-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 |
bd2d28093818f981f8dedb2be160b62d818279b81748d72dc4fca6cdd160291d
|
|
BLAKE2b-256 checksum How to use checksums |
d4d8a84d59b49395e4f8e080991915929c69e1e6a40c411a9c0998904dbf8bef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.16.0-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 |
1890bda08adfd6daa875d1d5e41039c5ae8c58faabc7cd1813f8d8de9f1536a2
|
|
BLAKE2b-256 checksum How to use checksums |
be373742215d5fd4e090ce7ae964e43d978d1ac9865b5865530a6d5f1063a124
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.0-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 |
8d44f858f3d5d1107e674886facbb011ed85438f0888278d6aa3c1f42d9e5a5f
|
|
BLAKE2b-256 checksum How to use checksums |
3f1d3619629c01407eef4042c22299afaf8d3f5fc3b0b26c98ffb4cd86f7cc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp310-cp310-win_amd64.whl
| Download URL | stim-1.16.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
609666b77197d45705e1579a9840123a53cebe614e8bf1d496c0df24f797e653
|
|
BLAKE2b-256 checksum How to use checksums |
4c434e5036fdc3c8bdfb4d774a4fff0cb8a0f44609ae18aa858ae37f61649cd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.0-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 |
41c02d52af847e0ab886c35751e8f7e17e2e0d055e390ece93a50a12dcf87e56
|
|
BLAKE2b-256 checksum How to use checksums |
c53090d9ed81b10c4850e108b81346c2c6e2784126945342d591272ed090e027
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.16.0-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 |
84b777678cc12e808b3d6747d57e07eed951f8ec18047a936dfa25dbc950a2e2
|
|
BLAKE2b-256 checksum How to use checksums |
71ccf7ebbe95361ce7b5c5da47ce024543846d6aca9fbbedd6833aeb33dccf15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / stim-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.0-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 |
d467b5599de7e171651a1ff7fac353dd64d78df75d9c63e7d870d576eb0fd64b
|
|
BLAKE2b-256 checksum How to use checksums |
2ac4b2cb8ed667da891b4835826eba3cb582c577ccc6980f15fd0e84d5e6491e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for stim 1.16.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.