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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: stim-1.17.dev1784068810.tar.gz
  • Upload date:
  • Size: 883.2 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.dev1784068810.tar.gz
Algorithm Hash digest
SHA256 74f553e783ab6ef052cef254c095de4a2b3d0827558f114e2d8705f2db590834
MD5 fc308c54d16b16f9cc89eace23d2e30d
BLAKE2b-256 5298b6bd02de6dfad2b91f4a4c1b6c7caaa7a0c03161f902832240c1de231e4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e50769b629912cd01fce2bb9e3d2b9939daf5bf5f9e151fd5a11794e772a92d5
MD5 9e7b747608aeea8fccf85c1953b681c6
BLAKE2b-256 4b9db282a935e5e1d5033724da4934fb47666b9710df74eea6c0c2cb844daaf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 237924afba850fbf78df4255a67a40fe61d1c40f727006baac58faab90c4bd41
MD5 cb23d4d58888cd4195b9c57fd3afd9c7
BLAKE2b-256 3053d27c9b525cbbf8ae714de788c4c069c1a97871a97b5e4125c465af64f339

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6a7f5ea4e08acb9d73178badfd9b705c000907ae041dce794794edc0e7f3158
MD5 10664930c45b9e45db56a18c945c5344
BLAKE2b-256 42c8769628df9235057a5c880982d11cde19cfca6bb72cb632ba0dc4819840a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 65052b5041d29dfd6d5b911d156ca85c4eed18a148ee79384fde8eb38e5e77e6
MD5 2a5ffc92a1b7240abebc187ecb9db404
BLAKE2b-256 82d9da247f2c3fb2f6e68eaf31bc023def4729766e8c7e8e07348c7897540df6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c91560b3562ba50872031bb42362e8d2d111b5f6e1d11eeca0af75c2c678fdf8
MD5 e3138645517498664f76132d7d05ad2c
BLAKE2b-256 e8ff68bd7110ae845d6b463d74f3d6623d1e596bd7290da944aa4f8179f2a18b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 729677a58d07f4a098274b3aaee9d7650df78319ae845325e19e1adca54aa649
MD5 f71de6d2ef94f97f9cb6d3921b390f5e
BLAKE2b-256 943903ada70d5ce3eaba2c110c309e307ef0494de2b8d886f3fac35831a09295

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a37af1e442801446279f0fd933e68c32f04911192fe88a80e2a2422ec05dc459
MD5 9af90a81c2360ac4f77c7ec785f81d7f
BLAKE2b-256 5083ea774184d8522d471ceb0b9365a8853d0e5fb4f9175c849a476511a8bf81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 440c529568eb473a6858f50e9a5c8f537b18993d26c0f286202d6153430c9e2e
MD5 a27f654e7641c762c6832235e72b4507
BLAKE2b-256 d6f508751d906e7983335fb9bf2a9c3a74922c372e79ce27fade4d68d03cdfc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 598fa98b67b41ccccbf6df678e562cac791dfe3c8307af26edd4ba0b19c3fe36
MD5 f8b79d8e1d4155f6d0031928c03466ea
BLAKE2b-256 fe4d359336f91c6a6820291e2272c20aa3c57355a61b703eec367c2b53f8f4e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 981828ae0c85968d02146db930ca69d00484c2f7fb166accc16ad4fd05975089
MD5 50cbe38c3fd43c93d4c42f7ffbad8bf9
BLAKE2b-256 6340edd76d37c6db3b7c74417b30ef6e29da438440a331667129227c2039ce02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 896d131833646b23f28d856ea483f77da3a536a4106b4abd8cac6e5780616b6f
MD5 e470dd13770d02bdfc39de2831c40616
BLAKE2b-256 f3d2c01a660ecb438ad0ca6508cd1742992ab9433063a353e4b9e08711dfa706

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ab0b3c02d6a674b5fb0be507f15d8d6c1a37f10efccd8478f52be0ac4f675eaf
MD5 7cee06abbc77548032a124948d4a1ab3
BLAKE2b-256 ac617d2d055ad3da4b2e0c5292e3caea6a164d046bfc845e2bad40d50950dead

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5a84aabea78eaece2cfee949233013ba1201e2d1367f8f094851b27969efba0d
MD5 6df329ce04036d84669ef95fca977c98
BLAKE2b-256 69515e8647299b9ef0b566502fedf194ed220a1a9ef8f4ef735b3275eb83bce2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5400cce4e5dc465b70acc82096d4f4aefa475cc8d4e26263cbc6770747dd6510
MD5 2921bb2a4b72776ad682f9597bb9d0be
BLAKE2b-256 dabd16b5f00f4cdfbd540f7a0fb0dba712afc47bddb621a9fe23c133facb9366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92dadacb444e70a9c987d40e70122147fdcd7c6adbc66f24f63a3ce9b7711cdb
MD5 09ce7b50793b65771b2d786447c12233
BLAKE2b-256 f7ab13e06aede907bbdd18d508669ff3d840cb184c65c81128336251386cdeb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f9a13d7bd836c2479863ec97e220ad69dd6f7de230008fe4235e45f21f96e85f
MD5 fd3f7c09f08bee4c729d0a1d4a221f66
BLAKE2b-256 7168015be06a5dcccf40558663387aac00a1f45101e4c5c8ebc8647b0da5206d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 37ad3e3e859aad71d9278edc422e5cd0ab5f8bcd14208ea64d8ba4420cbe3fa6
MD5 7009471a097ab9ac5591d61047c95477
BLAKE2b-256 d0cd739ddda8fe5f68c546941425da63e9ae6583694d93b08213366474afe612

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb49925014f3f95f622cd8c1b093aa21d27b4fe998a5cf4d491898789878a461
MD5 7f1e0097139eb27f56acd9a49d857749
BLAKE2b-256 946b2b26a6ea34fd7d6befd57ffc2ba1d8280eaa1b922b8955a719f36da72722

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5dd9d352ec6213065013af9a18c071cae1c668d19af428eb59fa9cc32c1c0ac7
MD5 9574fa1574d18e44544fdbfc1b34b493
BLAKE2b-256 f210ad335f1476cd0cd3302f854d66f5bede5fbcfba51a8df230ee8df86ee288

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784068810-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6bcd1bfb3fc95990a09c61f4c6a2c3f1e807e2b76eb356101e3a997b1e30359e
MD5 655090328dad05155e8821a3ef0bfbae
BLAKE2b-256 71dbc69e7304f97718b1e432f0bc1346c7fe4591dbd1b821529b6d260012d33f

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