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.dev1782535097
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.dev1782535097.tar.gz | 882.8 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1782535097.tar.gz
| Download URL | stim-1.17.dev1782535097.tar.gz |
|---|---|
| Size | 882.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
083acd4bc193ba836ab8aca3c4b175fcdbf5755e06f73585fdf622cc7f87fc41
|
|
BLAKE2b-256 checksum How to use checksums |
6a7c8dda5a9326f1a17d7bab233c408d0ba1abdafb4f8b452915829c12187638
|
| 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.dev1782535097-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1782535097-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8c08cfdc44759b33a9fbf1926d7cade2ab4ee689991b0063b27c8c161954e6b1
|
|
BLAKE2b-256 checksum How to use checksums |
f7c4802b130b2134ba3deaad9b4ee758d0393029e0968cb9da7109067ba84117
|
| 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.dev1782535097-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
9a67c434264a60dee1a3198615b0a1a2ccdcb23c01ac07e4c0d508832ed274a5
|
|
BLAKE2b-256 checksum How to use checksums |
e3ed3aabd1a30e6fc4093bf759278a653672ef0f94e3d405ceb768bd233320ae
|
| 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.dev1782535097-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782535097-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 |
f273ccf77617b358d85e17c056e9aea3abf687f310a7171930b9de8a194947b1
|
|
BLAKE2b-256 checksum How to use checksums |
5ebf98932fe6bed3e7d0be6d30f64b9d31227ebd5ad3d66a7052f15554a12861
|
| 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.dev1782535097-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
8ff07584831f393b8858503637eb9987e701985f2a83d2886be4351fdf164f85
|
|
BLAKE2b-256 checksum How to use checksums |
91a92a7cb83fcbd5c2eef2dae026ed08f699f076d91081bbcc6bca27717decfb
|
| 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.dev1782535097-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1782535097-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cb03110fe26151b14ef6653dc7f5e6f1bc7c59b274426ae50aebf21ca8bbfe93
|
|
BLAKE2b-256 checksum How to use checksums |
48e2f853aa158c9b227ae89ae3dbd2eab9fa6c0db38e3b6ed1b6c1c7adc8d740
|
| 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.dev1782535097-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
506c47bc34c0e0a510377c73657b4cbaf62bf45e08f4f0d402099df85bf0fb30
|
|
BLAKE2b-256 checksum How to use checksums |
0c207ea12dcf240aee886634a706e684655726d56bc37b17e5be7a811361b5af
|
| 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.dev1782535097-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782535097-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 |
c21a8650330abd88caf8e6925241dbd03f5f5f7388e0b7fd1419b9abc346c802
|
|
BLAKE2b-256 checksum How to use checksums |
a07960fd37d6f5dad357e6666598bdb9ae4a251705fc32b5432831726f47ab1a
|
| 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.dev1782535097-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
3c15a609d38d529499bf8bcbc6095611b4c7de2d5e36b421fdc102fe78e6a9b1
|
|
BLAKE2b-256 checksum How to use checksums |
7c260da6f1f1139ba3cf812c9327ca692085dca2ba0e7dc9a0025d01c5bcfcc2
|
| 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.dev1782535097-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1782535097-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b2b540f4932931640c52cc4eef7f6ca44500e416e1341086dfa40a61c7ba192b
|
|
BLAKE2b-256 checksum How to use checksums |
f8bac22f93b1dc0ea8e102d7eaaafcb99b1b515610c87dc5bb2033e24bd50d50
|
| 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.dev1782535097-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
ef90cfca7b3d3fa4c393371815428c0e43257f62fbc4098f8277b1ab9abec3c3
|
|
BLAKE2b-256 checksum How to use checksums |
289c9ba30618008aaae8fde8e3f5ce6c894374860fbde88545d1fd3a40b2534b
|
| 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.dev1782535097-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782535097-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 |
af671974ff15f909566f273d0cacc7b559a8e72d428bba4684e7745af6595e7c
|
|
BLAKE2b-256 checksum How to use checksums |
21857069edbe6243f4e5a98aaad8b910bfeda4cb0c31dbd87bf4e6e790ab8db9
|
| 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.dev1782535097-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
03b3bc5383aaea4b0ee689e9f648c172d79a202d647d4e586863c181da93d5c9
|
|
BLAKE2b-256 checksum How to use checksums |
8501f6b7840f3b096e12b71ab62e3f60e28499f0319b66281da642d0337ac3aa
|
| 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.dev1782535097-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1782535097-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1fdc3eb27718f55376d98ee5c8cae9f0dcc99196cb866fb437c08a18a2862d6e
|
|
BLAKE2b-256 checksum How to use checksums |
b1bf6188ea2e3c18e1669b1820c038a46da4018a663ddc7f55221d62036b05b2
|
| 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.dev1782535097-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
bfa9148728328de2dcb77b7b604dd51f0ade4ecbef69ee4867b4351e2a9e56ff
|
|
BLAKE2b-256 checksum How to use checksums |
e5e1c92968924e6776c3c5705ff74e6d6f9edd175555887c62a6c607a6c45dae
|
| 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.dev1782535097-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782535097-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 |
ae5820633804a8eb844453e57e79fa875a6539894783495472e25ff2a43fa759
|
|
BLAKE2b-256 checksum How to use checksums |
06e972849b4af5cfcaecf1acca93003aeaa1a903eae20d59bca74665db0e0a6d
|
| 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.dev1782535097-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
6aa108d3384b8722ae33cfbcc8a0afc17c83e1c81512bd8b444f5c246647c058
|
|
BLAKE2b-256 checksum How to use checksums |
2defcf5a8983862958594b699fb21934a8392f0ff865fdf7ac7db4a2ca86d787
|
| 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.dev1782535097-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1782535097-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
77b9f98aacf7c7899ca1127af8df7baf704b62a512b448d2e3f9401038638fe0
|
|
BLAKE2b-256 checksum How to use checksums |
e55bc67b1293119bfc7a5b0ad13a335505005aba3e457bca6be8d079ac1f72f0
|
| 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.dev1782535097-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
a74653f6b0cdc103d4791b06cc3f010dfe75e55bf1fe4c3a49b04b087dcc54b8
|
|
BLAKE2b-256 checksum How to use checksums |
6ede1c33c3f0a3b2e9aab3382e35c36fe1342bfcf2df52fc39c25f06549d2c16
|
| 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.dev1782535097-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782535097-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 |
d91c11d38df31b5174edad520d0d3f8df86c245a593a129c6db7dac6f3fde361
|
|
BLAKE2b-256 checksum How to use checksums |
f3175bd60f8bece15dd17dfbf6183c57052be8b73f4163d9fd86985164667772
|
| 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.dev1782535097-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782535097-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 |
65fc4f1a7c0a481b427ced91f758a7086b0ad3c0deb6f5eb6de708363c949ca6
|
|
BLAKE2b-256 checksum How to use checksums |
2c6a31aedae15c959b102bbe6fa7f7aa7ba347d844971410f1bbf65f80a78b8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|