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.dev1790038003
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.dev1790038003.tar.gz | 883.7 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1790038003.tar.gz
| Download URL | stim-1.17.dev1790038003.tar.gz |
|---|---|
| Size | 883.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfdd1b3bd85acb002290176e2ec633b19f74018207c212c6388c6905011cc3f3
|
|
BLAKE2b-256 checksum How to use checksums |
a6a3e0028f6f810dba841be274a01cd23d03bed051c3485113e0148c17ed68b7
|
| 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.dev1790038003-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1790038003-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
353e53e0ccf8034d4725770ef9556fd7fabd1b14d0f538368a401c2df4867487
|
|
BLAKE2b-256 checksum How to use checksums |
8c2f24e01bd3973ad1f53fde18d46bf41f166aec9b8c7ffd0ed094d87c0f24d8
|
| 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.dev1790038003-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
9a945129cc73737bdfb354ce6f5b77540d2711bb0829bcb27fb843183ef41862
|
|
BLAKE2b-256 checksum How to use checksums |
7a857545e23ca69c6fafe429672d66010c3de6d65cc9978c6fa39f2ff9de8354
|
| 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.dev1790038003-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1790038003-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 |
16d8a07467aed5e687a0fbcf90230a6f1c7250e50c3dd3d3671b0fd4d6e4d689
|
|
BLAKE2b-256 checksum How to use checksums |
fcdd8ab1ec41f4839cd047dc5821e8ae64ddbba78dee6a66e44c8c463f59cb88
|
| 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.dev1790038003-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
6736b4e147df03dc65d6ec88007e3628bc827e57a03e8bc6118f2cef98195bbe
|
|
BLAKE2b-256 checksum How to use checksums |
8707645dcc3c4c7510364312ad7fd99fbcb19cc7eac14596f7b4c49767091857
|
| 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.dev1790038003-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1790038003-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b42bd45d01046a599f430f6858e8cab5ab1e756b4a0653f60c00a2a23f582e21
|
|
BLAKE2b-256 checksum How to use checksums |
2537032664c9e0b2ae07591a49890b3212cf55d2f63de14316a3fcb59e30ceca
|
| 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.dev1790038003-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
16f9e358556afa8bb161da3448cc62b9262e9e66015cb8020b2e9c83d474e18a
|
|
BLAKE2b-256 checksum How to use checksums |
c7178cb5dc5872ed39431b62b292a77eb522c135ea7ecacdbcfe271ebc0b22af
|
| 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.dev1790038003-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1790038003-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 |
dab21dac498b25c0c0ceac86e0af1e624ae0fcde3da677a66b37f6586afc6363
|
|
BLAKE2b-256 checksum How to use checksums |
6f83d5cda8566c3a38ba00b6931d2c92032f628079f5d0b5ec096bbccfb5ce65
|
| 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.dev1790038003-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
ae63129ec7832724d59ff2f91c4e7a6630aa7556908ea6509bec42ef69bbae97
|
|
BLAKE2b-256 checksum How to use checksums |
87ec2920caa253619526ab0bfca557da302aa583cd90c3a6351e3b108c0f87e5
|
| 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.dev1790038003-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1790038003-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f0dfb7f192abc3069cfd4f28bf3e6da6e8a7f50365468e8abb72b18750b71355
|
|
BLAKE2b-256 checksum How to use checksums |
659ff06790e4f6f15df7be7ab1e9d12adaa217640c97f7aebfe0a379adcb1e14
|
| 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.dev1790038003-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
819d7c0128882923377fe0a9eaa07531b3afd16cec1ed30bc1cbb34d442fdc1c
|
|
BLAKE2b-256 checksum How to use checksums |
735c6c7da8c814b58b9db2992294598cdb62dcf6db3c35280b26e7201f46cc90
|
| 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.dev1790038003-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1790038003-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 |
33f4528fff92f217c43b7b0238a58f89dd027b50d0878cc95fad1be18f7dbc7e
|
|
BLAKE2b-256 checksum How to use checksums |
1e9ccfe7a6d9255651a7942ede572f09743c36475b4e332878f0bf7e67b786a9
|
| 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.dev1790038003-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
53cc2696e0cd620c02615ebae9bd66b715d0c9dbcac68039bc33e9b0ef8bf02f
|
|
BLAKE2b-256 checksum How to use checksums |
940842d045db341e9002fb222c9d2f7eaab0cca3aca248a51faa6fca44d179a2
|
| 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.dev1790038003-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1790038003-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c0b0a9fd430be2efc38951193cc8a15524ee5996c968766f840242db34f4e635
|
|
BLAKE2b-256 checksum How to use checksums |
246cacb8f4bf281e2962043716b4bc609967ce9023c987ac927e5a6908ac41c5
|
| 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.dev1790038003-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
a7f7256c9795a7ef9d62e24bf46cbebff488880633712f4950c0bc8dc9de2cf2
|
|
BLAKE2b-256 checksum How to use checksums |
57c73decbe7c37355f72c9976bd5ac5c1da40a99c846c02cfee4d10a4f3aebea
|
| 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.dev1790038003-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1790038003-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 |
09f9c32c66bae35048166b7ff243fb6a26507dcfab6b4beccf96de2d3e7ba965
|
|
BLAKE2b-256 checksum How to use checksums |
e81d1004fee0298c68aa85396f6ec00b8ffc230eb303e1e2395edf39c4a5efdf
|
| 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.dev1790038003-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
eb130a3b7a68980a0e5b0847e7493443399d9544217714d4b4c76885513c6e57
|
|
BLAKE2b-256 checksum How to use checksums |
011fcac1aa10101fa6520e9e9addfafb092f8ca8d10abfd633568c78b68f128b
|
| 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.dev1790038003-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1790038003-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b87043f436f55a3a0bb74a48d05ef60d2746745f1a96791019c477bfb6c5d3c1
|
|
BLAKE2b-256 checksum How to use checksums |
3adea320c5b58aa874250947e4a2cec73733c046d73b2ff4e829d4cf068933dd
|
| 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.dev1790038003-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
4f9b8bf74d3002afc795d6968e14ef054e3a26ffb0fbed9687e606c49884ef18
|
|
BLAKE2b-256 checksum How to use checksums |
1710c32357e4b07c28c9ce0561eac9a6694b3b70878187a26f271144f4f9b9c2
|
| 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.dev1790038003-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1790038003-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 |
3358a90429883949ce11a60ebc8edf83bb81f438fd05d07085b1608abd0f79f5
|
|
BLAKE2b-256 checksum How to use checksums |
06724686c7d050884a3fa62730b10bbbfc47b23a0c100cf27c7247b9198661b8
|
| 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.dev1790038003-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1790038003-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 |
e22f724820aa9699c506dd8f5bf795237599fc8a49500d41061a0912a269d2c1
|
|
BLAKE2b-256 checksum How to use checksums |
9f08b69f66baa7407ba30ba196db5f2e0f268b3b6e235c59be2da0057abbf06c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|