Skip to main content
Pre-release

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:

  1. Interactive simulation with stim.TableauSimulator.
  2. High speed sampling with samplers compiled from stim.Circuit.
  3. Independent exploration using stim.Tableau and stim.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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stim-1.17.dev1782863113.tar.gz (882.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stim-1.17.dev1782863113-cp314-cp314-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.14Windows x86-64

stim-1.17.dev1782863113-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

stim-1.17.dev1782863113-cp314-cp314-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

stim-1.17.dev1782863113-cp314-cp314-macosx_10_15_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

stim-1.17.dev1782863113-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

stim-1.17.dev1782863113-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

stim-1.17.dev1782863113-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

stim-1.17.dev1782863113-cp313-cp313-macosx_10_13_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

stim-1.17.dev1782863113-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

stim-1.17.dev1782863113-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

stim-1.17.dev1782863113-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

stim-1.17.dev1782863113-cp312-cp312-macosx_10_13_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

stim-1.17.dev1782863113-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

stim-1.17.dev1782863113-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

stim-1.17.dev1782863113-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

stim-1.17.dev1782863113-cp311-cp311-macosx_10_9_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

stim-1.17.dev1782863113-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

stim-1.17.dev1782863113-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

stim-1.17.dev1782863113-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

stim-1.17.dev1782863113-cp310-cp310-macosx_10_9_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file stim-1.17.dev1782863113.tar.gz.

File metadata

  • Download URL: stim-1.17.dev1782863113.tar.gz
  • Upload date:
  • Size: 882.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for stim-1.17.dev1782863113.tar.gz
Algorithm Hash digest
SHA256 dae5bbee6c1b91d5c003328a27d91891f126d65625a839d33a97934cddced1e0
MD5 1773c3832da709668b26b30dcc1109be
BLAKE2b-256 78d5f6f6af7f5db653c4df84b7970fb97a9f8b2506d2ae363ee6388ef200978d

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 342ecfe15840a4e89894a0562c6f2a2013d2d8952088cefd71a4042a4f629f6d
MD5 83cedfd4296b2be27ddc1b4254e71169
BLAKE2b-256 12702bafc001c9e04f73f656d858d2b7ec71f9b5b6efff89c63374419ec8ca69

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62d65ab2ea3fb8dd28a3923a2925bb1f13e61e1597201ea1b8022a185d1fba82
MD5 3b03b3c7ec7879625226ab50088cbc23
BLAKE2b-256 f2548762e8afd3e6a969867308036f2563342932a067644bc83d108f50021066

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7542c7bb223b4e8aef2b3e407639b484c8b93a96ce522d1226e1043a12d809b8
MD5 0a7ea5eeab3984ce5f51d929a06a3106
BLAKE2b-256 b0d282b863785b1791338327aff35b0d3fd36a5a4799facaba4075bc696f3140

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f94c876dcf776e11017df213fb93960e73197b45f5e6b1a8a94131eb8a52b3f8
MD5 5c9f63f0a5326ec8721ae61e302718cb
BLAKE2b-256 09bc64d55c1867d64cab17019759df70aeb8d6eb6c4b34c376b60a4f6cf7965f

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 586a9c2a2e469d05bde4abaae184f53bd075b47c2d1ffce1c157321ab866fa19
MD5 21e2ffdd7d24762f6ec5e3950a8734b4
BLAKE2b-256 1feacee8560bb2adcb428c6fcd2f1a72bffd846a0e50c6d8ef3c1ef695630ded

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a0391b26cebef07d320c739aa149f1d67df3bc2585b0c8c74e48a730e6881853
MD5 9d289230cd9302f010bfbd8f56d8953e
BLAKE2b-256 535dc7075a3444f70fd14488df930f624b340ff42263e0d56c2fe90e98c452ff

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35a080710722ca80920e375a0fab74bd30f3f46f1b43845c820dab200da9fdd9
MD5 b7071d712378d9f6a6a6fe4d814fca3a
BLAKE2b-256 a5ad714113880001af0d50276bbad7b71bb3c3f9cef1fe7347b2618deaba37fc

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a9eff68b22b74cc2774bcc7bc46c6975f1a96717aadb10cb1a6c3725aff3a5a6
MD5 e191e3f56e85f747c5e65d7379b61e63
BLAKE2b-256 b2c44864105e8c50eff1ecc35a595291ea657fe91af33319cf1d079bae2a158e

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 14310f01e2c239c782b16a1720a86b65404a527b10eeb842989d9119db236865
MD5 8c6db2d6dac81ff1674318b9f7bb2e77
BLAKE2b-256 a7fd6ddda6280dc75f86d534ba3cc3a002a5368981877e062e4a4f62fb25b7c8

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d24f4ec38181ec0bb2c30d6da03807a28f358e41e7d2b4900abe75e2bb9b0e5
MD5 5ec3eece658a4e8816cf607f885d9859
BLAKE2b-256 f5f3d6c792f268c132fd37cec7b1de264ae1fbe08602665e0e44a8fd4ff732e6

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae7248e6811b026d835a5a5bd9c0efb9cbda31691a5375f66c556e24f7a586f7
MD5 d216fcdb196062958abce43c79c43cc3
BLAKE2b-256 84c887a414f83449005907b06fbf0dc13f6728a54087950286cef52928bfcaf9

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1ce91d781aa00b930ac5abf6459216286e5fa4a9a1a456c2d4782810b5d3bdfb
MD5 14d7e0f00fbc933bf212eb0bacfb0337
BLAKE2b-256 05f6cfc04873e649bc220630314e6d5e184eccaec4c9b6b88c0bc79fa0710a53

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2a3aa519dea788bb8ea3eaa630f08ab6a04e42b391ee486929f0057a0735414d
MD5 dc97f60b677ae2dc87cc16c2e2553ab5
BLAKE2b-256 76d4a94fe1de173d13508164f42675da964ff6257c647f033d25262cc39edf41

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66b791dc1e3f1aad727b356073637c2fedd864eac1f2bfc03c54157fede6fad9
MD5 5ce54e732ce97718e60b3c6841d52847
BLAKE2b-256 f43040f6f40cdfe5dd48adaf9599474a8beaff9b6b0851f730b1445679da08ca

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45fcc47ec7d832be1491abf24c91fb8e814859d9dcd443f2f107221fd06697f5
MD5 05b614d54d125dcf8ff7cbf890f7a79c
BLAKE2b-256 d9a2dd3beea7718bb4feb60c75bdb31bcd7b8bca2fd4a240a45cb15f4c243ecb

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 293535a46ba32a47beaf0f42703436a79f5d36b437cdf32ec7941418c65b1596
MD5 b1ea0557bf069b97426ab28045c7315d
BLAKE2b-256 d9302f49d44a8030aca1f0cadff09cd6b4e6ab92e606d2976ff9523df38da1f4

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5394ace9e0271682325585e6ac1e8ad6ae9ea14213217fdfd8569bbdb316f489
MD5 ffd0645c2fcdcaaddd7b42eeb2db4934
BLAKE2b-256 2f804ac9102fc02ce82d3f2d9d79a3a156016a0c322ab575a77b8f588a48e087

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7499641ff17dd2b59c1ba67f13f774208dd9ca766722a6cb5991e04a9e7b1c56
MD5 f90c6b63442fab1d0c290e0107840739
BLAKE2b-256 0b73786af7f66d128938948ae6d78ddcc423902c217c719c70121522baf33427

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3c19a463c25ccb6d2c1d30ec55b3f7a98419beb47a954b709e64daf30b24d8f
MD5 769de3f11eaa30ee1f453029853c4087
BLAKE2b-256 86b234cc294d663891e55ad47e867bd1772b4dc0b81d610eb1f28a343c27beee

See more details on using hashes here.

File details

Details for the file stim-1.17.dev1782863113-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for stim-1.17.dev1782863113-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b4b5a320a5adbe9a334e22b02c7fafcf73b70160a8a8e809a9a209e72d508c66
MD5 bd6265facb025aa0b6a362c5368f5fee
BLAKE2b-256 7fe944648bcc940a0a6a216db5ae0385dc9059e7c6f15da6c4ea0b4c3f2d3644

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page