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.dev1782869566
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.dev1782869566.tar.gz | 882.8 kB | Details |
Built distributions (wheels)
Total release size: 62.0 MB
Release files / stim-1.17.dev1782869566.tar.gz
| Download URL | stim-1.17.dev1782869566.tar.gz |
|---|---|
| Size | 882.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b05d47188b8c166e0c5fdfc04612ffd5e716d5056f22806e3f0e772a32d2fce
|
|
BLAKE2b-256 checksum How to use checksums |
d3dba55e4b31b56e6363e260225587ce56c9f650410950a4e3dc6e43a49ace22
|
| 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.dev1782869566-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1782869566-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
492d472274111681649a5f567b745a0a433cab68d98a3ede9497b9eaf9ea7259
|
|
BLAKE2b-256 checksum How to use checksums |
f12fe59ef4e1275c8567aa7187430a0e27c2320c16687cf39c1aaea977ef09bc
|
| 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.dev1782869566-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
0391a226499ac5f8e09091aab59596990dda062ce7a4a2cdd63699dbd9f433c2
|
|
BLAKE2b-256 checksum How to use checksums |
ce4ed7d22e81f8eb04e7c3488f7b246db0d647f4e9ed27ef6c63989d5e4486a7
|
| 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.dev1782869566-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782869566-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 |
3e499ae3f5decca8c0d274c2cafd8a17ae9023b824d1b9816d9cf75cb2a62a3b
|
|
BLAKE2b-256 checksum How to use checksums |
d0caf1eb644c48c0e03c991eee0d5b9e984f6af50f62d16c829806bdd3b6b8d4
|
| 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.dev1782869566-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
503609761547c1c35016472d0df9593f78f59945b8a633439cb290f7bbe6cf81
|
|
BLAKE2b-256 checksum How to use checksums |
a436d2a7608a98000d324280aed3c05f3c23f5deed7f7c4fe10b93d9baf3a0c7
|
| 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.dev1782869566-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1782869566-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6dcad77ec05ac14de90f4a2433c094d9956013f4f9cba00acc26f89e5b169e9e
|
|
BLAKE2b-256 checksum How to use checksums |
e62ee2f021d51ab27aa3fa6afd2129318fd51a809b5e8c38a60dc8e0deda10e8
|
| 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.dev1782869566-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
2088d0133447e27209b59cc2cc0b58ff4b236186a32faa471aa3151ea843af8d
|
|
BLAKE2b-256 checksum How to use checksums |
331a868a54286b3c59b84ddbf21744c7d4ddb0c639e5f47f3bf7b0eb6105ef1e
|
| 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.dev1782869566-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782869566-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 |
8b4bfa28d5e48028e168c662720223f98ddea692e082b74101e59f4a7219341b
|
|
BLAKE2b-256 checksum How to use checksums |
8abf4be36e55df38e70d061ad5bfa34d36e2de94e1bab5a83a4d2d5532d87baf
|
| 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.dev1782869566-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
c77d51d64b46005f2030f37544bf49dd3316bdf5b3440434cc78e850b8880986
|
|
BLAKE2b-256 checksum How to use checksums |
045efe1e38268f526d0469de927685a70d600bae793e7bfd1fbe50c74462bedd
|
| 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.dev1782869566-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1782869566-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b437f1c22053674df662e8f726322feb58aa2887805e9f27529c9b9694efa6e8
|
|
BLAKE2b-256 checksum How to use checksums |
3e92ccad4c272f36b706e880f859f746dc0d55124df7653f6f4bd3ffd22d973d
|
| 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.dev1782869566-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
fd1c83f465de01cd61b8c293a02c85b60280220dfb3a95dfa1209cb816446338
|
|
BLAKE2b-256 checksum How to use checksums |
3d0fbcd949511328d210eee57644766bdeef6350e5da52a94a2799db77eaba25
|
| 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.dev1782869566-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782869566-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 |
1d7c7beddb9c8e14c8ecad0cf4c3647fb5df4f9366e425825a0bc02bf73aba94
|
|
BLAKE2b-256 checksum How to use checksums |
76da8c17dd6d47d2984bfead81f65db23727af5009b30e8f446e20b724eff0d0
|
| 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.dev1782869566-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
a4f126d154f12b4c74d7cddd5dc0814348f2e2b8a13f95fd89f5fae912a07ae4
|
|
BLAKE2b-256 checksum How to use checksums |
c9b9bc11afdb4a734bdcdc83ff9a308b3e931c87e0a3ca2ce0ac3c47c8c7f97b
|
| 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.dev1782869566-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1782869566-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a2108295e9cecaaa8a2b69ead31342b88e28a6e3aa6f1a442f1c8fb7b7972365
|
|
BLAKE2b-256 checksum How to use checksums |
1a24b6bf53946610512295e3311969cdcefd486ba550ae569bcc94cfa39c812e
|
| 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.dev1782869566-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
444014bcf1a18514e24ff2c7bbe22625688bbe37064b01e496fe81121829ed5e
|
|
BLAKE2b-256 checksum How to use checksums |
265e7075c9fd48721d6e55a050ae73e4fbdc6c1e16997afbf0119b5adbb014c5
|
| 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.dev1782869566-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782869566-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 |
f5f00b513b827486cc78953b24fe114baff5202722b98089e3a2a1ecec3cc3df
|
|
BLAKE2b-256 checksum How to use checksums |
e165ba2573aad36a4755e729603e576c0a314930359ee4e0ea72f9c63bd7dd83
|
| 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.dev1782869566-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
d8d634fc8b945783578b3eea47140d76e485caa9543991ae5710f83acf9b5f88
|
|
BLAKE2b-256 checksum How to use checksums |
5ebf8232024a775f74e68a4657641e18912c84741dfc07202a83f4ec5c9b646b
|
| 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.dev1782869566-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1782869566-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d2585c62584147ef4b5d305201524dca4bc06087d807c60e2fe0d0d19fe59792
|
|
BLAKE2b-256 checksum How to use checksums |
d99414a33513e4df7576dcba4fe55eb10ed9a33f1708cd35b0e67557824bdc89
|
| 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.dev1782869566-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
bcda3e353606d215b1b9cd70560a45921d96b53637d4b300ba32919696f04361
|
|
BLAKE2b-256 checksum How to use checksums |
57ce52dff7cf4496863a4f8d8a63d116d9ee0e6b0f91bbe5af201abbb46fb178
|
| 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.dev1782869566-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1782869566-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 |
98a7fff457f51e74944ea5872d9129be8f959fbe9c522168c286f87aa67c26f3
|
|
BLAKE2b-256 checksum How to use checksums |
7499917dd4950cb8dd76acd16098da581aa7cb5a76c9202b742cf397c6d57f2e
|
| 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.dev1782869566-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1782869566-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 |
2e61e284fe571700f8c37869fbd1d2ed351dec13afda6fd481bdb178f6f669c1
|
|
BLAKE2b-256 checksum How to use checksums |
346f7030873c1912ef856b945812f44ac3239d5358021a5f35feba34d6c04575
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|