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)
Metadata
Release files for stim 1.17.dev1792124270
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.dev1792124270.tar.gz | 885.2 kB | Details |
Built distributions (wheels)
Total release size: 62.1 MB
Release files / stim-1.17.dev1792124270.tar.gz
| Download URL | stim-1.17.dev1792124270.tar.gz |
|---|---|
| Size | 885.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cad35e316544757032793eb6dd1ee39ce08bd5245f2f56f930c75096bc34758
|
|
BLAKE2b-256 checksum How to use checksums |
133f36c86ba49e574415e5ef1bbd5d4cbeb71bdc2c38553e9b9e2aabaf82c344
|
| 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.dev1792124270-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1792124270-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1089ae6e15c321b9255a07bfbdf4fcb0f997c1f5aecdba575ddef1295ad33c62
|
|
BLAKE2b-256 checksum How to use checksums |
a362294aa52164af5d026ca5def74226451777b1b21a04b02329fe2f68df26fd
|
| 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.dev1792124270-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
f658ce6fdf3f9a0cb4be4709798552b6875f8e6b2bc505b18b76fce23c885d7a
|
|
BLAKE2b-256 checksum How to use checksums |
85c63dba469d96367f952e82c0ea39c2f1224d0bbdb983aa82638835751e2c31
|
| 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.dev1792124270-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1792124270-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 |
3643584d08d239e42a34478fda1bc0f37b44883974bb79009f3dab798e6d5d4d
|
|
BLAKE2b-256 checksum How to use checksums |
16a642b24b060dd390fca79ed6c36331bb806ac6ea5ee9a84fb287c1a45d7ab7
|
| 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.dev1792124270-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
1677262bde45633183cb02feb0afb7621031ce3d57d91db4b97aa5b881b81766
|
|
BLAKE2b-256 checksum How to use checksums |
000cd38672e56f2c059ce81e3a281bc63a8c3490494aad805ed5b3ff18979f1a
|
| 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.dev1792124270-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1792124270-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
302bcc72426f69996036c2b6b9eeb7552ee7a2bdd2a5dcfed38e61afbc7cc9d8
|
|
BLAKE2b-256 checksum How to use checksums |
6d069fa94a04074c5ff5c1d1574bec59cce4c50130495602c80241f72e78d207
|
| 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.dev1792124270-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
834f350035b4e799acc194288e19a2b14b9e9bf85e9b8a9b259f67f3e1ae701d
|
|
BLAKE2b-256 checksum How to use checksums |
e7c79ca597325b47b13e553e43d40a304c4a9f72b14f368840a09b7d2c6d0e40
|
| 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.dev1792124270-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1792124270-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 |
c042a1281bb61224c30092e7909abb9ad91c4be34c5ca65f68d21221cab237fc
|
|
BLAKE2b-256 checksum How to use checksums |
d42386d07107794b92a9e1bfe8f8000a5b0ca9d5efdf08c6e91aa09be455c4c0
|
| 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.dev1792124270-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
02510178666cfa10a21eafb0721a94c6a08e0a8f79fd2aeb49c46ff2b9650fef
|
|
BLAKE2b-256 checksum How to use checksums |
dc0d8e6c7290f7e68693d23602484c73fe53b327d162ac4b8dbcc558aac97bf2
|
| 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.dev1792124270-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1792124270-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1e5e9e400181dd0bbe4e64cda60c9ba481b0d59ac31e7516f79c5588b55c8e65
|
|
BLAKE2b-256 checksum How to use checksums |
bda314396137098418373b694094dca9755ce6378e858d4d2a2518271f40fb7e
|
| 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.dev1792124270-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
d4d0ac24d4ba71c9d553e4b22ef0536b8203bcb1a037d7633564d56db2e143b3
|
|
BLAKE2b-256 checksum How to use checksums |
811e3332e3615da1aebd2edb31cf556e154b86ca36b38875d97b60f96ba2f94f
|
| 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.dev1792124270-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1792124270-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 |
672ae40db5ee653c285372edaff70428d8d3656678545dcb8117e3c1913b0937
|
|
BLAKE2b-256 checksum How to use checksums |
1080cff550ba94d7ebde1c1f6c7baa538e05f9e844726aed3919b75479117e98
|
| 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.dev1792124270-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
06f8dfff445682af3636e6be5aae6ef411de926b4e69cce4a706a8646846fbbf
|
|
BLAKE2b-256 checksum How to use checksums |
ffbfaa5b5fe010696bc88955cd73cb8fdc95c54e4f37bf3d33e31eeee0fcb9c2
|
| 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.dev1792124270-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1792124270-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
36518a7a03ead6187906c9d0b6cd439f945de7e2d6fad0ae947c1c0a3832fb57
|
|
BLAKE2b-256 checksum How to use checksums |
e1f3d277c79a439934d5d167e5e7c2078ede7207ce14d34456daf78a135d7b9b
|
| 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.dev1792124270-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
cd11e5d649bfd1679c3de93753f818e1ecc4867b981bf48c265e07cd5f952123
|
|
BLAKE2b-256 checksum How to use checksums |
7a8bd41eacbaea570a107d5fe9b6de7ba62fe6cba21a085dbf7e04fbfa20347a
|
| 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.dev1792124270-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1792124270-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 |
84ab8be20b88d6acc774ba6ea141a61b5def9f1fb93544fecb66ab2152ba847c
|
|
BLAKE2b-256 checksum How to use checksums |
6073a20c530d8d7e6ee79df00a03f733af3b1d2a1383ef208812e208106a8505
|
| 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.dev1792124270-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1792124270-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
cfc049c720cf94b7c38587ecd43ef5f93d0179d037b4160b0a722187d11956c4
|
|
BLAKE2b-256 checksum How to use checksums |
234dcbedb339020f479dbfbbcfa6483b0e44b9dcc00661f05640c4cc0dc61e9d
|
| 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.dev1792124270-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1792124270-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
640e5b78627248bbe5090c805e33cf6129cce216d0bfd81bf2364ec85f20a97c
|
|
BLAKE2b-256 checksum How to use checksums |
0fc3e98138d9418ccb4bb02cc4e21e893ec902d2bfa114cc2ea1329162e0068f
|
| 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.dev1792124270-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
83a551a676c40cd20364947e4bd4156c5236e0e181f5c8a36188b47e7eacc016
|
|
BLAKE2b-256 checksum How to use checksums |
1472d96fd6f288d5bca5da519f1a6667025446f7a335d88472a794e0544487e5
|
| 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.dev1792124270-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1792124270-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 |
c4ba4801729912738b515d5b551eacc591254c21ba9770b049e9e2ac0f0c14e1
|
|
BLAKE2b-256 checksum How to use checksums |
c32527022e62065b330ca012ee42c9f9f70dfc0c0210d85877254e84ea280450
|
| 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.dev1792124270-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1792124270-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 |
ae9b306bbb7140fc92c1bbb551f99a899ec771a8146801b6b02e014350d1da89
|
|
BLAKE2b-256 checksum How to use checksums |
3f5eebce0708c0c84d61742eba0914e1e3574d59d89d4de43d4221806367e438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|