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.dev1780897841
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.dev1780897841.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 59.6 MB
Release files / stim-1.17.dev1780897841.tar.gz
| Download URL | stim-1.17.dev1780897841.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71370a7db3144bfe047c38ac6e65506326ed8ab9de58a7240d66b4823a318c9b
|
|
BLAKE2b-256 checksum How to use checksums |
dac6ce83cac749343be8f0aeabdd262f17e3223b63fa5247bcca79c897d31bff
|
| 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.dev1780897841-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1780897841-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
120d00b01c4ba1e744c7687d6ae7fc4fa7607d7202c059c19238215410226a44
|
|
BLAKE2b-256 checksum How to use checksums |
a15700461b241142dd5e5f69f5be29b7e5f51a099200abe0ac111c17dfad033d
|
| 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.dev1780897841-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
5aa41211c79d0528382083f8a850b27f94c52132b82976dea0c3b6fc0039ee89
|
|
BLAKE2b-256 checksum How to use checksums |
6d6c7a2fb3d89ac8fb0b8bcb43e530f10e302cfb2d8d6d3ecfdbefbf0bdcb608
|
| 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.dev1780897841-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780897841-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 |
9a19bf037d8c99e2488541f9980ede90623dd2f8ec0f72353a5eafe643d6572e
|
|
BLAKE2b-256 checksum How to use checksums |
29486b8802584246896149bdc184c99385a7d5622ebef1a7d149ecfdfc102530
|
| 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.dev1780897841-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
3060629dd7136cb3b893510ebc4730f8fb8dc1e28df943969c3826dcee883ddd
|
|
BLAKE2b-256 checksum How to use checksums |
66d40ffbc9408b408e1e9c640e5d6136cd06cd7d38b40a75a5fabf575b64b220
|
| 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.dev1780897841-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1780897841-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f7313a1c174433b988d40d7dd0d3fc553f81567cc73ab76f9a9d452e29d73100
|
|
BLAKE2b-256 checksum How to use checksums |
71f46aa9590b8c6426ff0340d2ff034b595ebecc3273578ac05f80f62d2eda83
|
| 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.dev1780897841-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
a0a8d9d2563b0e97c4684652e824e851e46388400fed3092fbb8b747cb92d348
|
|
BLAKE2b-256 checksum How to use checksums |
a60d8c44f44817a270e9bb118935fbfaa70edc7c626e50350077e135ae46089c
|
| 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.dev1780897841-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780897841-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 |
5c1e7ba36deefb420d492f5ef2a7f4acc990b3b0678aae20daf2615e18f85178
|
|
BLAKE2b-256 checksum How to use checksums |
bc5b7c81966c93ab12d3aadc448e9fd8d90f76e771e727494d38f0c3ea57b0fc
|
| 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.dev1780897841-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
8dd50859e22b28cec3e2c8b660e92547dffae0d2ded46c846dc85438b7b700bd
|
|
BLAKE2b-256 checksum How to use checksums |
cbb359d1a71dac4b1606b10e919eaf18c6da1f2dc05582357f2879ea47d459d0
|
| 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.dev1780897841-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1780897841-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
280990f9b0a29360bc3b5b950d71b66145233c16205ec4e11abc5ff13cc01a1f
|
|
BLAKE2b-256 checksum How to use checksums |
04e732ceb7933fb568d1e71f201199953bca7725dbf61b84553534ff0222001d
|
| 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.dev1780897841-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
99c9a6e16aeb31403b0807add4cf09e5d0f23be727d4f9e484ccef1f4b77b9c8
|
|
BLAKE2b-256 checksum How to use checksums |
ed1f291c402f149111e27e79c715c471d3701f0268f08304c02ba55af346534e
|
| 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.dev1780897841-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780897841-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 |
b3c6f259da57921fba7057477f04ce05f06647cef3a6f623a991864119215733
|
|
BLAKE2b-256 checksum How to use checksums |
8649057cc0ddf4189ef0c291dd5c1125d8f7d4ef39dac1eff59d7577cc2a3757
|
| 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.dev1780897841-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
30d5ce03a733eef179e8b8b04fc6927c466288e005a5f2797fac444d381fc606
|
|
BLAKE2b-256 checksum How to use checksums |
cfd9767d4e5aa486338cf90138998bc967bb1f0a2e1d28400ec978b42de6c7c1
|
| 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.dev1780897841-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1780897841-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
27e21698093907bc17b3cd6dab0cf64199219617ae493356de5e232bb9ae8a2f
|
|
BLAKE2b-256 checksum How to use checksums |
24193b12183ee13213bdac33dd78f8bb540c2f5f341643146a7aa0f75748b857
|
| 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.dev1780897841-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
6b4b3b8cd38622ae0009fcae71aeaafd9a8c29e826eec04edcae21014804d9f5
|
|
BLAKE2b-256 checksum How to use checksums |
bccada62a2af29d95169a55fc67629a70f5036953b6304f576dddabf3d7f1f41
|
| 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.dev1780897841-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780897841-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 |
e33730cbf2da093b4f1c4752d31482772ddfa4b53616926beadf1d14345165b9
|
|
BLAKE2b-256 checksum How to use checksums |
6ffa572e8be45710128475f0245b3b2e17a586bfc452e77c7e043bba2ba3b554
|
| 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.dev1780897841-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
052e5de87f0e7e9ee98986254063324600879db5689fab99e2f81768170c4299
|
|
BLAKE2b-256 checksum How to use checksums |
8d3a8253c551a652521f34bda0500c1b38bb6948128693288ecae887f626ad9d
|
| 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.dev1780897841-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1780897841-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e78a11ab7871e4b09a014733c3e2172a1066a3ad13b869a921800584ac7bcbff
|
|
BLAKE2b-256 checksum How to use checksums |
f5916294b673530fc68b160dc52058435e34347a6aeaab3b83dbe28b0ee24071
|
| 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.dev1780897841-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
1aab79108e7c36f4868f439a9634b1ec35cbd4fec0c4495c2fd0cefa31684b15
|
|
BLAKE2b-256 checksum How to use checksums |
98b816f41b1fa4c007506b1d5674c0ffe13aa040ae3467bf02939c30988118ce
|
| 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.dev1780897841-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780897841-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 |
510f9d70e3dc190c2d50185237c6c316ce32512efda0498c6ddf15888f96488a
|
|
BLAKE2b-256 checksum How to use checksums |
5d36c40b4a82ec9954afcd18f8681016ee4b6b213be1262086d280252cafb6e2
|
| 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.dev1780897841-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780897841-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 |
2b03e4c9779f61e6e205769841e7d23869bfeb60a8af5c6b8d51a714916ef3c7
|
|
BLAKE2b-256 checksum How to use checksums |
a45c6a5f7ffe578c39aba92dc1318901e24818fda2142f211d9cd374176250bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|