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.dev1791843863
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.dev1791843863.tar.gz | 885.3 kB | Details |
Built distributions (wheels)
Total release size: 62.1 MB
Release files / stim-1.17.dev1791843863.tar.gz
| Download URL | stim-1.17.dev1791843863.tar.gz |
|---|---|
| Size | 885.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d93c58f9a15af5787affab55e390b4cbcbeaa53f00b90c9c35828fa1a2a0ad11
|
|
BLAKE2b-256 checksum How to use checksums |
f38bfde6af80b117a56382a5e9e2aa4c40721a9350d96f99564a59a3ab0e4e6f
|
| 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.dev1791843863-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1791843863-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
bdb9c9b2c02935f44632f403cc1623a280671ca9c09d8547052f96957eeeef57
|
|
BLAKE2b-256 checksum How to use checksums |
d0a56a44d3a5ae9886cbf6e534d3362780e08c19645e6ad03b011f6edcab89e5
|
| 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.dev1791843863-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
7be4c5c59eae159fa9454df9e6bdd170dce93bbada5a8aba52ee821ddf50be34
|
|
BLAKE2b-256 checksum How to use checksums |
c98ff5bc5080121ab4800ddc32a765308d3cde793c0ad51f6032f0b08e7168c4
|
| 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.dev1791843863-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791843863-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 |
d58243984146329f57faee4a2b80cf8c69439b6266892bf61486652f4a5e2819
|
|
BLAKE2b-256 checksum How to use checksums |
0ea5e2009e15418c080a70697a5ba0f9c86e99b740021be11472685fd7c6e814
|
| 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.dev1791843863-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
d120819b51d179af51812d2c2092e5d23b813b835f5f7da2290c20f8ce95cf3c
|
|
BLAKE2b-256 checksum How to use checksums |
9f53cc0209bcb1e5d122049674658f6bb2491cae99bfe8793040664b5189f8eb
|
| 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.dev1791843863-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1791843863-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1a7ca3b4930a785a002b2dca633dd588fb488d189618f72009e09861fe5066c5
|
|
BLAKE2b-256 checksum How to use checksums |
27b017dae02103f76ffdec90a8fef22122102c6080a9c59cce200fc23efb4b80
|
| 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.dev1791843863-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
c3241b5d52172c58cd79df92b5153c37ca72be047b28d9594f3f9731f0614cc0
|
|
BLAKE2b-256 checksum How to use checksums |
632bd5ef74ad261091c6279edba13c3a07ff60a1fea45d37f81440e9d0bf0835
|
| 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.dev1791843863-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791843863-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 |
b39a88f0a96c79594a6277df55d566a107932c5c4111ff6d178da9298c6485ba
|
|
BLAKE2b-256 checksum How to use checksums |
7ce20e9f29ebba265e6f2a67b87001de29e47a3f24901e3870b957deaef5b0fb
|
| 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.dev1791843863-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
6bc48a044bfcd402c3018a7d531fad9cdd6cc0eee17897298496660e0fe7827f
|
|
BLAKE2b-256 checksum How to use checksums |
325811ff060defa3b5f7a7616404105f2f414f6ad099e5382bd67e4381329532
|
| 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.dev1791843863-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1791843863-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
71e367f3fc5db45285bcde4f9c71dcc1cd659ace6c900bc28f18b3ef0d4621ee
|
|
BLAKE2b-256 checksum How to use checksums |
1fdf8b442e3eb10751e595083d252f9ae5f096d2e2729f19d4098d36fef9f935
|
| 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.dev1791843863-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
4d659dfbf37a032b1561bc6595dd5e1ba62be915551690c9945f5dbe05de4a65
|
|
BLAKE2b-256 checksum How to use checksums |
7d82b1e2dbc39673266b9186494ecb9d73390b164c412ad30c724b31f1ce04ad
|
| 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.dev1791843863-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791843863-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 |
157fed1bb5a0047fb5eccd51bf8b210130590d47c5fee023d9297c734b32d211
|
|
BLAKE2b-256 checksum How to use checksums |
fe91c25ae09068fa5b254fe13d73e6621247c6b53cbae6b26fedcb2fc543c7a3
|
| 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.dev1791843863-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
f4dfa83fc43cddf9629f5413cfacaeeb9fdb32b160e3247b2ec53dd226d2aedb
|
|
BLAKE2b-256 checksum How to use checksums |
c3e05f67c7e575e3262532a897ee1392ed43b6e1fda94232c07c206d5bce4bb0
|
| 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.dev1791843863-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1791843863-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e604fc6db52eb54b5118f535ad4a796daace57701c3711f978efe5eed69778f9
|
|
BLAKE2b-256 checksum How to use checksums |
b46c3f5dfce28614e36c2625d5454ac61310dc6a119c3582020646c830441b35
|
| 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.dev1791843863-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
4b302e7575e21d36bb357aa42d279dad7b0345a1532c440451a7815308e89e8e
|
|
BLAKE2b-256 checksum How to use checksums |
b77851d86774e9afdc668879bd4dd5ff3f1a3bb9e89697ad0f629742a2c86351
|
| 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.dev1791843863-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791843863-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 |
4c470e049dec6a7cb2960fbd67d4c2ee405e0fe1bf7234a5d809b7220993aa23
|
|
BLAKE2b-256 checksum How to use checksums |
16027b8875f94822539771a220508778ad98e0755cccbaac41d4ccac55a3ab6b
|
| 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.dev1791843863-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
873eca83dddb5bcb3ef28b9d7b7ac91eaac391f3373588a435411976711e1032
|
|
BLAKE2b-256 checksum How to use checksums |
c64c07c73aebda18967ddc5454fc59597b76b5aeda6144ab6cc06f7937362566
|
| 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.dev1791843863-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1791843863-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1970b1c25adff9a03aea2a60271b83e764a169c74098e8df2fa2e2791f36b713
|
|
BLAKE2b-256 checksum How to use checksums |
76ef3982b7f98614e804836da7a8dd05d49d8ebd04ab124abcbdf1b50febf702
|
| 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.dev1791843863-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
4c49eaf1beb0ce0ecf9fd91c88a49f25336d72293cb308c50161b02132ed17b0
|
|
BLAKE2b-256 checksum How to use checksums |
92875966e18472ef7e0cda3aabdfda4c593b3c677053d8d301e70fcd992db424
|
| 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.dev1791843863-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1791843863-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 |
cec0ad10c5ec503f4d21b3d0e942660be3702cdedf2bf81cfbe754039b78883a
|
|
BLAKE2b-256 checksum How to use checksums |
17ac7940066c0c0654fda9f69c28fdf1ef810588a3ce0fdd279f94edf34cece9
|
| 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.dev1791843863-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1791843863-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 |
e77daffa9bf0e741e4a853efd7687ccaad1ff91dadd21e5cba293c5dc7c43941
|
|
BLAKE2b-256 checksum How to use checksums |
bcc98fd5b570113ba4675528e9ee53dab9861855a726d728a425b3f6ae4ec988
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|