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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: stim-1.17.dev1784161823.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.dev1784161823.tar.gz
Algorithm Hash digest
SHA256 ded68f152cd98465060780c83fb4aa7717ce9cc9cacd7b75730556e07e9aaa90
MD5 6fff09b885b805e20940d40ee5c1b1a7
BLAKE2b-256 603f6fcd7a322cdddb8467705f20a7226ee4c244a24e2bf2deb8efb36a1924a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 50df2abc921f6c38af7dacd319b4ee47b4b5066029edb1e280fcbf94a74a1f23
MD5 8841edae8bfb9174f64507bc3859b07f
BLAKE2b-256 04705a464ea597684b5a8830e2d1fd7f702963c8de09a1abfc96a0034e4cf053

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3039cf36ea904ca84b4bfca664c3c1cea8b18715310d0f5ff954edf55e5f7382
MD5 a409111391da7b7f105bf27852c0fbc8
BLAKE2b-256 ad02680c3aff9bcd973fb918544ee8803b222594b36994a326dae6ba7dc5f902

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f05b6725b98c816b7f34d6f92c24c6b1a46fc2f8bb22fe128c7ae8bfdb75cd7a
MD5 30ae3c24e869189ab546d678fedadd0e
BLAKE2b-256 e9d2de86b35d11c14d44965b72cd766870fe4c23b223c35b76860da071fc577e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d90cd17665c0212f96cb0ffaeab7d63d0db032ebd4bf63610087194d0f97feea
MD5 0b1c53f70d8c75754cc28be0526a2ae4
BLAKE2b-256 4165a69690eb71a3b9e08518b23b04942a9b8d485f6fe63cef33886bcfc6b304

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 59f4fc1474aaf246703066682d66fe7f80fe818257f914a236600f435df28cb9
MD5 d3303be8eafa2f4d95cecb2a3cde14a0
BLAKE2b-256 1ca89b3eb90c0a66025e9bf60bb1f5fd3bb34ecca0ab7fa8531e33302107691d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 65a20533c42acc75ae6c5cfa013c74beb5e78a2b13406b9f5d716541460dad9e
MD5 1088f00f19f1470114458d8523020519
BLAKE2b-256 ffb605a375296d360ac622caf9c95e2b0f3730e3424cc11e8b19fccd0a706735

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c697d7c0bc6b837f4e1b5d7afa803cf6bbef7f6dfb5dac1a29af35e25c318703
MD5 20d4b1dfe0309b081a943d8decf148f8
BLAKE2b-256 2e9f198a88b789658352116811c75c4365264068478f798adf3c0a9713376fea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 606d15995369af1dbe2e9eaf52c756c1da11f39a0541c968cb07f00f84ed2731
MD5 8eb24b17e641bb00b1d5ad98bfcc82f5
BLAKE2b-256 5fe04deb435ef604d50d1455860f6aba528bf4f3af3a0d985fc5d67de90ae030

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b51c02a0bd29a46cd326d71f606646a6105bd7b1ee8c621b1cb87d298ea0a2da
MD5 4a77ec4e51cffe9bc393b02fa9705068
BLAKE2b-256 913c6c5406feb1e326dd6f9bdc7a3b79a18886bad7184c1ed7a059bbcd298c93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f38224c33cfb2964a78d2e12a72814742792d5a7d853f5fb19b8dad0dc3bfd44
MD5 686d11dbc096881f749fcc8b4f1d561c
BLAKE2b-256 bca72d2c00a427a12e8c962527a2bc41a64ef296ac3dd3bbecef5670a9d609e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2b244df262bb4405135d50a04f5b8a8ab256199c84e63c4a04aa0cf2dc76919
MD5 f4bf1c44f591901801c2f5fd83c0835e
BLAKE2b-256 909957e8daa3f1033e79209aa0d81a692b6d07a38bc760b597802fdf2f55d0cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ba293958590e8f195e5192b87e14174a208a2e76bb82101cdf1734a597d22172
MD5 ba36128765d3dc198d4d1ad278b97617
BLAKE2b-256 55f6c97e9c412901c1c598dcb8cdaf3f8a9981e8989165ecc539a14b8c2df9ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d790eb1a0478b6f1821ef229f1b972b27742d65f34a9906dbab6ceb0bc6991cd
MD5 7212edbfbc1c8fdb87db097b4dc3a681
BLAKE2b-256 6aad5b5ec29aaf357ed175d80e2f16b877184a35000b0fedd54fe6cb197cdced

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e231ac9310e29fd73f56d8e80aecedfc6208902ab90a6fe27b45ad93c1d254c
MD5 dcefbc6834e7873e76d0298127c3de06
BLAKE2b-256 ba990f5a01fb0c1b7c8e0098dd59feb70fb8d83782d7317fa86b635a714ffa30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 948c9dd39d3ada0dd30fad23be52bc8849fdd0fd24122b0320b28b3cf54cb26c
MD5 5ad162dea91cdd2ce336049beb10f83c
BLAKE2b-256 079c999d3e1335c16a7dc295c37252dc6b49f731ad0b00a5b85e3a98aa8ddfdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8f62f4241b1c995aa766115b313e3e18b2f352c71189839133790ecb28ec4fbc
MD5 aaebb948c9c724cfb8ba7cc542a60965
BLAKE2b-256 92f0b17cfca849a32339b0a88d324d4667482a7795967eac6ac3e47681dd6ed7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bd7c12cceca4d9f4da06161a9fc6762bee768133fee2ad46852b32d7f285f02c
MD5 98b61ccababaf1392e95d0d14013f3e6
BLAKE2b-256 ad2516b1c1edccacbe7529aae75194d17bd24576c903a54cdaa58846696653e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 517a0042bf6e62e1b0ed62659380a4dc37de70e3d3e29dedbbc2ce498488b85a
MD5 f83f1071516846a47e63f869611f454e
BLAKE2b-256 45159280b00ac75f25ff66bf030c835a3a4207c41a011af8b289e381818ad7d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ca8c4a61a5480d2ee15781f49a2a74491c84ee58ec4c794168c223ce997648e
MD5 c0ea903d93f2214537e63aad90bf4f6c
BLAKE2b-256 12922eda1218355af25f0e698aeacd10af1ae07f976961f1a5ef90281c590911

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784161823-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0c85d1314c34d7aa391139742633d0e893030a658abb523fd7eab528fe7b2790
MD5 94a6ec9bc983df8604334b44ca6bd9bf
BLAKE2b-256 0f5270ea1f85ddd4108cc291f928489d5ef98ff6bf98e7f105e4e7b92e66668f

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