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.dev1783227814.tar.gz (882.8 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.dev1783227814-cp314-cp314-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.14Windows x86-64

stim-1.17.dev1783227814-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.dev1783227814-cp314-cp314-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

stim-1.17.dev1783227814-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.dev1783227814-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

stim-1.17.dev1783227814-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.dev1783227814-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

stim-1.17.dev1783227814-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

stim-1.17.dev1783227814-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.dev1783227814-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

stim-1.17.dev1783227814-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.dev1783227814-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

stim-1.17.dev1783227814-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.dev1783227814.tar.gz.

File metadata

  • Download URL: stim-1.17.dev1783227814.tar.gz
  • Upload date:
  • Size: 882.8 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.dev1783227814.tar.gz
Algorithm Hash digest
SHA256 112b81e1370f346be1c1487cdb4420f1e948df856733c9867cc230156ed748c7
MD5 a55be61660bbfb1864280d1a0dec3ba0
BLAKE2b-256 540a83128f3d59391fb836fe0220fcd7405b39fd07de7144b39a274193caa5eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d4ee2a7c9cd2a6321df76fe77bc79359993971742542d25cd34fb670d16a0a01
MD5 fefdb84d72d17e83bac20cc1941769f1
BLAKE2b-256 5f4b75de98cb9d5fe132fcdee701004433a3d7f81d85299eace69cbec1c50983

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ddae56e064a9eb17885f5e8c9d6aa905b13438765ab1abd68bc136050375a59
MD5 3727ee2052e1172a1950918891529e19
BLAKE2b-256 d544e5a145dc06e7f932215635ec4f2dcb568158767735717ab45257051922fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc516cd28665b08ca82c8c2c55db0a31a4c1e593a42810f87bceb0eee59b1130
MD5 fe1a140e8c95f6521dedaeb4b5cd5cb6
BLAKE2b-256 6644758fb10ffbf32bcc6bb3d1d7f0f0c599db0108faa20517fee5a361926949

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7a2916c481b70654d4d0442916a43c6e3b609fd7fa13cb9f8620dded36a7c135
MD5 1550696ff6614b8991675f62f7e09077
BLAKE2b-256 162a13b0a090548934f92b630567acb78ecbfe0b9750aeb24802aef88f4992d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 14462a8a07acbaf9f6f06454e4e246c03f32305936e2addb984599aa3f6c66db
MD5 87f411fe1a728df4cefbbd662184d72c
BLAKE2b-256 872312522392acb0696aafa3b94eac673babc19ea03b6eb2cd7c649271757aa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 828223ea01dcb0a6ebe12efd56a35066ebe4c336f49f86e2c1b6dfc03da6f08d
MD5 5caf45bb93d633785dfa089f676791ba
BLAKE2b-256 81af7dc3ac2e112b3e7208a737227ffa4015896b59ea179c8bcd62174042d7fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f764aec60c37d8ff98eb7522bc4050d62f7a3ec33dabace5b870b519beebd08a
MD5 cb027b9aa6484a3a96a49b119630fdf7
BLAKE2b-256 e1416887576a005f2e753927df32959c89681e7be71e40167b43ecac6cf06f84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 160843af4b315e3ee9be7b9794d743066a1dd13734f1a04132ea47c6d50eb823
MD5 5c4b0baa89a80891378fe7cc420a5cde
BLAKE2b-256 ac0004adf704f92d4549ad73e1b60883673d956cbabe2520194d7f24e674e188

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 86811fb8be6ae0dfa71983cb9d05b0e49b4b7afc7f5c94363616936205d2b26d
MD5 9a1f1fd165b81e6fdb13d21ac519abb3
BLAKE2b-256 8445421118a1f4b235173559ddaf6cc96b158366532647d606825988639e11d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 748c26bb9a0e585a3c8e4ee207effb727268f69a70ed44561d77f79f502d817e
MD5 e85a4000383bfcb8d5b28982b100557a
BLAKE2b-256 c4f210e27a4c23f0704928ca87f97040f7400b0ae34e3effcb94e64411f4bea1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9320d6cb6badf9a000e11c5ae2f92aa4853c16b6d58284e50b5a8cb2d42ed8a6
MD5 5270d7aabbf25baef4e698b74f8a1054
BLAKE2b-256 e52cb9abe061697de53fa483528583e203ab7b9ccd7c6e947c73916651540fe8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5a31de7c0718c047a16081e4a6aa2cddebfe8a4c2795049934a584b7a5e45bf7
MD5 d9b9c189a95c3af500a283effd1e1b0a
BLAKE2b-256 f2e747664bc385d87aedaee0dd08427413685a441b59424fffcde17c8d2b6de8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8138a727be6f9321dee7c47ce318c2a3e394e83823aa4a902428d9db7bd593bd
MD5 7fd71292b1226ba191be0d569cd46918
BLAKE2b-256 67e1993358b40118d0497516721b065918279578f9730a241524db053f7f77bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f28551235aa6b2fd8e4c00e7ad5330c17806643cd6155de577ed02febb0696f8
MD5 748b7b9fa5d488f0573d4e5bf7130a0c
BLAKE2b-256 060ad36bac59b0fabd69ef0c5e373f4f6b072441266e95c654a37b1913a3205c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 319cfa83bdba890c7bfccc5ab45aa47b9798084529a37f649069e765d7c87816
MD5 7dd71a95e330282882d63c92beee563e
BLAKE2b-256 f93525d6cbec253798b6f908d5146b857cac176a549bdd45e6f40edbce6ff82b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 66013a574294614f7119f644183386854c4ab8298025133d67ec98ea1e1cc0aa
MD5 1679997664e1b19ce829bf6adcd69f33
BLAKE2b-256 631f8fb4ba2f17f574003620f5d97134b19ca40f52436d30cef431bd5437abfa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b4ae8d370edcf9fc52830af84d7a10e2d35235da36fc114c09f86cffcad5965e
MD5 26a728766d17c85393ae9ea5a99a4d9a
BLAKE2b-256 5ceed4e6e84441247f676cb4c87342e0657aee422ba62adfd1741b27e849a08c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 caa809df81b7844079e64e0a7c78f0753735f93d42e3c6cab5ed5de1e146a273
MD5 a8f1dfcad5d07787b0d143adb122f704
BLAKE2b-256 ede1b3c5a82e1cf49244733fefb712a4618325381cff9a15382a2eee539bb3c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1efd5a0e3a7fede04d0f2a4126ff919e46f977410307cc23de4e3c529c05b4df
MD5 049d87ab291eceb27cb87da248e27e79
BLAKE2b-256 ef1e7697444e4856d4c765eea94ff928ba9ff60fd18caf006e4c50a233c1c048

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1783227814-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 95362eab0af5322017e1f4c885faf433a6af2a09df021f15058757bc2921cea8
MD5 12eecc52150d89a598af16dffa5e0988
BLAKE2b-256 d36c9a81dbaf30607ba6bbdca1529c9225c63d5a8709cdea0339cf5c66aa6fa0

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