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.dev1780685949
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.dev1780685949.tar.gz | 882.7 kB | Details |
Built distributions (wheels)
Total release size: 60.9 MB
Release files / stim-1.17.dev1780685949.tar.gz
| Download URL | stim-1.17.dev1780685949.tar.gz |
|---|---|
| Size | 882.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccbb4353c70ec70a57a17fe39e93be8457f086758204ff5294decce043449298
|
|
BLAKE2b-256 checksum How to use checksums |
3a44db61199c0562973aa7d24157da443015a1c1be180aaafab7a774fbb06333
|
| 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.dev1780685949-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1780685949-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2b3126df9718aad2e219bc29a3bfb3b56eaae2b0978a09aaefefe014527a581a
|
|
BLAKE2b-256 checksum How to use checksums |
1cb0d2d78144f65f69cb0ef5ae808b7a2316463ce5368575c2314cc5e942275d
|
| 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.dev1780685949-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
96142f837772baecf8f0cf15ed40e56e3107cceeff1919de6885e80e1596fad5
|
|
BLAKE2b-256 checksum How to use checksums |
f7bf251f1225aa0bc76620428c7dbbbd3e422d86c205734a0eaf12cf2063a751
|
| 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.dev1780685949-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780685949-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 |
79ae3ca7561181738187f22e85b35f6bfe5dbe57a69c668bb4f289b54ec5b86f
|
|
BLAKE2b-256 checksum How to use checksums |
6bfbe78b0b1a06e87a735fb39983a4a57b2c4d5b2633a42c04b2790b6dba9e38
|
| 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.dev1780685949-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
0ca055489f9067837a419581d97948354f80e6ec840f78fa5169aa842c9f66c8
|
|
BLAKE2b-256 checksum How to use checksums |
8831f98e920b13f25222193e807dcdd3a154653c815a7eb847c4c947547812ed
|
| 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.dev1780685949-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1780685949-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1fb5d937ab0ac1aa7b84901d52e79cc5a285d8e71bff3e14abda7d49e4d3b976
|
|
BLAKE2b-256 checksum How to use checksums |
299ee9bba2d929957f044e27685b9c3964c2e91ccb29d721c07d7c38e4111895
|
| 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.dev1780685949-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
e98328749810700f03441d641fdbda89acc223bb79751bafb40f1960a06552ee
|
|
BLAKE2b-256 checksum How to use checksums |
78fcbc37e0e6e9ea5aeb40880d8338a074b2771c5967cdaeb6440911026bc0af
|
| 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.dev1780685949-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780685949-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 |
138f6d6fa64b918294f22b4f1ed1b8f73ca53969e78dc849ef0eca0341cc266f
|
|
BLAKE2b-256 checksum How to use checksums |
6797f4698c42b63f467c13f1125170226d96d514b8e746c5a80987a858b6cef5
|
| 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.dev1780685949-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
a052e6df0fc6fe4ed87d5b4bdce6b6dad512ce98985831f93c42be0a6d8d8c64
|
|
BLAKE2b-256 checksum How to use checksums |
4c4d64862689b463b38242c8fe0dba50666fa4441f0d66d0c617d2eb9cabb52e
|
| 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.dev1780685949-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1780685949-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c72ef9d64aebc79fd4fb098b7009733a24089a96afe9ae413cbd9e34203b96ff
|
|
BLAKE2b-256 checksum How to use checksums |
08862da300aa7388018efafc14e6143b5783248d5f344a58d2542a3a5bf9ae0d
|
| 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.dev1780685949-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
f672d3983e31f85574e0890f917922fae06fd6f5a588dad15bfc7be3de5daece
|
|
BLAKE2b-256 checksum How to use checksums |
0ccf6c3c83ec22e2b543d841809e607196b92c52d8847e72169c52053e59e4b9
|
| 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.dev1780685949-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780685949-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 |
29e1ff9b39d2cb3ee4e97d63be2d9f73f2df882fc98c4dc4c7f68eb5445f4eb4
|
|
BLAKE2b-256 checksum How to use checksums |
a9095663c26d2ce998a2710f46bc984f01d0143fc1995208fb1c3918a3bb06d3
|
| 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.dev1780685949-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
c768eaf217792256ba95e4aeeaad553c5bca516daa836c85a7520a0758d306ba
|
|
BLAKE2b-256 checksum How to use checksums |
fbfe5f6966fcc495d307ba47e9936d251560ea3d87dbffb4d61b3090de833fdc
|
| 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.dev1780685949-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1780685949-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
89e008b4da7589634787ed5d465332197f701721c138d853bff62950b50110d2
|
|
BLAKE2b-256 checksum How to use checksums |
e35b79b6c06f4e6344aa1cbed084035b9b6d09e2f5054e5ab274bb21e9e14882
|
| 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.dev1780685949-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
422e8d22a1788ad4035ef419f591f082ba9f7c461ad1384c586148ef06328f6b
|
|
BLAKE2b-256 checksum How to use checksums |
33a5b0068d37a351df4724799539b1ee8b1885562e9510d06bfcbc803850869f
|
| 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.dev1780685949-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780685949-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 |
7d0b863fd11dba04d518c82e7ffbba1c3b8c7d73b3c6fd8e500910ef75b71025
|
|
BLAKE2b-256 checksum How to use checksums |
05d0ea36801fc7a66002759fa74c23eb27a91fd2bcc6572e6681c9c77a569c7d
|
| 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.dev1780685949-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
afcd8593c5c042778194794d70f2eb79801097f959f85a2d6f72d149341a4a65
|
|
BLAKE2b-256 checksum How to use checksums |
7d3166c24000a701be0a993f7427d77b74033d1f591951a5d9410a8327ced38e
|
| 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.dev1780685949-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1780685949-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9e7b445eb232a061f8473d86ebcf4e5ef73ffef16fef4929b7f87187cabc8210
|
|
BLAKE2b-256 checksum How to use checksums |
fe2a018bc1f20616251a1e3525df7940d145f3ba428e2b94d98df3982627d2fe
|
| 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.dev1780685949-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
ecdab61a5310886537175c8ee974b55304a9c3a2f69272227057e920c5d7595a
|
|
BLAKE2b-256 checksum How to use checksums |
a7afd75d8f141f4613ca542e4f578f96ed6443869a2b6a607f25c9a360456690
|
| 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.dev1780685949-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1780685949-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 |
141ae3432f56893d563b8e88b872e7e4c710ebb7098091dba207d85b65ebebc1
|
|
BLAKE2b-256 checksum How to use checksums |
303531d160d0d54a2de1e6195082e289fae0d01a4226a16a9dee8aff7e8d37f1
|
| 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.dev1780685949-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1780685949-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 |
d966f7d586a97b0db5f139c0ff89373b183af22ba27d05806c1cbe3dcc450590
|
|
BLAKE2b-256 checksum How to use checksums |
a03666e1b80d4898535645db9efa55b1d037d328a174455e07be3be0ce7e2fd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|