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.dev1782536076
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.dev1782536076.tar.gz | 882.8 kB | Details |
Built distributions (wheels)
Total release size: 60.5 MB
Release files / stim-1.17.dev1782536076.tar.gz
| Download URL | stim-1.17.dev1782536076.tar.gz |
|---|---|
| Size | 882.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86d6a46227354479e5dd2b113d46554fd9eb64d25d5ff973c87a676b5a53863e
|
|
BLAKE2b-256 checksum How to use checksums |
14ad34d6bfbfcaba7e090591e94842f1d80d9bc3626a390f096eb7b353504b56
|
| 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.dev1782536076-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1782536076-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6cd85f1da79fe48e723026c4305370b281b7843d497f8a5624ed6451af38da57
|
|
BLAKE2b-256 checksum How to use checksums |
7d288f84ac230aed34cc486e0bc7babe9c597e61fae9c436313da24f0d53df88
|
| 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.dev1782536076-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
7a2177b49db9e7c9dffdff695489926ec6aa06aa7d92605c0fe2fb89b85a2266
|
|
BLAKE2b-256 checksum How to use checksums |
8fc4a1a014c780dee3c6f3d9cea8c25873fc4b47fe66c558ae484aefdfd2ee80
|
| 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.dev1782536076-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782536076-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 |
85772ba26233e339764ca101993cddbf1e81a05115463ec40f4a959ef33563e5
|
|
BLAKE2b-256 checksum How to use checksums |
dbdec1cc67f955b1b94af7da36c9bf27cbae264fc16975a1725ddbe664a1230d
|
| 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.dev1782536076-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
10e798e8f8088366c5ba5eb80938c8685b616829b564835616865b2a6dc6d53f
|
|
BLAKE2b-256 checksum How to use checksums |
3615b533b84f23489d961f86b5a1ab191980518f67df5707a8c2b4fce262829e
|
| 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.dev1782536076-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1782536076-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c6e4b5af3e11997746b52b172ae9297fb67c0c9473e3d90094593ffe9d6d6054
|
|
BLAKE2b-256 checksum How to use checksums |
2492c460aad6ede67c29e6ae9e4a84eeb77aa9741bba73be65281b185ea92d0e
|
| 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.dev1782536076-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
75d017c3321442e328f60207f5a4cb4f541d424e7f09a913dc339919657ca8bc
|
|
BLAKE2b-256 checksum How to use checksums |
d8561a066593bd3505ca8f5677b9402a32dcf91c79a3c4676e8d04e6ac8924bf
|
| 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.dev1782536076-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782536076-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 |
341d4903798a66136612c514bacac976ee35c556b750ca1ed5e0e5c23e7d1f8c
|
|
BLAKE2b-256 checksum How to use checksums |
28253f4b9a5b48fc531d63fc43ef680757d1a06100e316f213e9fdae691d76c5
|
| 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.dev1782536076-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
cfea878e06b2a8a87fc72787aa34f1cd09e858ee9497adc9e0d005f2fce9efca
|
|
BLAKE2b-256 checksum How to use checksums |
602464c2ca60416c3da4ba5f4d2c5251dc50f3881d735b634679501b037d8488
|
| 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.dev1782536076-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1782536076-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a38a40bb2727ff1e3202fb186eebcb885de9b8bfaf491c0e7e379dc85c7bcebd
|
|
BLAKE2b-256 checksum How to use checksums |
3304b85ef21318df01a2ee82e27e440e7c656e379209d862005050dcd490c4f7
|
| 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.dev1782536076-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
e92f07ca32ee1a2e7ea7323011f237b1e75b6da7fdee379365592a6f518b40b3
|
|
BLAKE2b-256 checksum How to use checksums |
f349dd2b557a6e8bbcd0f55443b69f21c69fe37b4a0336ac6dc6dbfa54ab31ce
|
| 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.dev1782536076-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782536076-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 |
d2abe51a21c03f1b79f7ab87b72858c38d930515656095354b3d91b293979daf
|
|
BLAKE2b-256 checksum How to use checksums |
8b4776b45948225857fbba0981f10885d282ae0f794444e4700bf28ae759d691
|
| 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.dev1782536076-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
cb71cc68b3234fc18305acefb4aabe49f550717fe13d03236c8c41bf7ab87884
|
|
BLAKE2b-256 checksum How to use checksums |
e739c7b2256dad0d5c5085d6da6f420f7d2d31be88fad48599eebab543bb61ef
|
| 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.dev1782536076-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1782536076-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
79da027258849a18f7d9e2f24447da9539eee8a54f20d7d6356545bcf2c7ce42
|
|
BLAKE2b-256 checksum How to use checksums |
8f8a88c6e7a3b8a27c37f1230aab51c0aee40a138a0fedf2e79ee294286d5eaf
|
| 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.dev1782536076-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
d3eab9b1c09e74570ff702388bc19cfc2e496f6911579346f957bc5a13dacc09
|
|
BLAKE2b-256 checksum How to use checksums |
c311b42c1d8ea4673203866c118bbc489fb407db74c235f41dc0c922503122f6
|
| 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.dev1782536076-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782536076-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 |
0f578d833725a3d9693d82e57b241cd201d1bc3cf547b98e41c3213993702a78
|
|
BLAKE2b-256 checksum How to use checksums |
108919dd4f161ea1d079e5f6961abfa3be01fd98864a05b5fdd3f62a7207f2c5
|
| 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.dev1782536076-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
a63a79cf3ccedf7e95c71ef69a2f023d6e923999cc11950678d9813bf6229600
|
|
BLAKE2b-256 checksum How to use checksums |
698bb860a53688a4bafce67dd2eba402afb0bc44a9f915214b382c1d2b1ed4d3
|
| 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.dev1782536076-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1782536076-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
87a70696376d2338b44bc03e700d6b8203f13e45c31ee0bff9f18c174b74d9dc
|
|
BLAKE2b-256 checksum How to use checksums |
f26d9768c23ac86aa70579ea4cccfbcd0208cd71f4e2be0c78a09511de96100a
|
| 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.dev1782536076-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
652d37d9f29ad0742e3c6771a76d2ab6695082ec3c2bfc8f02eda304433f7005
|
|
BLAKE2b-256 checksum How to use checksums |
9d46af53c01fa111e8bb49f6b22f487f3448c4817176df0ece48318a7770be00
|
| 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.dev1782536076-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782536076-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 |
2965199cbfb325256a91efe9dacf9cb356e361dcf1d16ade9f2ba01d745fe832
|
|
BLAKE2b-256 checksum How to use checksums |
748c7796576217214c652e8c49291103281f4ff02784f35415434892ab62370d
|
| 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.dev1782536076-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782536076-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 |
de0945246ef86cfe705f5526cdea5f6f9d24817e64c2322705f447f7e7ee53f1
|
|
BLAKE2b-256 checksum How to use checksums |
2482361c5a5aaa8d161fe9235c92998d5949393d0a14cb8e3d0e0182edf839c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|