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.dev1782869566.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.dev1782869566-cp314-cp314-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: stim-1.17.dev1782869566.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.dev1782869566.tar.gz
Algorithm Hash digest
SHA256 0b05d47188b8c166e0c5fdfc04612ffd5e716d5056f22806e3f0e772a32d2fce
MD5 881ed0825c4321b65673d8db416d554b
BLAKE2b-256 d3dba55e4b31b56e6363e260225587ce56c9f650410950a4e3dc6e43a49ace22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 492d472274111681649a5f567b745a0a433cab68d98a3ede9497b9eaf9ea7259
MD5 1dd134b42b4431d847ec56cfcea5ec25
BLAKE2b-256 f12fe59ef4e1275c8567aa7187430a0e27c2320c16687cf39c1aaea977ef09bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0391a226499ac5f8e09091aab59596990dda062ce7a4a2cdd63699dbd9f433c2
MD5 b8f5790ec436981c55c74c17360d043e
BLAKE2b-256 ce4ed7d22e81f8eb04e7c3488f7b246db0d647f4e9ed27ef6c63989d5e4486a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e499ae3f5decca8c0d274c2cafd8a17ae9023b824d1b9816d9cf75cb2a62a3b
MD5 78e72f79e7d3e5c63bad82b45047eed9
BLAKE2b-256 d0caf1eb644c48c0e03c991eee0d5b9e984f6af50f62d16c829806bdd3b6b8d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 503609761547c1c35016472d0df9593f78f59945b8a633439cb290f7bbe6cf81
MD5 e9efad17f3a6842decd13fcb4a4070a4
BLAKE2b-256 a436d2a7608a98000d324280aed3c05f3c23f5deed7f7c4fe10b93d9baf3a0c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6dcad77ec05ac14de90f4a2433c094d9956013f4f9cba00acc26f89e5b169e9e
MD5 e27c50d7d10e48158fd26c42f329153a
BLAKE2b-256 e62ee2f021d51ab27aa3fa6afd2129318fd51a809b5e8c38a60dc8e0deda10e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2088d0133447e27209b59cc2cc0b58ff4b236186a32faa471aa3151ea843af8d
MD5 1fff79bd947b5ed2a1157794102f4a97
BLAKE2b-256 331a868a54286b3c59b84ddbf21744c7d4ddb0c639e5f47f3bf7b0eb6105ef1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b4bfa28d5e48028e168c662720223f98ddea692e082b74101e59f4a7219341b
MD5 f1d4b05db3c37a36bea74704a5cc3d31
BLAKE2b-256 8abf4be36e55df38e70d061ad5bfa34d36e2de94e1bab5a83a4d2d5532d87baf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c77d51d64b46005f2030f37544bf49dd3316bdf5b3440434cc78e850b8880986
MD5 dc44d21037d94bdab3bbb8b4c0112ca8
BLAKE2b-256 045efe1e38268f526d0469de927685a70d600bae793e7bfd1fbe50c74462bedd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b437f1c22053674df662e8f726322feb58aa2887805e9f27529c9b9694efa6e8
MD5 4067e0470735632c2f0491e7615bc5da
BLAKE2b-256 3e92ccad4c272f36b706e880f859f746dc0d55124df7653f6f4bd3ffd22d973d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd1c83f465de01cd61b8c293a02c85b60280220dfb3a95dfa1209cb816446338
MD5 9e52c534eeaaecdaa2f2c52122abcc34
BLAKE2b-256 3d0fbcd949511328d210eee57644766bdeef6350e5da52a94a2799db77eaba25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d7c7beddb9c8e14c8ecad0cf4c3647fb5df4f9366e425825a0bc02bf73aba94
MD5 5ca0fb01637101ba957ef153f7ec37fb
BLAKE2b-256 76da8c17dd6d47d2984bfead81f65db23727af5009b30e8f446e20b724eff0d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a4f126d154f12b4c74d7cddd5dc0814348f2e2b8a13f95fd89f5fae912a07ae4
MD5 739ff6e1113e46071871656ff3be4382
BLAKE2b-256 c9b9bc11afdb4a734bdcdc83ff9a308b3e931c87e0a3ca2ce0ac3c47c8c7f97b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a2108295e9cecaaa8a2b69ead31342b88e28a6e3aa6f1a442f1c8fb7b7972365
MD5 1eed01a603f7b6161680cad6739d8b84
BLAKE2b-256 1a24b6bf53946610512295e3311969cdcefd486ba550ae569bcc94cfa39c812e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 444014bcf1a18514e24ff2c7bbe22625688bbe37064b01e496fe81121829ed5e
MD5 42a868a0e08e8d304c0dc5dd36964b4a
BLAKE2b-256 265e7075c9fd48721d6e55a050ae73e4fbdc6c1e16997afbf0119b5adbb014c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5f00b513b827486cc78953b24fe114baff5202722b98089e3a2a1ecec3cc3df
MD5 dd682fe8276649598847ee50c963093a
BLAKE2b-256 e165ba2573aad36a4755e729603e576c0a314930359ee4e0ea72f9c63bd7dd83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d8d634fc8b945783578b3eea47140d76e485caa9543991ae5710f83acf9b5f88
MD5 dafee37c2a36dff863b4125fa1fbcb65
BLAKE2b-256 5ebf8232024a775f74e68a4657641e18912c84741dfc07202a83f4ec5c9b646b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d2585c62584147ef4b5d305201524dca4bc06087d807c60e2fe0d0d19fe59792
MD5 d61a68a4fe88bde77deafecd5cceaf78
BLAKE2b-256 d99414a33513e4df7576dcba4fe55eb10ed9a33f1708cd35b0e67557824bdc89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bcda3e353606d215b1b9cd70560a45921d96b53637d4b300ba32919696f04361
MD5 1f275b4e506a7bc59e7d9f6dc6ee717b
BLAKE2b-256 57ce52dff7cf4496863a4f8d8a63d116d9ee0e6b0f91bbe5af201abbb46fb178

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98a7fff457f51e74944ea5872d9129be8f959fbe9c522168c286f87aa67c26f3
MD5 b15866c98a11cbe24a0e3e5603d80602
BLAKE2b-256 7499917dd4950cb8dd76acd16098da581aa7cb5a76c9202b742cf397c6d57f2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1782869566-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2e61e284fe571700f8c37869fbd1d2ed351dec13afda6fd481bdb178f6f669c1
MD5 2f20459ad1bd8807ac6b7c03eea0cf8f
BLAKE2b-256 346f7030873c1912ef856b945812f44ac3239d5358021a5f35feba34d6c04575

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