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.dev1783227814
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.dev1783227814.tar.gz | 882.8 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1783227814.tar.gz
| Download URL | stim-1.17.dev1783227814.tar.gz |
|---|---|
| Size | 882.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
112b81e1370f346be1c1487cdb4420f1e948df856733c9867cc230156ed748c7
|
|
BLAKE2b-256 checksum How to use checksums |
540a83128f3d59391fb836fe0220fcd7405b39fd07de7144b39a274193caa5eb
|
| 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.dev1783227814-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1783227814-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d4ee2a7c9cd2a6321df76fe77bc79359993971742542d25cd34fb670d16a0a01
|
|
BLAKE2b-256 checksum How to use checksums |
5f4b75de98cb9d5fe132fcdee701004433a3d7f81d85299eace69cbec1c50983
|
| 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.dev1783227814-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
6ddae56e064a9eb17885f5e8c9d6aa905b13438765ab1abd68bc136050375a59
|
|
BLAKE2b-256 checksum How to use checksums |
d544e5a145dc06e7f932215635ec4f2dcb568158767735717ab45257051922fc
|
| 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.dev1783227814-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1783227814-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 |
dc516cd28665b08ca82c8c2c55db0a31a4c1e593a42810f87bceb0eee59b1130
|
|
BLAKE2b-256 checksum How to use checksums |
6644758fb10ffbf32bcc6bb3d1d7f0f0c599db0108faa20517fee5a361926949
|
| 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.dev1783227814-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
7a2916c481b70654d4d0442916a43c6e3b609fd7fa13cb9f8620dded36a7c135
|
|
BLAKE2b-256 checksum How to use checksums |
162a13b0a090548934f92b630567acb78ecbfe0b9750aeb24802aef88f4992d8
|
| 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.dev1783227814-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1783227814-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
14462a8a07acbaf9f6f06454e4e246c03f32305936e2addb984599aa3f6c66db
|
|
BLAKE2b-256 checksum How to use checksums |
872312522392acb0696aafa3b94eac673babc19ea03b6eb2cd7c649271757aa4
|
| 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.dev1783227814-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
828223ea01dcb0a6ebe12efd56a35066ebe4c336f49f86e2c1b6dfc03da6f08d
|
|
BLAKE2b-256 checksum How to use checksums |
81af7dc3ac2e112b3e7208a737227ffa4015896b59ea179c8bcd62174042d7fa
|
| 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.dev1783227814-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1783227814-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 |
f764aec60c37d8ff98eb7522bc4050d62f7a3ec33dabace5b870b519beebd08a
|
|
BLAKE2b-256 checksum How to use checksums |
e1416887576a005f2e753927df32959c89681e7be71e40167b43ecac6cf06f84
|
| 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.dev1783227814-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
160843af4b315e3ee9be7b9794d743066a1dd13734f1a04132ea47c6d50eb823
|
|
BLAKE2b-256 checksum How to use checksums |
ac0004adf704f92d4549ad73e1b60883673d956cbabe2520194d7f24e674e188
|
| 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.dev1783227814-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1783227814-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
86811fb8be6ae0dfa71983cb9d05b0e49b4b7afc7f5c94363616936205d2b26d
|
|
BLAKE2b-256 checksum How to use checksums |
8445421118a1f4b235173559ddaf6cc96b158366532647d606825988639e11d8
|
| 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.dev1783227814-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
748c26bb9a0e585a3c8e4ee207effb727268f69a70ed44561d77f79f502d817e
|
|
BLAKE2b-256 checksum How to use checksums |
c4f210e27a4c23f0704928ca87f97040f7400b0ae34e3effcb94e64411f4bea1
|
| 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.dev1783227814-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1783227814-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 |
9320d6cb6badf9a000e11c5ae2f92aa4853c16b6d58284e50b5a8cb2d42ed8a6
|
|
BLAKE2b-256 checksum How to use checksums |
e52cb9abe061697de53fa483528583e203ab7b9ccd7c6e947c73916651540fe8
|
| 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.dev1783227814-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
5a31de7c0718c047a16081e4a6aa2cddebfe8a4c2795049934a584b7a5e45bf7
|
|
BLAKE2b-256 checksum How to use checksums |
f2e747664bc385d87aedaee0dd08427413685a441b59424fffcde17c8d2b6de8
|
| 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.dev1783227814-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1783227814-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8138a727be6f9321dee7c47ce318c2a3e394e83823aa4a902428d9db7bd593bd
|
|
BLAKE2b-256 checksum How to use checksums |
67e1993358b40118d0497516721b065918279578f9730a241524db053f7f77bd
|
| 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.dev1783227814-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
f28551235aa6b2fd8e4c00e7ad5330c17806643cd6155de577ed02febb0696f8
|
|
BLAKE2b-256 checksum How to use checksums |
060ad36bac59b0fabd69ef0c5e373f4f6b072441266e95c654a37b1913a3205c
|
| 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.dev1783227814-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1783227814-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 |
319cfa83bdba890c7bfccc5ab45aa47b9798084529a37f649069e765d7c87816
|
|
BLAKE2b-256 checksum How to use checksums |
f93525d6cbec253798b6f908d5146b857cac176a549bdd45e6f40edbce6ff82b
|
| 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.dev1783227814-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
66013a574294614f7119f644183386854c4ab8298025133d67ec98ea1e1cc0aa
|
|
BLAKE2b-256 checksum How to use checksums |
631f8fb4ba2f17f574003620f5d97134b19ca40f52436d30cef431bd5437abfa
|
| 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.dev1783227814-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1783227814-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b4ae8d370edcf9fc52830af84d7a10e2d35235da36fc114c09f86cffcad5965e
|
|
BLAKE2b-256 checksum How to use checksums |
5ceed4e6e84441247f676cb4c87342e0657aee422ba62adfd1741b27e849a08c
|
| 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.dev1783227814-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
caa809df81b7844079e64e0a7c78f0753735f93d42e3c6cab5ed5de1e146a273
|
|
BLAKE2b-256 checksum How to use checksums |
ede1b3c5a82e1cf49244733fefb712a4618325381cff9a15382a2eee539bb3c1
|
| 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.dev1783227814-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1783227814-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 |
1efd5a0e3a7fede04d0f2a4126ff919e46f977410307cc23de4e3c529c05b4df
|
|
BLAKE2b-256 checksum How to use checksums |
ef1e7697444e4856d4c765eea94ff928ba9ff60fd18caf006e4c50a233c1c048
|
| 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.dev1783227814-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1783227814-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 |
95362eab0af5322017e1f4c885faf433a6af2a09df021f15058757bc2921cea8
|
|
BLAKE2b-256 checksum How to use checksums |
d36c9a81dbaf30607ba6bbdca1529c9225c63d5a8709cdea0339cf5c66aa6fa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|