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.dev1789689440
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.dev1789689440.tar.gz | 883.6 kB | Details |
Built distributions (wheels)
Total release size: 63.6 MB
Release files / stim-1.17.dev1789689440.tar.gz
| Download URL | stim-1.17.dev1789689440.tar.gz |
|---|---|
| Size | 883.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a28948e98079500ed933722cedd3ed10a6645c2426350a384fafb13a51e32c52
|
|
BLAKE2b-256 checksum How to use checksums |
877ec6cdd4ccfd39df99a45a168eb2caebd0aa4922231c3662165d1cb83f5e66
|
| 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.dev1789689440-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1789689440-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3db0b310fe1bd15cc4d3ff7863ae0afea91df37ae96d746aed9aff19fdb7cad9
|
|
BLAKE2b-256 checksum How to use checksums |
8977bec130e2d5dbe013ea00a3bffdd5414622aae4082e3ab0caeb084a892b75
|
| 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.dev1789689440-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
10e80b58fb24f7a7f24ab86667973d2787e794403a8463e254b75d93157a1cf6
|
|
BLAKE2b-256 checksum How to use checksums |
bd4367317f4c347b158654f82ff91d82e9901d5889f085c41a1aac7c31aa8de3
|
| 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.dev1789689440-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789689440-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 |
84893cece13ec1d5aded05d07502cb32d13e9b93192c86c529dbc056e243f4f9
|
|
BLAKE2b-256 checksum How to use checksums |
4fde636a11d98975af9c08693b00c3787d5099ad612492ad84115f19270b74e9
|
| 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.dev1789689440-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
3abef43609e0ea4e4b46968c636a88d2fba3a2de83d196ea50556c4692277741
|
|
BLAKE2b-256 checksum How to use checksums |
0bf40d5c998453916999c90d81516d7210253e6ccfe41597ed07b7074ee0b339
|
| 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.dev1789689440-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1789689440-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
058b0473709f6937954f0a147fed2a27d434b262f67b34f5329f28d831602712
|
|
BLAKE2b-256 checksum How to use checksums |
fa7e924eddc459f697352dc8c20fe4f2760af0e1c43de59e1a0500cc2fa42967
|
| 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.dev1789689440-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
4d3797ecb1407ba1706f50e7a05470d996d07acb5592546fa816075a8283b601
|
|
BLAKE2b-256 checksum How to use checksums |
7a0b4c7dcba41d1f46abd0f4bde55736ec043ba3ac96952b868d3f0ce32fb521
|
| 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.dev1789689440-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789689440-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 |
d0b5f554d2eefef775b0a78c2f81f8e0b5c0e8551b15719d0415ee3716ebf5ac
|
|
BLAKE2b-256 checksum How to use checksums |
8deb2448dffddd0a906e29d4f1f06bd694036395c4ddffdf31bcbbb1fc00bb1d
|
| 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.dev1789689440-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
ced224c0c162368bdf02ab8c010630bd222b3f161fb0918f348ea236b7d75710
|
|
BLAKE2b-256 checksum How to use checksums |
236d9cde673ac7988aee19a02e7dc6400a8cbd1597ce1008d7de217da224df5d
|
| 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.dev1789689440-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1789689440-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e38728fd874bb2c528ae39cd7c757e47b7eb7dfed7dc499dfb472d2ebd7c5836
|
|
BLAKE2b-256 checksum How to use checksums |
321a60ca2f9c53dc1182d2ac451f3578ad87019c989cd41a58d47b54aec303ea
|
| 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.dev1789689440-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
9018040db4efcbf9c7b035570a5a5b6bc97ebacbad983bade8599619f5068ddd
|
|
BLAKE2b-256 checksum How to use checksums |
771ba2300de51cd9fa3c7c65d46169928843367941a568bcd378853e6a6c64a0
|
| 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.dev1789689440-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789689440-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 |
ecb24f09f3215d6b6409cd4c0a358aeec3f5cc8b5101499cdf0755563609f3c8
|
|
BLAKE2b-256 checksum How to use checksums |
87d770ce6f51946576133d47da3d0e2713dad3561eadcf387048502012ad1c91
|
| 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.dev1789689440-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
b37e69c44ce4d1ca4ab56de3ef8c5f95e2ef3b1b1d7e2b8349ff5d295c573e3d
|
|
BLAKE2b-256 checksum How to use checksums |
8790db2e5e5b4d71741a68d43e73ecd035463ff3f1c27ffe2278cb902fdc9be7
|
| 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.dev1789689440-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1789689440-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
09c3a91dbfd716ec2302bece37ed449e3b8faf86ab5cfd17e87179b5997a395a
|
|
BLAKE2b-256 checksum How to use checksums |
9398f444b8d7dc6e9ebd8b6c8b9012c4609384e396b7ce8680424117e48d0444
|
| 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.dev1789689440-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
44e32258107b512a7b06572aa6675e8cfd63924734582806399c932f30860e3a
|
|
BLAKE2b-256 checksum How to use checksums |
880341fab97eebf16a835b0e70ce2e497c0028a4b902a9d5ea936ef40ca1fc3c
|
| 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.dev1789689440-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789689440-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 |
9b698fc9eeea74ad7adb260606279a17919e47705e441cb91d77c7f6108c77bc
|
|
BLAKE2b-256 checksum How to use checksums |
385cede436fe27d0eab0614d04fe088ed364e7d9ebfa81b8347758bfe88c9a71
|
| 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.dev1789689440-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
41fde6842ac471c2af7393f1cdfaa4c1dbb1012bc1ffa5260a6d11882ca361ea
|
|
BLAKE2b-256 checksum How to use checksums |
1db9c96e3061a34f032bd26574696f57ad8b288d10c9594b0d0bf6c0fcb27877
|
| 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.dev1789689440-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1789689440-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6d8a0a473f6a968e2b507d8af7f64d37605564f6b7cbc03b19235fb882e815a1
|
|
BLAKE2b-256 checksum How to use checksums |
a398ce6704fa12a40e6dae928836b169c3cbea21961503534de327757ba773e3
|
| 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.dev1789689440-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
5c5d12b3ff72604a97abdd17a887b832027b982e4ed596e763d785bb80d1586e
|
|
BLAKE2b-256 checksum How to use checksums |
a3a665f6b13d5e2bcc71dffddca02d3efdc98c4b412f54428d52d7d3690c5a22
|
| 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.dev1789689440-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1789689440-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 |
f83865dea6e533a01396f5bb3b715ca8722b3e9c894f771b1ede95e7dcc7d057
|
|
BLAKE2b-256 checksum How to use checksums |
8ffdaf9e1e2112e317f435140eaf45148d798b7362deb22691cf0c0ffbdeebbc
|
| 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.dev1789689440-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1789689440-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 |
addaf79fc53c4cf824aced6a773b6298311e82425a99977f02145e59122f8eeb
|
|
BLAKE2b-256 checksum How to use checksums |
a0b08a1e74a724d0905c851a571efac3b2fde14352fcbd2a29fad7416501da35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|