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.dev1782599698
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.dev1782599698.tar.gz | 882.9 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1782599698.tar.gz
| Download URL | stim-1.17.dev1782599698.tar.gz |
|---|---|
| Size | 882.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb40b55f28a241f2e8087e68b44dd5995ea7cd1f61adb7b51c9512e1a76a38ce
|
|
BLAKE2b-256 checksum How to use checksums |
941cf626c97912e50a516e2d807215cb6bf251e7169dad582c0db602b5391845
|
| 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.dev1782599698-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1782599698-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c7c4d6ee63f16c623eda42d72c1f5b8d15447ccdfb26fe81431eb46cce4c385c
|
|
BLAKE2b-256 checksum How to use checksums |
c6a9479d722bb4c0cc41e84d53d9beb58dff4539e23c8da7c716ffe8229e079d
|
| 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.dev1782599698-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
d7c948a953e4168e74ca76c5fe5877c6aa0ff3a3f22258cf53d00da198f80fe8
|
|
BLAKE2b-256 checksum How to use checksums |
a57ef16f39f119e6174029fbc85c88ac46f21cc1e1f3f0b8f7c4217a30eadf29
|
| 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.dev1782599698-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782599698-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 |
2174dad555782f3ee559cb89e0bdca91570e55ba1e59a0592cc017e77f13168b
|
|
BLAKE2b-256 checksum How to use checksums |
59d911832a7a24d41fe57c9f2901d69c152e18963829eebfa52b48759c925a65
|
| 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.dev1782599698-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
e5db9f042b9d9d9d127cdb8f0e634936cdd6a884129d1fe3c0c3fdad4ef1053e
|
|
BLAKE2b-256 checksum How to use checksums |
346eda5021ee3edc79d702a9cee415ddfbc47711d9cb92c0221164b401b5f2cb
|
| 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.dev1782599698-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1782599698-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
be7bba638782b1c686f08a10e8b7e01329101f5180edf2efe7d0bc9d2c5ee702
|
|
BLAKE2b-256 checksum How to use checksums |
b85729bd4e8485289c6d05564fba8265f7bb020844676cf484a230e41eb3e431
|
| 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.dev1782599698-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
22f451a3aa15eb39e7aa5d411ae5361ec4ef04912f683e5d0cbee076fd2896f4
|
|
BLAKE2b-256 checksum How to use checksums |
fd33dcb2f24053cf30ecf51e5c65043ddff7bc512e6464b9a7d018d29adb585d
|
| 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.dev1782599698-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782599698-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 |
7c6b4388c6527d40c4e87761fc9b1d8b4193eae84eee1f162eb04dabed89439c
|
|
BLAKE2b-256 checksum How to use checksums |
c5eb73145edae303f6b68b5c8a60baab898c543ecd0ed0dcb0555d34a2d2d78e
|
| 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.dev1782599698-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
696f1be3d50c7d2c7d5f747d4b78bf724a861fefce1f8b8f4735277a2ea28bdc
|
|
BLAKE2b-256 checksum How to use checksums |
2a9b17ae61b06cfdc5e53d111e11fe8e96b48b48ed2b25e4650b8fbb396686c0
|
| 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.dev1782599698-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1782599698-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
31fedd201c06e80b7ae9d593df2dc94899cf82b71302c5269ef018037ae52b5e
|
|
BLAKE2b-256 checksum How to use checksums |
01738838fcc7eecd180dc59f18516144e2164ebea462c81f224339eb7d1fc077
|
| 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.dev1782599698-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
63871e5d822654c0cbc4bc25018d1d1993997f94d33cc549abe761796135901b
|
|
BLAKE2b-256 checksum How to use checksums |
39d7fd810483ac60805557c42ea64a164585c92057a2bacc8ada49bc8cc43727
|
| 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.dev1782599698-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782599698-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 |
b2ef0ca346a87c11f3a1de815e87f27e4f6f8abd01a9c991681a301ff3275285
|
|
BLAKE2b-256 checksum How to use checksums |
2ce9d6ed0c093ef2decc8f217461e631c1d5713b4dabe9a1d91c1b1795585121
|
| 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.dev1782599698-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
0bd6cd23e2665218a9cf4e8f0e6a15be9815ca1d2ea501b7ead299da98bf2220
|
|
BLAKE2b-256 checksum How to use checksums |
d41a00485b16abe35189486d361113c4a15ceb70014152970b0d72b8bf547112
|
| 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.dev1782599698-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1782599698-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f3c048f256a856e1b84f8036364537851ec2dbb77feeae3c51d8f0b16f10989c
|
|
BLAKE2b-256 checksum How to use checksums |
40936083b4e0b8b4432f5387d8ba8ec6e8158d31baadc0d2e14bcf42d6319830
|
| 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.dev1782599698-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
dc44049fcc2553f81922f154d570f6548f7a2b214fa2dc5dcda6ea54c19b17e2
|
|
BLAKE2b-256 checksum How to use checksums |
101accebe7773a2585815f4b9d49750b227625ba56be1d4383c8d24c05148504
|
| 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.dev1782599698-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782599698-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 |
9cba5bc3d48af5d2d8ca160f739ffd269e75cac1d08e5a6b4fa00443abb1ca9d
|
|
BLAKE2b-256 checksum How to use checksums |
03eb3b4a006f35ff51c7249192369b5b4ac53b61b03358cec0dcdea9057ad67b
|
| 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.dev1782599698-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
91150ac67c09e535a5a7301b099742df4d343cc844ad7e755ba668fa2de9431b
|
|
BLAKE2b-256 checksum How to use checksums |
798200ad0f7fad7f7689adb5141f7e924c6a5e0cd2a8e6e3a21588ad89e90002
|
| 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.dev1782599698-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1782599698-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2f8ccff24f83c3af1dbb5c564b9beaaa3ad42d0f5cfe7aa5d3a91f9664b2e909
|
|
BLAKE2b-256 checksum How to use checksums |
42497d77d3652bfc29dba2f5195a2fed05cd1e872288c16920344ed5d089d095
|
| 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.dev1782599698-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
3d215852305caf841cf458540fee142c7ee046107a3a419252b1ed1517aca6c6
|
|
BLAKE2b-256 checksum How to use checksums |
75ca5b8bce41dc434349c461deb2e5ead6c806332e63d52b397d22d343824569
|
| 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.dev1782599698-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782599698-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 |
204c81880b3aca4d0c6da33a595a98482303f726ee7bb4946083e6b8e343c38b
|
|
BLAKE2b-256 checksum How to use checksums |
e78e29b99dc31bb48622532a0d366eee993650b887b401c44db9e95a793df2ce
|
| 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.dev1782599698-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782599698-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 |
b8d8163d86dd49d659c373c7f73bce1796f8e5ec58279d9bb896a2338790a826
|
|
BLAKE2b-256 checksum How to use checksums |
e41f9479fd067388e848226492a6bdca958c1665a714e8f0b5af0056c52168ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|