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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.15+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

stim-1.17.dev1784094335-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.9+ x86-64

stim-1.17.dev1784094335-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: stim-1.17.dev1784094335.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.dev1784094335.tar.gz
Algorithm Hash digest
SHA256 6a9abec560ae93f201b2bea51879b30e22e9e35c81bc212d34d763f3e2c2bbcc
MD5 1c4de59da39d43f5f2c1cb861b35793b
BLAKE2b-256 bd122521887c9510cb3789636464b14a9ba8008038a010f16568cf0f3b4ec3c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7275f7959c72b55954be6e552e6a0edfbb1e9c8ce3df50085eba5ed8ba177904
MD5 d43ce2caf1d9d2ae2e3d50f7d158f7b2
BLAKE2b-256 d359d5e64dd7d42fab0a7c980dedf7c95c4ec1ff962712dd8309959ba208bab7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b8c634e3f501e58c91b353eb2b84e03991aeed395df515da3463ab9a91408391
MD5 fe02b6b8726e8a4fa68e6b37ea1796f6
BLAKE2b-256 701cdb4fc6a8bd1314972fd6cbcb55bd16d36130de85c9e35cf5b4b506c7c4ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d1a1d85e5d14ef0d4f180e2a3a3b538f7ed942e60eb0cb252e875781b2343a20
MD5 c1f526dd98565a91f2cb77652b57d0d1
BLAKE2b-256 09f193291bbc5b44fb081aa29563d6d31237b8f7461c8cf56d9a6017af49e7a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 881434559c12414242ff1e87c3fc8c1840d5214f16c521fc4e77dd8e6d12aaec
MD5 bd931017a3feb0cd9824e2f46a2d983b
BLAKE2b-256 a8a5367ed86bc7eab5669a42c42f6168c64c9572a1c4d1a15ef45f8898e861a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fa2fdc07c3f260567435715b77e32e7f4620761f55f9cbd518d471ceb5abf038
MD5 ae6dd48db7fff7ef0e3bdac1e98b7b6d
BLAKE2b-256 e71e4a6e8100d5375be19b68557ee8bb7c06f1d2c9c5f994f7d58a367aeae526

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b38e9e2f88a0772fc9843b522f2681c428d6eeebb39fe5d60c5429ff4a7b8d0e
MD5 65c33c11a0be81bc254d8a540610be54
BLAKE2b-256 b1db4d239af66bd5639fbafa8057d069520b4091db75965e78c3f4e563086614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e1c845cf400594de1521e6d2a26da53d80ae72fbd82a66a4a293e4d6c6ec6c5
MD5 4e4d96b775bf64ebb95aae62bd5f6dc1
BLAKE2b-256 e9ba8e126ad38713a0af73e6e00b3632bb04dfd5c255f75b7166e52dd45617c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1b64fdbc2f153ceda1318f21ce1ec22b6b5cba64fe6ea42742602da8f75ae584
MD5 6bdbc3b6a65314d1724ec31f3e9284a6
BLAKE2b-256 057aa6fa9aeb3282f6e6614086343a3301ce46df15c0c505f161877b6d5f1add

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dabf65f6bea6c417a611aa0b261709d7bea17b9d7f54248ed8643a89b67d4c7f
MD5 85a8aac2d621edd12460f3fcfc6c4a09
BLAKE2b-256 f0afd67b5198b30fce3636358ca6991d07b8e47277f411b571d7dc5ca670b256

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05ca5fd6025ad3b4eddbd7a973285dd0e91a38a12a62d8a4616286ce1d46b734
MD5 7aaeea6f525e799aceee0766811e173b
BLAKE2b-256 dc0c873980554ee26675bc5d433bbe4c5d2a0104122bb82ad59dccbd21f8559f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6c99037661d78dde976f89cab43b64e4a82a8b66bfdb024167d801d091c8090
MD5 cec617f644959384a15126efe4aa8042
BLAKE2b-256 f1863300dd164158269f5854b9642f82645721c906c81f4cdcd0a46090cab5f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 44f18830a5753fcea512aaad8f3c275c830c86272344d6c0e1f445adef437c72
MD5 06ff22f0b3845e71ae6fbebd4a178102
BLAKE2b-256 9289c124727f8ef1180b0b14aa3aafdd5687fe0001761afac4572ac3e83cea42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 acd0c3a5fed18480169c498f7e4dbba309adc383b6e446b0e8c65132584998b6
MD5 f1d17634068edc192db7307591573852
BLAKE2b-256 081608643e47a43ab55160ef55de0bfc7fe5671ec8e12f1670d8b0917b99b9cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 220a30cd5bae7f2238d5652d73f26c6c22f0753f99fd8109fdf16e5308b213ba
MD5 7c2cf32d580d0ddcd32f788fdadac1f6
BLAKE2b-256 5ad3d2ce23c3087f4282d7987857d88ff84cf880c94350e9e1485ca8e14cdf9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 977a336b251727da71e5483abfb8159a5fd2582bae2989f9872fddcfb7c0f0d4
MD5 65e119a3d649d70a13a0fff0fc6d14a7
BLAKE2b-256 0ed80ba309681359ac0a671b6c18c5fb75a78acb0a46bea556a032dfc77449bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 89492873a76714ccc00f32bbeb25a40c01914317ec942bf263deda35fb02b661
MD5 c022c5f5f60441720c6e0e33891a6e35
BLAKE2b-256 7ec0dd8e1654c3c197a06baf702fb1a760961c371cfdd0f0f7d78e3657c5dcbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c9cf818fc21f896cff8b891ab419666db700c84a483ffa514fd2fa9b80cab510
MD5 e49755dcaaa260a5b9c33f9039888d53
BLAKE2b-256 ccd64c84494e4535f5237eb82c3568ac0ba08dd4b438b9f132cc841b46d3d682

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5b6e5cc1b46c7a27c33885d855d6f2cd084923c69ca0c1ca606e7ee06cb542c
MD5 1c3786c4cf49225d5217519403d75dca
BLAKE2b-256 27122ead4d42788530bc8a9ed007d5b8b7baf226e5ef27c6a90c0019059a0e88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f83a993a54c2fcbc1cf2e68a3c1eef87681aebc24b286847f187b1440f315c82
MD5 47ac201eb8335c38fc409622fcbd6e59
BLAKE2b-256 5b20ebceb4d25635b55b1044ffe1bd2e737041f2a75eb7e0eb8a8f79d49ce736

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stim-1.17.dev1784094335-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 90e5f40be37a956c086702152eec98b38b47b5e585543b819e5555bc2dd5ff7b
MD5 a30d17ba75c8d5b7d74487431e3f0322
BLAKE2b-256 8bbdce3856501e0e1836418508d5f0d519ff8f6fdfa195cb2af1be3460bf5406

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