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.dev1789789184
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.dev1789789184.tar.gz | 883.8 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1789789184.tar.gz
| Download URL | stim-1.17.dev1789789184.tar.gz |
|---|---|
| Size | 883.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44e222f66705bf38640eaaf626ce3d7d3d6eba30431ebcaf6da3e39aae2e0875
|
|
BLAKE2b-256 checksum How to use checksums |
a6edef316a044550b32a34ac0068518b17467d4caff1fa45bd55c17dbc1fa381
|
| 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.dev1789789184-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1789789184-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b66a9536582130d7fe718824f0eec8dc3141de8b742c3166fe60eecfa6505bb6
|
|
BLAKE2b-256 checksum How to use checksums |
c38578ec91c4f8373995fd30b1896b10173fed553434e18d210e51e883d9680c
|
| 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.dev1789789184-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
816d37f77a2e2e9e4a9ffcdcafb17e862a5793ea6c7eb1e94b1c0b04fbc10c32
|
|
BLAKE2b-256 checksum How to use checksums |
4bdf25c201935fe05b16a455b168365f18c40482d4a6aeb6ca1ac984bc63158c
|
| 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.dev1789789184-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789789184-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 |
6615141bab5d51ea84afc1f8cf794749d2185bb9787462fc432b529bfff51ece
|
|
BLAKE2b-256 checksum How to use checksums |
1da415a04a0639dd5a14c3c31c523abf491adfe2d2e2c4ff2eb23dce8bae6460
|
| 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.dev1789789184-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
6796d87a73a58a313c8f0d413e633e820a27b30b0d4d179590410248528cc9f9
|
|
BLAKE2b-256 checksum How to use checksums |
50711c4cc0c46e9e260196ddefef5111e858eab1ffed0f339ec85cd3a4a3ab23
|
| 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.dev1789789184-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1789789184-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5c4ef1e6d1fd9e42a12aba589b7737a0a8e03e7efc9e82f8f61041f2610d9b2d
|
|
BLAKE2b-256 checksum How to use checksums |
41e2a691f9563e400857078326295648ac563416d069f5384c82033b9103c7ad
|
| 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.dev1789789184-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
961f4cd49fb2cac3fad902441337e76d451a86c9569f607219b2b5a2860d5f90
|
|
BLAKE2b-256 checksum How to use checksums |
259a84df4e3b1a09bfbf89c821f0337b865a6411695f91f99c9739bd0fefb1d0
|
| 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.dev1789789184-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789789184-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 |
320d87ea14055a3d83f0691864c17e030d1eb7038a49a2ca5a16de580b4fa993
|
|
BLAKE2b-256 checksum How to use checksums |
88e34b606bdba7fcc09bed13720856a379e76a8c82baf14e02101bb26fdd005a
|
| 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.dev1789789184-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
403b41afa4a36bcac494698d3818ce5f24715b91d534bef5c5b8cc82f033a7a6
|
|
BLAKE2b-256 checksum How to use checksums |
8e011c735d0131095e7ed09aeba9bab56f0445f02e013d9825f088b5173a9f84
|
| 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.dev1789789184-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1789789184-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3aa009b2bcbdfb6c416f0034e0e76ebdb3bf791b2a05328e73cce04b12c1490e
|
|
BLAKE2b-256 checksum How to use checksums |
aa914d8d4819c8d847f1f77e8e1f5a396099a3c9deada46e750739f74a21bb3b
|
| 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.dev1789789184-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
e6a970dbce7f31d734bf20deafddea4b2429374a5eaf3797533b59f360a079de
|
|
BLAKE2b-256 checksum How to use checksums |
64c206aa6272b890201315e2bea612b2389661011a1f487dd47144681826f0ac
|
| 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.dev1789789184-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789789184-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 |
0de9c102dfaeee9cd21662b660cf0653d218178a891fc4f04a7cb512d2c15c6f
|
|
BLAKE2b-256 checksum How to use checksums |
8c2ee907dc1e2b193b93283297b0d93e739bfc827026e3708e09432ff07c0bbe
|
| 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.dev1789789184-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
ca4c10342a3ae4a38e6580ca415efa57c16997bcd0cb9c2afa2b36f25d311bb5
|
|
BLAKE2b-256 checksum How to use checksums |
43cda3b0b9aa21a85391719bc47ab59f435bebb53e76d04ccea2441ee6dec91e
|
| 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.dev1789789184-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1789789184-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d2cd74b01e260e44d28526b4853e12f1299dd2ead7d35de153cbca536d4513b9
|
|
BLAKE2b-256 checksum How to use checksums |
7408b60188e53ba8f1d59f0211d3f49008470c2e55d0a8643278e1ef7021bc0d
|
| 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.dev1789789184-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
5c7b9d09ca8d8ef225251ad8a90a7dc3ed253afd2f923859173fd6d4c1c42d9e
|
|
BLAKE2b-256 checksum How to use checksums |
7f54bd77c7bea36a45719d7806f8b561852d7e3194dda73b8466a73028be0fc7
|
| 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.dev1789789184-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789789184-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 |
f453c13eb8fa9d20f7fd0520f4070e82431bf13ee56225bba76bec4bfde2c341
|
|
BLAKE2b-256 checksum How to use checksums |
0f2ae7ed098454021adc942b86b3102a27161ca3cc062a09f139ebc75e845143
|
| 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.dev1789789184-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
c28e3a0f28bae388447b2b781d81ae622f5d6a45e04b435dbd51905180c33146
|
|
BLAKE2b-256 checksum How to use checksums |
e94a9903d1d62f4067b8c6c3259abe5448be286f01fecf771fa88f97016e93f8
|
| 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.dev1789789184-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1789789184-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bbade96e0b9494932ccc6bddf110e468e35bc487035969361e1d5858013c7fad
|
|
BLAKE2b-256 checksum How to use checksums |
3a50b8417fc46a85e25d0b7148a14f82a20c598b11b6ad0eac202f4f2b3ec241
|
| 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.dev1789789184-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
f9979d40caf14e5f67e8fb1a9fceb1ce357ecbef3e4ed6d466011d0fb359c1e9
|
|
BLAKE2b-256 checksum How to use checksums |
dea90158150600ae93d2484de59d0e6445ed870d3c055832a59afe0e7bcc69bd
|
| 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.dev1789789184-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789789184-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 |
7ab94538008eb4b8ded63b06c4102f0b5ef1b321cab74f438ddd01def97b0624
|
|
BLAKE2b-256 checksum How to use checksums |
ad4660fb13dfacfd0ca1826999775a6018822c8da047ec4cda3b648f9036015e
|
| 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.dev1789789184-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1789789184-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 |
811c67078643e8b1ff8931508d968c6401adf804e855ce1d5e9acc127f98846d
|
|
BLAKE2b-256 checksum How to use checksums |
b8ca7eb11c58dd665fc0a4bf98b4821aefa11cd639fbcd6bdcb3f2eb2e46a958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|