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.16.dev1779425858
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.16.dev1779425858.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 59.6 MB
Release files / stim-1.16.dev1779425858.tar.gz
| Download URL | stim-1.16.dev1779425858.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc15b5e7b5f6304f725455da998eed8a6d6f4dfbf1879ba7932228c3c5056edb
|
|
BLAKE2b-256 checksum How to use checksums |
f79522e1ec0367dd140b2408a4124957e189653d445de4da809d15c5a300ff75
|
| 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.16.dev1779425858-cp314-cp314-win_amd64.whl
| Download URL | stim-1.16.dev1779425858-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ff221848278e382ab07d8cb825a30c7317120ceff21ec3b0fec3493f18222c52
|
|
BLAKE2b-256 checksum How to use checksums |
6a7edf7efd435fe908c90d7efac1ec5129aa6d4fec00db678ec517276c3491a0
|
| 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.16.dev1779425858-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
c10db86d434b9056cf5c2763ed2f16e49961834d16172548c73bba9247573950
|
|
BLAKE2b-256 checksum How to use checksums |
245844371c02e312bce19cdc2225a25850d2e17f772ec8c2da33d32db1a0b992
|
| 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.16.dev1779425858-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779425858-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 |
27f12310723029995445d86d7389139189e6e1dd40bdf45457bad2d5ac55fa5c
|
|
BLAKE2b-256 checksum How to use checksums |
ce929cc264046330127b6f6c315e18b57a5ebbe257725a6d96783624fd7343c1
|
| 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.16.dev1779425858-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
906c580b57f8c66b689777746b65a6f455ca0c392a78d6868e4c9c7bcd22b6e3
|
|
BLAKE2b-256 checksum How to use checksums |
a1b7378ae5743efb6abe55320d64e4de13804898968af08769914c91c5dcb793
|
| 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.16.dev1779425858-cp313-cp313-win_amd64.whl
| Download URL | stim-1.16.dev1779425858-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d0a9aebb73b673edd66783d44a5ff9b35426b54d0cea0b700dc8060a368e0163
|
|
BLAKE2b-256 checksum How to use checksums |
ff03f154c3e68270073266573849edac4a41a43b5c9b740ff3c49d6bfe216ecf
|
| 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.16.dev1779425858-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
46b5b27a73efe022d16a5afe9f70624978dc2248d742801d5b0b50d0ee1b5616
|
|
BLAKE2b-256 checksum How to use checksums |
7d375b9ff8e3c07dff49bfb2ddd2fbb775fc7164fbcd4e8659a46dafa56812a6
|
| 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.16.dev1779425858-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779425858-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 |
08563eb819af3ccef4431c00fb85b87feaeb94b5d407e4e6ef5bf3aa5a41444b
|
|
BLAKE2b-256 checksum How to use checksums |
3b944a4713c13e9f0d306817168c856f59cae75e374c7ff0bf40b8eac4b95a6e
|
| 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.16.dev1779425858-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
eb62efada5f75dae31e7d4cba57ffba9418ca8214c9ace519f4cf9ace104434b
|
|
BLAKE2b-256 checksum How to use checksums |
7b31d66a1712340bee30d24cbb630f6db04da94c390437b32d71c7f117241b40
|
| 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.16.dev1779425858-cp312-cp312-win_amd64.whl
| Download URL | stim-1.16.dev1779425858-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0d4e8aa411404a8f2678320b4acd1961782bf6c972979a36c7285d579a62a9c4
|
|
BLAKE2b-256 checksum How to use checksums |
026e32f0ea382cd49ced05ea5ce8326f6017eebf1b0238e566c7c955404c161d
|
| 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.16.dev1779425858-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
5e7b8ef30151c79716e773f8f1df4df83681bfdf895011d2426f27337a256646
|
|
BLAKE2b-256 checksum How to use checksums |
33acd6c47afb604283083c70a7dc06ab0580781079ae90b01db9f194f9bfd34a
|
| 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.16.dev1779425858-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779425858-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 |
3c127487ec5acbe1a9dd86433c1f0bbe237dd852b3ea06e7736d38dce2b1f902
|
|
BLAKE2b-256 checksum How to use checksums |
771a8375937a02f73bb0971b03583ee7524432433c41b960a4e11746d54e6f81
|
| 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.16.dev1779425858-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
d59412ccd39275ea85121d1bfc27bc8291fa5506fe4cb31bce439997ee462d9b
|
|
BLAKE2b-256 checksum How to use checksums |
ecac62e95b67463d12688ef8eaa5c52401e3ac26052d9641749bd422f373d4d3
|
| 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.16.dev1779425858-cp311-cp311-win_amd64.whl
| Download URL | stim-1.16.dev1779425858-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2f83be727f9e12629bfb64d9d3d4cebb56534326561b2e90ae063b2d8c8ce047
|
|
BLAKE2b-256 checksum How to use checksums |
0f7a561776cb5abd707568dffdbbcafab69f140db7ed1b8b1aeb1b19f693573d
|
| 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.16.dev1779425858-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
2052eb88c837687ce96607495f6d267cf93f22b3198dfc9ec5644e70ae7f2130
|
|
BLAKE2b-256 checksum How to use checksums |
5ef7656f063d9f188df7a20957e69e984305d966c0984c979984760f8ff616ea
|
| 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.16.dev1779425858-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779425858-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 |
7523206fd3d508722176b1a20dcdc84d7d00a4efee1f78368907190992386714
|
|
BLAKE2b-256 checksum How to use checksums |
28abcfba6df8e8af5178aa728f7ed503fcd321f237b292d017113e91d8a280a5
|
| 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.16.dev1779425858-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
c22febb1f52c3a633ea11695e28d7bc206072b1de5f0846180c75c2df58e02f6
|
|
BLAKE2b-256 checksum How to use checksums |
8ba6937ba2efb5fb39def7833925111e13772a1ae95284ab0601a5d6bb3adc8e
|
| 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.16.dev1779425858-cp310-cp310-win_amd64.whl
| Download URL | stim-1.16.dev1779425858-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ee603239fa7297eda9e392406bdf976488cc908b7586b8e281e41813f6cef2b1
|
|
BLAKE2b-256 checksum How to use checksums |
dd671f4a1aabf3bfd26a0e0e0bbb3db704945f0fe7a962bcec7a5277b98470ef
|
| 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.16.dev1779425858-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
5558d3584573f77d0530fd94cf49d1079402693edb74632c670322dc72f3a9b7
|
|
BLAKE2b-256 checksum How to use checksums |
3e44af1981fde45fa84b35cce5e53984ceb2236fd6289cd7af07a139d986eba6
|
| 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.16.dev1779425858-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779425858-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 |
6910202a01182faf76298bffe59dd1ce4a82388d3a748c8bf10fc7b7584972b2
|
|
BLAKE2b-256 checksum How to use checksums |
6650f2384a4f586729ff7c3c5b2e2239be9ce7c588589f74a6a45f4de30a707b
|
| 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.16.dev1779425858-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.dev1779425858-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 |
332f80a98fbbc67cfb85ef1e66faf65e10dd95cf6abd72e6cf83225db17dbc2e
|
|
BLAKE2b-256 checksum How to use checksums |
3b4e2a25abd63da335e6be92d3fb19e662da5b2d35b821d4a1a0174986679f05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|