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.dev1784161823
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.dev1784161823.tar.gz | 883.1 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1784161823.tar.gz
| Download URL | stim-1.17.dev1784161823.tar.gz |
|---|---|
| Size | 883.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ded68f152cd98465060780c83fb4aa7717ce9cc9cacd7b75730556e07e9aaa90
|
|
BLAKE2b-256 checksum How to use checksums |
603f6fcd7a322cdddb8467705f20a7226ee4c244a24e2bf2deb8efb36a1924a1
|
| 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.dev1784161823-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1784161823-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
50df2abc921f6c38af7dacd319b4ee47b4b5066029edb1e280fcbf94a74a1f23
|
|
BLAKE2b-256 checksum How to use checksums |
04705a464ea597684b5a8830e2d1fd7f702963c8de09a1abfc96a0034e4cf053
|
| 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.dev1784161823-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
3039cf36ea904ca84b4bfca664c3c1cea8b18715310d0f5ff954edf55e5f7382
|
|
BLAKE2b-256 checksum How to use checksums |
ad02680c3aff9bcd973fb918544ee8803b222594b36994a326dae6ba7dc5f902
|
| 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.dev1784161823-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784161823-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 |
f05b6725b98c816b7f34d6f92c24c6b1a46fc2f8bb22fe128c7ae8bfdb75cd7a
|
|
BLAKE2b-256 checksum How to use checksums |
e9d2de86b35d11c14d44965b72cd766870fe4c23b223c35b76860da071fc577e
|
| 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.dev1784161823-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
d90cd17665c0212f96cb0ffaeab7d63d0db032ebd4bf63610087194d0f97feea
|
|
BLAKE2b-256 checksum How to use checksums |
4165a69690eb71a3b9e08518b23b04942a9b8d485f6fe63cef33886bcfc6b304
|
| 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.dev1784161823-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1784161823-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
59f4fc1474aaf246703066682d66fe7f80fe818257f914a236600f435df28cb9
|
|
BLAKE2b-256 checksum How to use checksums |
1ca89b3eb90c0a66025e9bf60bb1f5fd3bb34ecca0ab7fa8531e33302107691d
|
| 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.dev1784161823-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
65a20533c42acc75ae6c5cfa013c74beb5e78a2b13406b9f5d716541460dad9e
|
|
BLAKE2b-256 checksum How to use checksums |
ffb605a375296d360ac622caf9c95e2b0f3730e3424cc11e8b19fccd0a706735
|
| 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.dev1784161823-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784161823-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 |
c697d7c0bc6b837f4e1b5d7afa803cf6bbef7f6dfb5dac1a29af35e25c318703
|
|
BLAKE2b-256 checksum How to use checksums |
2e9f198a88b789658352116811c75c4365264068478f798adf3c0a9713376fea
|
| 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.dev1784161823-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
606d15995369af1dbe2e9eaf52c756c1da11f39a0541c968cb07f00f84ed2731
|
|
BLAKE2b-256 checksum How to use checksums |
5fe04deb435ef604d50d1455860f6aba528bf4f3af3a0d985fc5d67de90ae030
|
| 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.dev1784161823-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1784161823-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b51c02a0bd29a46cd326d71f606646a6105bd7b1ee8c621b1cb87d298ea0a2da
|
|
BLAKE2b-256 checksum How to use checksums |
913c6c5406feb1e326dd6f9bdc7a3b79a18886bad7184c1ed7a059bbcd298c93
|
| 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.dev1784161823-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
f38224c33cfb2964a78d2e12a72814742792d5a7d853f5fb19b8dad0dc3bfd44
|
|
BLAKE2b-256 checksum How to use checksums |
bca72d2c00a427a12e8c962527a2bc41a64ef296ac3dd3bbecef5670a9d609e6
|
| 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.dev1784161823-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784161823-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 |
c2b244df262bb4405135d50a04f5b8a8ab256199c84e63c4a04aa0cf2dc76919
|
|
BLAKE2b-256 checksum How to use checksums |
909957e8daa3f1033e79209aa0d81a692b6d07a38bc760b597802fdf2f55d0cb
|
| 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.dev1784161823-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
ba293958590e8f195e5192b87e14174a208a2e76bb82101cdf1734a597d22172
|
|
BLAKE2b-256 checksum How to use checksums |
55f6c97e9c412901c1c598dcb8cdaf3f8a9981e8989165ecc539a14b8c2df9ee
|
| 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.dev1784161823-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1784161823-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d790eb1a0478b6f1821ef229f1b972b27742d65f34a9906dbab6ceb0bc6991cd
|
|
BLAKE2b-256 checksum How to use checksums |
6aad5b5ec29aaf357ed175d80e2f16b877184a35000b0fedd54fe6cb197cdced
|
| 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.dev1784161823-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
2e231ac9310e29fd73f56d8e80aecedfc6208902ab90a6fe27b45ad93c1d254c
|
|
BLAKE2b-256 checksum How to use checksums |
ba990f5a01fb0c1b7c8e0098dd59feb70fb8d83782d7317fa86b635a714ffa30
|
| 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.dev1784161823-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784161823-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 |
948c9dd39d3ada0dd30fad23be52bc8849fdd0fd24122b0320b28b3cf54cb26c
|
|
BLAKE2b-256 checksum How to use checksums |
079c999d3e1335c16a7dc295c37252dc6b49f731ad0b00a5b85e3a98aa8ddfdf
|
| 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.dev1784161823-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
8f62f4241b1c995aa766115b313e3e18b2f352c71189839133790ecb28ec4fbc
|
|
BLAKE2b-256 checksum How to use checksums |
92f0b17cfca849a32339b0a88d324d4667482a7795967eac6ac3e47681dd6ed7
|
| 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.dev1784161823-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1784161823-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bd7c12cceca4d9f4da06161a9fc6762bee768133fee2ad46852b32d7f285f02c
|
|
BLAKE2b-256 checksum How to use checksums |
ad2516b1c1edccacbe7529aae75194d17bd24576c903a54cdaa58846696653e6
|
| 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.dev1784161823-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
517a0042bf6e62e1b0ed62659380a4dc37de70e3d3e29dedbbc2ce498488b85a
|
|
BLAKE2b-256 checksum How to use checksums |
45159280b00ac75f25ff66bf030c835a3a4207c41a011af8b289e381818ad7d6
|
| 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.dev1784161823-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784161823-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 |
8ca8c4a61a5480d2ee15781f49a2a74491c84ee58ec4c794168c223ce997648e
|
|
BLAKE2b-256 checksum How to use checksums |
12922eda1218355af25f0e698aeacd10af1ae07f976961f1a5ef90281c590911
|
| 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.dev1784161823-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784161823-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 |
0c85d1314c34d7aa391139742633d0e893030a658abb523fd7eab528fe7b2790
|
|
BLAKE2b-256 checksum How to use checksums |
0f5270ea1f85ddd4108cc291f928489d5ef98ff6bf98e7f105e4e7b92e66668f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|