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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

stim-1.17.dev1784096857-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.3 MB view details)

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

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: stim-1.17.dev1784096857.tar.gz
  • Upload date:
  • Size: 883.1 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.dev1784096857.tar.gz
Algorithm Hash digest
SHA256 920c089dbc0360d3da9a181e25a649fa1a1633ae909c414d66d1114832399d78
MD5 2f915d974ffe3d3c5d5c432db322e876
BLAKE2b-256 31550c617dcfdb60c0f8b7cacf1f0ec07394757f1b42fd24ff143bf736cd6c66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8899dd9ffa1ecff94e766f9c96fd4ae286d56595ccc6f5ad367fc952a3825a67
MD5 3b7560b50095c527076bb980122cdd26
BLAKE2b-256 62fb04f1b76aa070cc5b7bb7878305b0846533655e25f53634bd8ddf049c026a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a92a15b802cdf7f7aaac54764916ca74a212583ed23dde93028c205facd11a01
MD5 fce1f76db24049ef2018ed5b3f9b6efa
BLAKE2b-256 8604d8888421f5fca7189067446432ae50146563ca69b45f78dc07a9351597fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ad0a85853a1b49376134345f047dd4f04fa3fcfc5b7b69896266087401dff7d
MD5 ab1e4dcd28f64dac44b95133ea71d2e7
BLAKE2b-256 0c98b4ac0d4cc7762d0b5ad99781a6a5cc8373920268b22f7ab5b5549bf9f087

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 612ebd7c443c8ce619421d216b1b0e510be73ccf9bf46301ffdb00465cde9957
MD5 21e075d6eab08213c0cd0f05cc400b62
BLAKE2b-256 8b741b0954c7e665ff2e91f410fa230e6499e01643137ca6f339aedb4a977608

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 78753fb0e46945e47312a05b568d8ae29b045d468918b46584b807bedb7f0adc
MD5 0d5537863b4637206e9bc2a6757064ad
BLAKE2b-256 d4b7edcb0382209a2f1f3bef10bc518b7fbfd10466854863180b9b45988e7aaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61ea96eb179caad762cdb63ea0cb368f7b7988fabee22ac5b97284446a3b4a0c
MD5 61942c07d3b20d7a24c7689badfc38e8
BLAKE2b-256 fe1c3b379a47d66388804911cef4fa442222b6d575d92800e0fe22f298a669e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2cc50b1732da85a19de866a4ee69f357a7f7784c6ecbb5a3a88382702b77ab73
MD5 d0465d7bc21dcb7eeed326c19e48cd6d
BLAKE2b-256 72f8a0fbc5fe5de1b4ff2afd3acc559bc7fbf0bead555eae75234818f5a584f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0175e26a09a629902e8cc5c95d953463c16336ccb04624e09c95b0093a74a4d8
MD5 ed52e5d6fd683bc9ac85cb21607e677b
BLAKE2b-256 cd7d3ca282e57180bf96c867d1a38955c8093bb89af1933bf5a0a8a83217dc6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4e1d7b7deeab6b56bfc979782ffbbeeffdd167ea3ce93b30c7618c2475cb64f4
MD5 b66ddde4622c9576c2f677b86d93685b
BLAKE2b-256 6f491a2ddc85ccece63c715a2abd077c355e333ddd5486d7c7c04ac208649806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e55f310cf9fc431814d9a17d8963a6c891b01d1ca35b0902a7bcdef75c5b8f0
MD5 188ce538abce745d982e955384c52946
BLAKE2b-256 f0b0a0f65e9422b33730449f25db15936bd56a2bf99f33832463034451609aa0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 837beb710e48362959d88cb5c83f4c778c47bc1a5830c6732761c4fa342c058e
MD5 b187df2bac2810575c60e7f6962086b8
BLAKE2b-256 03956c7151bbf96642bbac3784cbba4bfea0717d8e2c750c3cbe5eef68f13854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e4fdd69cef60abed15d76a88f5c16893a75659d650c680719dec3d7296ea4638
MD5 88436bd7074928777449ca6e3403393a
BLAKE2b-256 092e97c1f4e060c04c9474459336476e412d0d8db39b0a5fb281e2a78d0f22ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6b82dcb6139e82310248bc4b1a5c50c90c8ffe0c4c364c6d400dc0add05d18b5
MD5 7abbb1f5f0b022594280d963ce457023
BLAKE2b-256 ca2f492d2001ab558be6e9b07102796fbfc3dbe9c9a52f415be9d64d2110a750

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e2fa2b9c98bd8b24aec72b4487da76a0622d4056e160547949b23b8387497a1
MD5 898780378e103d38eccf6bf747411cf2
BLAKE2b-256 31e20580c866125ee9f49dbf786976888d7ee944ffc80db5d940b75fcdcbcca2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 62bd8c8490331d1ff5a34bf83dbaf65c26b90a12f12be49b26d96caf086a9b92
MD5 aa2a4767afeaab1ce77c3a161cf9aeee
BLAKE2b-256 0db7b178bdedcd1b72a21a2ded41b7ab7ba122c48d0f5531601a9d6c4f7c0a96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 76929e9a587f2a7c57c7c330829f06c45edc82cae41fb8e03c556f135256c2b7
MD5 4bd4e96c71febeb6bb98091142a22a96
BLAKE2b-256 4f824bb025b01d142eeb699bf31fa290afc1cc7ecf783c2708a5f9b0e8b1f0fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d6eb168ea9534528acff0f7487cbc36a84ae84ae395796daddd92a816b31ccdf
MD5 350766c19d601545e3060d6094d22fa0
BLAKE2b-256 ee1980e716f1986ea133202bf5e7a65fcda357bde8df8217cbdf49d817a8d626

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19554052d4f6110b539608bdc17da99379a40a2396a298a57dc68ffbb47201cd
MD5 92f9850d1bf1bc3ec7cf840fac22a940
BLAKE2b-256 7a90895a840d1831ebfd44f5ad4a69cd59365ea5da6529681aa18d33b43f95c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87d189ef0f1342e14fbe2232c2577b8f46f500a30ba4998b842663c59aacb0a1
MD5 d418edbd50398f32026306245b00200f
BLAKE2b-256 108aa4994577c2ddb3a816f7a0b384fd4dc3883a2c390c9d3fe3e1d2897f66eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784096857-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c6ab4500f4332c710e2160df37018ab29865bfea5487971f2781bf8b020c531e
MD5 e2f4488e2e762c8009bb0bdbe9d73e3e
BLAKE2b-256 61b0f406f6904b8ea2c18553f9ebf6f3cb86847dd2191904d4b46a2b20187296

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