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.dev1779421376
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.dev1779421376.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 60.9 MB
Release files / stim-1.16.dev1779421376.tar.gz
| Download URL | stim-1.16.dev1779421376.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
491f6b7de087eafe96f25b58bafc76dcfad342ed0b7d3b045f8f0bfeaf41fcbe
|
|
BLAKE2b-256 checksum How to use checksums |
1c07218d675de4603433e768d1502029dffbc97365b85c077b10e1eb5e885bc6
|
| 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.dev1779421376-cp314-cp314-win_amd64.whl
| Download URL | stim-1.16.dev1779421376-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
65b922b73db2208c5da5fb0329eb0dd8000d8453fe122250f4e6cf712a8d3675
|
|
BLAKE2b-256 checksum How to use checksums |
fa67a40852de47f11b048f9c6d6f1cd9ceb18713866a497e5eb239cf42888c5f
|
| 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.dev1779421376-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
216bfbfc110f7c1a5c7193b1626c604e3a7235b5812ae97a4e00a10833d69982
|
|
BLAKE2b-256 checksum How to use checksums |
a1ad0d6d037935910907e1ac310be3b4883112dbb7086217e988bd0f1c94cc4a
|
| 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.dev1779421376-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779421376-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 |
936e4b3fdc8f49d78cf912f96c69cd09b388dc688f01414b502066a816f31b35
|
|
BLAKE2b-256 checksum How to use checksums |
8ae9252e9515851ddd934dd116b2d8fe5030f57fbaf5eed7a72d1420ff51b9b6
|
| 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.dev1779421376-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
5c0893d6ca840f156499836639621883d2b02ee266b60c5b2cada709b48ce90d
|
|
BLAKE2b-256 checksum How to use checksums |
3d3ced4408d1ee5715e7830b4c5b7fb0c048d0093f42e851ce9ee33ab340eeec
|
| 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.dev1779421376-cp313-cp313-win_amd64.whl
| Download URL | stim-1.16.dev1779421376-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
41e0c2654958d9283e9c8bcf8b177545a9d3ad0d95a669df93daea70c842dc6d
|
|
BLAKE2b-256 checksum How to use checksums |
e9582c1ee9e5248715eccf353704a7b16bf713838e9d362071aa0e2b31409d05
|
| 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.dev1779421376-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
4b974c64ff37179c28c7625cd136192870527061c38ed2f6910309718e9ded8f
|
|
BLAKE2b-256 checksum How to use checksums |
44e842a78ea2fc013ae7a02817810bdbb9bf2d6e160fc1b9d473131715806701
|
| 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.dev1779421376-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779421376-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 |
6d3e53cdad4362d17b50e5d979fdeef798b0712853715cfb70715c99c48e4749
|
|
BLAKE2b-256 checksum How to use checksums |
75ce025855ca81054c2f3b9221491d9157ed9649de9316c6cbd99edb685fc252
|
| 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.dev1779421376-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
16f678606e272cdc9b285060b8accf8a6a78e7f53314f0869e0ca0687c069bb4
|
|
BLAKE2b-256 checksum How to use checksums |
4a5d0b39f48134e5feba50cc249b9aaf102300d7dfa41cda2447d0b5972e519f
|
| 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.dev1779421376-cp312-cp312-win_amd64.whl
| Download URL | stim-1.16.dev1779421376-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a04abe2827cc78d7642a497d479f69b3e8e1f202d7670be1b285bd970016097e
|
|
BLAKE2b-256 checksum How to use checksums |
ef72a24d66d7251f7094eaf0708fe6e1573a782bde905fa69a2366f0acc26aaf
|
| 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.dev1779421376-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
853c04bf7f9188796c1dbb6efd6ef17aca605076fefbf2e14a75157fcd986b85
|
|
BLAKE2b-256 checksum How to use checksums |
7c9a58befa3f535535de74bae529835dc90e929bff721afb35039177b45d5fe6
|
| 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.dev1779421376-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779421376-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 |
fc01f60a1fbd168e62d8a2fdccd21c3b7465e34d5fd374ddbf82a1c8629fd045
|
|
BLAKE2b-256 checksum How to use checksums |
d41c68e7595592d31fb756aeae42f2dfd67364d4a19afb167e640ffb21b4c95b
|
| 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.dev1779421376-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
fa0481dbb50cc15fd509e72903a682390a27ff7a2b8675ce8b178f60a8c8adf9
|
|
BLAKE2b-256 checksum How to use checksums |
daef53349cee52f7f265bd7d57d551750171aae0a55cdb7e54607149d86e8549
|
| 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.dev1779421376-cp311-cp311-win_amd64.whl
| Download URL | stim-1.16.dev1779421376-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
934069c1cc8b41b46357a6e0a54ffbfa7269c5d2799e24eca72a1422b4eb5543
|
|
BLAKE2b-256 checksum How to use checksums |
d2bbefac5990516ebd5e982568b2534da6b8d58bd51b551dda68688080cdc2e5
|
| 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.dev1779421376-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
561355c7c5a8640db128aa43bd5240950e8df91a34ed49255e37c5dea41f26af
|
|
BLAKE2b-256 checksum How to use checksums |
00a8de1848d8ca7d3ecf483f969b825fb0429c6e878a1752bace4e6f14017503
|
| 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.dev1779421376-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779421376-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 |
c7c0c54e91018aec05afa5b4f5fd05c033e5abc0afdcc7f8cc0c55ff56b1b2bc
|
|
BLAKE2b-256 checksum How to use checksums |
2e1d457b1c397e5e8625b675d9dd2de92267ae0111adb53a039d273048b29e4d
|
| 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.dev1779421376-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
31950b53ca7e2d916ce90e60d8789b84cdeae6a462b593d249a86a10fbf32c0b
|
|
BLAKE2b-256 checksum How to use checksums |
f64fd65452e81b4eb60bdee973b9ffa81a0f62db33f23ed6d816e8dfe4dff2fb
|
| 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.dev1779421376-cp310-cp310-win_amd64.whl
| Download URL | stim-1.16.dev1779421376-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
299a99b0697dd0066efbf3d2e4904279d0464e074d7830176293d68d6d3bc119
|
|
BLAKE2b-256 checksum How to use checksums |
c0ac9108488eb9f785bc137fdff70d06b35e8d0b11cde7f773b214e3d2103b0a
|
| 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.dev1779421376-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
7c0abf3b70595bbb9c3ade9d89747f9f2745dccff9e5c0443fa4580bd7f3ceec
|
|
BLAKE2b-256 checksum How to use checksums |
3410e8c5eb1892542e104137a38d6641f8fd964ecab27abeed5f7ec11437ff5f
|
| 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.dev1779421376-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.16.dev1779421376-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 |
c1d611eb374962791bbe3b434fb4465f1301f95fc58e2f9ee1078292cedb265c
|
|
BLAKE2b-256 checksum How to use checksums |
4168ed134b7532dce6b15c26220c6d26f610579faa7b22ad7b4310eaac255566
|
| 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.dev1779421376-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.16.dev1779421376-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 |
31c2fab14e6f777ea86c27e645cf667ad86aec59d0494ca845ae7549b14ef81c
|
|
BLAKE2b-256 checksum How to use checksums |
d2ca3b147df7ffc2901694e2e330a1d8e858c04cc438ecdfc97db5da4c877fcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|