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:
- Interactive simulation with
stim.TableauSimulator. - High speed sampling with samplers compiled from
stim.Circuit. - Independent exploration using
stim.Tableauandstim.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)
Release files for stim 1.17.dev1784094335
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stim-1.17.dev1784094335.tar.gz | 883.1 kB | Details |
Built distributions (wheels)
Total release size: 60.5 MB
Release files / stim-1.17.dev1784094335.tar.gz
| Download URL | stim-1.17.dev1784094335.tar.gz |
|---|---|
| Size | 883.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a9abec560ae93f201b2bea51879b30e22e9e35c81bc212d34d763f3e2c2bbcc
|
|
BLAKE2b-256 checksum How to use checksums |
bd122521887c9510cb3789636464b14a9ba8008038a010f16568cf0f3b4ec3c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp314-cp314-win_amd64.whl
| Download URL | stim-1.17.dev1784094335-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7275f7959c72b55954be6e552e6a0edfbb1e9c8ce3df50085eba5ed8ba177904
|
|
BLAKE2b-256 checksum How to use checksums |
d359d5e64dd7d42fab0a7c980dedf7c95c4ec1ff962712dd8309959ba208bab7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b8c634e3f501e58c91b353eb2b84e03991aeed395df515da3463ab9a91408391
|
|
BLAKE2b-256 checksum How to use checksums |
701cdb4fc6a8bd1314972fd6cbcb55bd16d36130de85c9e35cf5b4b506c7c4ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784094335-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d1a1d85e5d14ef0d4f180e2a3a3b538f7ed942e60eb0cb252e875781b2343a20
|
|
BLAKE2b-256 checksum How to use checksums |
09f193291bbc5b44fb081aa29563d6d31237b8f7461c8cf56d9a6017af49e7a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
881434559c12414242ff1e87c3fc8c1840d5214f16c521fc4e77dd8e6d12aaec
|
|
BLAKE2b-256 checksum How to use checksums |
a8a5367ed86bc7eab5669a42c42f6168c64c9572a1c4d1a15ef45f8898e861a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp313-cp313-win_amd64.whl
| Download URL | stim-1.17.dev1784094335-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fa2fdc07c3f260567435715b77e32e7f4620761f55f9cbd518d471ceb5abf038
|
|
BLAKE2b-256 checksum How to use checksums |
e71e4a6e8100d5375be19b68557ee8bb7c06f1d2c9c5f994f7d58a367aeae526
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b38e9e2f88a0772fc9843b522f2681c428d6eeebb39fe5d60c5429ff4a7b8d0e
|
|
BLAKE2b-256 checksum How to use checksums |
b1db4d239af66bd5639fbafa8057d069520b4091db75965e78c3f4e563086614
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784094335-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5e1c845cf400594de1521e6d2a26da53d80ae72fbd82a66a4a293e4d6c6ec6c5
|
|
BLAKE2b-256 checksum How to use checksums |
e9ba8e126ad38713a0af73e6e00b3632bb04dfd5c255f75b7166e52dd45617c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
1b64fdbc2f153ceda1318f21ce1ec22b6b5cba64fe6ea42742602da8f75ae584
|
|
BLAKE2b-256 checksum How to use checksums |
057aa6fa9aeb3282f6e6614086343a3301ce46df15c0c505f161877b6d5f1add
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp312-cp312-win_amd64.whl
| Download URL | stim-1.17.dev1784094335-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
dabf65f6bea6c417a611aa0b261709d7bea17b9d7f54248ed8643a89b67d4c7f
|
|
BLAKE2b-256 checksum How to use checksums |
f0afd67b5198b30fce3636358ca6991d07b8e47277f411b571d7dc5ca670b256
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
05ca5fd6025ad3b4eddbd7a973285dd0e91a38a12a62d8a4616286ce1d46b734
|
|
BLAKE2b-256 checksum How to use checksums |
dc0c873980554ee26675bc5d433bbe4c5d2a0104122bb82ad59dccbd21f8559f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784094335-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e6c99037661d78dde976f89cab43b64e4a82a8b66bfdb024167d801d091c8090
|
|
BLAKE2b-256 checksum How to use checksums |
f1863300dd164158269f5854b9642f82645721c906c81f4cdcd0a46090cab5f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
44f18830a5753fcea512aaad8f3c275c830c86272344d6c0e1f445adef437c72
|
|
BLAKE2b-256 checksum How to use checksums |
9289c124727f8ef1180b0b14aa3aafdd5687fe0001761afac4572ac3e83cea42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp311-cp311-win_amd64.whl
| Download URL | stim-1.17.dev1784094335-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
acd0c3a5fed18480169c498f7e4dbba309adc383b6e446b0e8c65132584998b6
|
|
BLAKE2b-256 checksum How to use checksums |
081608643e47a43ab55160ef55de0bfc7fe5671ec8e12f1670d8b0917b99b9cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
220a30cd5bae7f2238d5652d73f26c6c22f0753f99fd8109fdf16e5308b213ba
|
|
BLAKE2b-256 checksum How to use checksums |
5ad3d2ce23c3087f4282d7987857d88ff84cf880c94350e9e1485ca8e14cdf9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784094335-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
977a336b251727da71e5483abfb8159a5fd2582bae2989f9872fddcfb7c0f0d4
|
|
BLAKE2b-256 checksum How to use checksums |
0ed80ba309681359ac0a671b6c18c5fb75a78acb0a46bea556a032dfc77449bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
89492873a76714ccc00f32bbeb25a40c01914317ec942bf263deda35fb02b661
|
|
BLAKE2b-256 checksum How to use checksums |
7ec0dd8e1654c3c197a06baf702fb1a760961c371cfdd0f0f7d78e3657c5dcbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp310-cp310-win_amd64.whl
| Download URL | stim-1.17.dev1784094335-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c9cf818fc21f896cff8b891ab419666db700c84a483ffa514fd2fa9b80cab510
|
|
BLAKE2b-256 checksum How to use checksums |
ccd64c84494e4535f5237eb82c3568ac0ba08dd4b438b9f132cc841b46d3d682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e5b6e5cc1b46c7a27c33885d855d6f2cd084923c69ca0c1ca606e7ee06cb542c
|
|
BLAKE2b-256 checksum How to use checksums |
27122ead4d42788530bc8a9ed007d5b8b7baf226e5ef27c6a90c0019059a0e88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | stim-1.17.dev1784094335-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f83a993a54c2fcbc1cf2e68a3c1eef87681aebc24b286847f187b1440f315c82
|
|
BLAKE2b-256 checksum How to use checksums |
5b20ebceb4d25635b55b1044ffe1bd2e737041f2a75eb7e0eb8a8f79d49ce736
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / stim-1.17.dev1784094335-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | stim-1.17.dev1784094335-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
90e5f40be37a956c086702152eec98b38b47b5e585543b819e5555bc2dd5ff7b
|
|
BLAKE2b-256 checksum How to use checksums |
8bbdce3856501e0e1836418508d5f0d519ff8f6fdfa195cb2af1be3460bf5406
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|