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.dev1784068810
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.dev1784068810.tar.gz | 883.2 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1784068810.tar.gz
| Download URL | stim-1.17.dev1784068810.tar.gz |
|---|---|
| Size | 883.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74f553e783ab6ef052cef254c095de4a2b3d0827558f114e2d8705f2db590834
|
|
BLAKE2b-256 checksum How to use checksums |
5298b6bd02de6dfad2b91f4a4c1b6c7caaa7a0c03161f902832240c1de231e4e
|
| 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.dev1784068810-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1784068810-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e50769b629912cd01fce2bb9e3d2b9939daf5bf5f9e151fd5a11794e772a92d5
|
|
BLAKE2b-256 checksum How to use checksums |
4b9db282a935e5e1d5033724da4934fb47666b9710df74eea6c0c2cb844daaf4
|
| 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.dev1784068810-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
237924afba850fbf78df4255a67a40fe61d1c40f727006baac58faab90c4bd41
|
|
BLAKE2b-256 checksum How to use checksums |
3053d27c9b525cbbf8ae714de788c4c069c1a97871a97b5e4125c465af64f339
|
| 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.dev1784068810-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784068810-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 |
f6a7f5ea4e08acb9d73178badfd9b705c000907ae041dce794794edc0e7f3158
|
|
BLAKE2b-256 checksum How to use checksums |
42c8769628df9235057a5c880982d11cde19cfca6bb72cb632ba0dc4819840a5
|
| 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.dev1784068810-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
65052b5041d29dfd6d5b911d156ca85c4eed18a148ee79384fde8eb38e5e77e6
|
|
BLAKE2b-256 checksum How to use checksums |
82d9da247f2c3fb2f6e68eaf31bc023def4729766e8c7e8e07348c7897540df6
|
| 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.dev1784068810-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1784068810-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c91560b3562ba50872031bb42362e8d2d111b5f6e1d11eeca0af75c2c678fdf8
|
|
BLAKE2b-256 checksum How to use checksums |
e8ff68bd7110ae845d6b463d74f3d6623d1e596bd7290da944aa4f8179f2a18b
|
| 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.dev1784068810-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
729677a58d07f4a098274b3aaee9d7650df78319ae845325e19e1adca54aa649
|
|
BLAKE2b-256 checksum How to use checksums |
943903ada70d5ce3eaba2c110c309e307ef0494de2b8d886f3fac35831a09295
|
| 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.dev1784068810-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784068810-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 |
a37af1e442801446279f0fd933e68c32f04911192fe88a80e2a2422ec05dc459
|
|
BLAKE2b-256 checksum How to use checksums |
5083ea774184d8522d471ceb0b9365a8853d0e5fb4f9175c849a476511a8bf81
|
| 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.dev1784068810-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
440c529568eb473a6858f50e9a5c8f537b18993d26c0f286202d6153430c9e2e
|
|
BLAKE2b-256 checksum How to use checksums |
d6f508751d906e7983335fb9bf2a9c3a74922c372e79ce27fade4d68d03cdfc4
|
| 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.dev1784068810-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1784068810-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
598fa98b67b41ccccbf6df678e562cac791dfe3c8307af26edd4ba0b19c3fe36
|
|
BLAKE2b-256 checksum How to use checksums |
fe4d359336f91c6a6820291e2272c20aa3c57355a61b703eec367c2b53f8f4e7
|
| 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.dev1784068810-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
981828ae0c85968d02146db930ca69d00484c2f7fb166accc16ad4fd05975089
|
|
BLAKE2b-256 checksum How to use checksums |
6340edd76d37c6db3b7c74417b30ef6e29da438440a331667129227c2039ce02
|
| 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.dev1784068810-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784068810-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 |
896d131833646b23f28d856ea483f77da3a536a4106b4abd8cac6e5780616b6f
|
|
BLAKE2b-256 checksum How to use checksums |
f3d2c01a660ecb438ad0ca6508cd1742992ab9433063a353e4b9e08711dfa706
|
| 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.dev1784068810-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
ab0b3c02d6a674b5fb0be507f15d8d6c1a37f10efccd8478f52be0ac4f675eaf
|
|
BLAKE2b-256 checksum How to use checksums |
ac617d2d055ad3da4b2e0c5292e3caea6a164d046bfc845e2bad40d50950dead
|
| 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.dev1784068810-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1784068810-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5a84aabea78eaece2cfee949233013ba1201e2d1367f8f094851b27969efba0d
|
|
BLAKE2b-256 checksum How to use checksums |
69515e8647299b9ef0b566502fedf194ed220a1a9ef8f4ef735b3275eb83bce2
|
| 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.dev1784068810-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
5400cce4e5dc465b70acc82096d4f4aefa475cc8d4e26263cbc6770747dd6510
|
|
BLAKE2b-256 checksum How to use checksums |
dabd16b5f00f4cdfbd540f7a0fb0dba712afc47bddb621a9fe23c133facb9366
|
| 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.dev1784068810-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784068810-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 |
92dadacb444e70a9c987d40e70122147fdcd7c6adbc66f24f63a3ce9b7711cdb
|
|
BLAKE2b-256 checksum How to use checksums |
f7ab13e06aede907bbdd18d508669ff3d840cb184c65c81128336251386cdeb9
|
| 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.dev1784068810-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
f9a13d7bd836c2479863ec97e220ad69dd6f7de230008fe4235e45f21f96e85f
|
|
BLAKE2b-256 checksum How to use checksums |
7168015be06a5dcccf40558663387aac00a1f45101e4c5c8ebc8647b0da5206d
|
| 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.dev1784068810-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1784068810-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
37ad3e3e859aad71d9278edc422e5cd0ab5f8bcd14208ea64d8ba4420cbe3fa6
|
|
BLAKE2b-256 checksum How to use checksums |
d0cd739ddda8fe5f68c546941425da63e9ae6583694d93b08213366474afe612
|
| 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.dev1784068810-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
bb49925014f3f95f622cd8c1b093aa21d27b4fe998a5cf4d491898789878a461
|
|
BLAKE2b-256 checksum How to use checksums |
946b2b26a6ea34fd7d6befd57ffc2ba1d8280eaa1b922b8955a719f36da72722
|
| 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.dev1784068810-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784068810-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 |
5dd9d352ec6213065013af9a18c071cae1c668d19af428eb59fa9cc32c1c0ac7
|
|
BLAKE2b-256 checksum How to use checksums |
f210ad335f1476cd0cd3302f854d66f5bede5fbcfba51a8df230ee8df86ee288
|
| 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.dev1784068810-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784068810-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 |
6bcd1bfb3fc95990a09c61f4c6a2c3f1e807e2b76eb356101e3a997b1e30359e
|
|
BLAKE2b-256 checksum How to use checksums |
71dbc69e7304f97718b1e432f0bc1346c7fe4591dbd1b821529b6d260012d33f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|