stabilizer-qec 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. stabilizer_qec-0.3.0/Cargo.lock +257 -0
  2. stabilizer_qec-0.3.0/Cargo.toml +38 -0
  3. stabilizer_qec-0.3.0/LICENSE +21 -0
  4. stabilizer_qec-0.3.0/PKG-INFO +61 -0
  5. stabilizer_qec-0.3.0/README.md +1572 -0
  6. stabilizer_qec-0.3.0/pyproject.toml +28 -0
  7. stabilizer_qec-0.3.0/python/README.md +43 -0
  8. stabilizer_qec-0.3.0/src/batch_sampler.rs +681 -0
  9. stabilizer_qec-0.3.0/src/bb.rs +321 -0
  10. stabilizer_qec-0.3.0/src/belief.rs +239 -0
  11. stabilizer_qec-0.3.0/src/blossom.rs +640 -0
  12. stabilizer_qec-0.3.0/src/bp.rs +374 -0
  13. stabilizer_qec-0.3.0/src/circuit.rs +607 -0
  14. stabilizer_qec-0.3.0/src/circuit_model.rs +743 -0
  15. stabilizer_qec-0.3.0/src/decoder.rs +630 -0
  16. stabilizer_qec-0.3.0/src/dem.rs +1115 -0
  17. stabilizer_qec-0.3.0/src/dem_decoder.rs +536 -0
  18. stabilizer_qec-0.3.0/src/equivalence.rs +192 -0
  19. stabilizer_qec-0.3.0/src/fixtures.rs +66 -0
  20. stabilizer_qec-0.3.0/src/frame_sampler.rs +244 -0
  21. stabilizer_qec-0.3.0/src/gf2.rs +294 -0
  22. stabilizer_qec-0.3.0/src/lib.rs +1797 -0
  23. stabilizer_qec-0.3.0/src/m2d.rs +292 -0
  24. stabilizer_qec-0.3.0/src/memory.rs +750 -0
  25. stabilizer_qec-0.3.0/src/osd.rs +295 -0
  26. stabilizer_qec-0.3.0/src/py_api.rs +759 -0
  27. stabilizer_qec-0.3.0/src/shots.rs +97 -0
  28. stabilizer_qec-0.3.0/src/simulator.rs +114 -0
  29. stabilizer_qec-0.3.0/src/sparse/correlated.rs +206 -0
  30. stabilizer_qec-0.3.0/src/sparse/correlated_tests.rs +260 -0
  31. stabilizer_qec-0.3.0/src/sparse/extract.rs +64 -0
  32. stabilizer_qec-0.3.0/src/sparse/flooder.rs +382 -0
  33. stabilizer_qec-0.3.0/src/sparse/graph.rs +104 -0
  34. stabilizer_qec-0.3.0/src/sparse/matcher.rs +355 -0
  35. stabilizer_qec-0.3.0/src/sparse/mod.rs +153 -0
  36. stabilizer_qec-0.3.0/src/sparse/paths.rs +124 -0
  37. stabilizer_qec-0.3.0/src/sparse/state.rs +150 -0
  38. stabilizer_qec-0.3.0/src/sparse/tests.rs +301 -0
  39. stabilizer_qec-0.3.0/src/sparse/tracker.rs +32 -0
  40. stabilizer_qec-0.3.0/src/stream.rs +462 -0
  41. stabilizer_qec-0.3.0/src/surface_code.rs +1843 -0
  42. stabilizer_qec-0.3.0/src/surgery.rs +417 -0
  43. stabilizer_qec-0.3.0/src/tableau.rs +233 -0
  44. stabilizer_qec-0.3.0/src/wasm_bb.rs +103 -0
  45. stabilizer_qec-0.3.0/src/wasm_hw.rs +264 -0
  46. stabilizer_qec-0.3.0/src/wasm_ls.rs +82 -0
  47. stabilizer_qec-0.3.0/src/wasm_rt.rs +130 -0
  48. stabilizer_qec-0.3.0/src/wasm_xc.rs +192 -0
  49. stabilizer_qec-0.3.0/src/window.rs +548 -0
  50. stabilizer_qec-0.3.0/stabilizer_qec.pyi +233 -0
@@ -0,0 +1,257 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "cfg-if"
13
+ version = "1.0.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
16
+
17
+ [[package]]
18
+ name = "getrandom"
19
+ version = "0.2.17"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
22
+ dependencies = [
23
+ "cfg-if",
24
+ "libc",
25
+ "wasi",
26
+ ]
27
+
28
+ [[package]]
29
+ name = "heck"
30
+ version = "0.5.0"
31
+ source = "registry+https://github.com/rust-lang/crates.io-index"
32
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
33
+
34
+ [[package]]
35
+ name = "indoc"
36
+ version = "2.0.7"
37
+ source = "registry+https://github.com/rust-lang/crates.io-index"
38
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
39
+ dependencies = [
40
+ "rustversion",
41
+ ]
42
+
43
+ [[package]]
44
+ name = "libc"
45
+ version = "0.2.186"
46
+ source = "registry+https://github.com/rust-lang/crates.io-index"
47
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
48
+
49
+ [[package]]
50
+ name = "memoffset"
51
+ version = "0.9.1"
52
+ source = "registry+https://github.com/rust-lang/crates.io-index"
53
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
54
+ dependencies = [
55
+ "autocfg",
56
+ ]
57
+
58
+ [[package]]
59
+ name = "once_cell"
60
+ version = "1.21.4"
61
+ source = "registry+https://github.com/rust-lang/crates.io-index"
62
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
63
+
64
+ [[package]]
65
+ name = "portable-atomic"
66
+ version = "1.13.1"
67
+ source = "registry+https://github.com/rust-lang/crates.io-index"
68
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
69
+
70
+ [[package]]
71
+ name = "ppv-lite86"
72
+ version = "0.2.21"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
75
+ dependencies = [
76
+ "zerocopy",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "proc-macro2"
81
+ version = "1.0.106"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
84
+ dependencies = [
85
+ "unicode-ident",
86
+ ]
87
+
88
+ [[package]]
89
+ name = "pyo3"
90
+ version = "0.22.6"
91
+ source = "registry+https://github.com/rust-lang/crates.io-index"
92
+ checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
93
+ dependencies = [
94
+ "cfg-if",
95
+ "indoc",
96
+ "libc",
97
+ "memoffset",
98
+ "once_cell",
99
+ "portable-atomic",
100
+ "pyo3-build-config",
101
+ "pyo3-ffi",
102
+ "pyo3-macros",
103
+ "unindent",
104
+ ]
105
+
106
+ [[package]]
107
+ name = "pyo3-build-config"
108
+ version = "0.22.6"
109
+ source = "registry+https://github.com/rust-lang/crates.io-index"
110
+ checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
111
+ dependencies = [
112
+ "once_cell",
113
+ "target-lexicon",
114
+ ]
115
+
116
+ [[package]]
117
+ name = "pyo3-ffi"
118
+ version = "0.22.6"
119
+ source = "registry+https://github.com/rust-lang/crates.io-index"
120
+ checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
121
+ dependencies = [
122
+ "libc",
123
+ "pyo3-build-config",
124
+ ]
125
+
126
+ [[package]]
127
+ name = "pyo3-macros"
128
+ version = "0.22.6"
129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
130
+ checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
131
+ dependencies = [
132
+ "proc-macro2",
133
+ "pyo3-macros-backend",
134
+ "quote",
135
+ "syn",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "pyo3-macros-backend"
140
+ version = "0.22.6"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
143
+ dependencies = [
144
+ "heck",
145
+ "proc-macro2",
146
+ "pyo3-build-config",
147
+ "quote",
148
+ "syn",
149
+ ]
150
+
151
+ [[package]]
152
+ name = "quote"
153
+ version = "1.0.45"
154
+ source = "registry+https://github.com/rust-lang/crates.io-index"
155
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
156
+ dependencies = [
157
+ "proc-macro2",
158
+ ]
159
+
160
+ [[package]]
161
+ name = "rand"
162
+ version = "0.8.6"
163
+ source = "registry+https://github.com/rust-lang/crates.io-index"
164
+ checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
165
+ dependencies = [
166
+ "libc",
167
+ "rand_chacha",
168
+ "rand_core",
169
+ ]
170
+
171
+ [[package]]
172
+ name = "rand_chacha"
173
+ version = "0.3.1"
174
+ source = "registry+https://github.com/rust-lang/crates.io-index"
175
+ checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
176
+ dependencies = [
177
+ "ppv-lite86",
178
+ "rand_core",
179
+ ]
180
+
181
+ [[package]]
182
+ name = "rand_core"
183
+ version = "0.6.4"
184
+ source = "registry+https://github.com/rust-lang/crates.io-index"
185
+ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
186
+ dependencies = [
187
+ "getrandom",
188
+ ]
189
+
190
+ [[package]]
191
+ name = "rustversion"
192
+ version = "1.0.22"
193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
194
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
195
+
196
+ [[package]]
197
+ name = "stabilizer_qec"
198
+ version = "0.3.0"
199
+ dependencies = [
200
+ "pyo3",
201
+ "rand",
202
+ ]
203
+
204
+ [[package]]
205
+ name = "syn"
206
+ version = "2.0.117"
207
+ source = "registry+https://github.com/rust-lang/crates.io-index"
208
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
209
+ dependencies = [
210
+ "proc-macro2",
211
+ "quote",
212
+ "unicode-ident",
213
+ ]
214
+
215
+ [[package]]
216
+ name = "target-lexicon"
217
+ version = "0.12.16"
218
+ source = "registry+https://github.com/rust-lang/crates.io-index"
219
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
220
+
221
+ [[package]]
222
+ name = "unicode-ident"
223
+ version = "1.0.24"
224
+ source = "registry+https://github.com/rust-lang/crates.io-index"
225
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
226
+
227
+ [[package]]
228
+ name = "unindent"
229
+ version = "0.2.4"
230
+ source = "registry+https://github.com/rust-lang/crates.io-index"
231
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
232
+
233
+ [[package]]
234
+ name = "wasi"
235
+ version = "0.11.1+wasi-snapshot-preview1"
236
+ source = "registry+https://github.com/rust-lang/crates.io-index"
237
+ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
238
+
239
+ [[package]]
240
+ name = "zerocopy"
241
+ version = "0.8.52"
242
+ source = "registry+https://github.com/rust-lang/crates.io-index"
243
+ checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f"
244
+ dependencies = [
245
+ "zerocopy-derive",
246
+ ]
247
+
248
+ [[package]]
249
+ name = "zerocopy-derive"
250
+ version = "0.8.52"
251
+ source = "registry+https://github.com/rust-lang/crates.io-index"
252
+ checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930"
253
+ dependencies = [
254
+ "proc-macro2",
255
+ "quote",
256
+ "syn",
257
+ ]
@@ -0,0 +1,38 @@
1
+ [package]
2
+ name = "stabilizer_qec"
3
+ version = "0.3.0"
4
+ edition = "2021"
5
+ description = "Surface-code simulation and decoding: Stim-format circuits and error models, exact sparse-blossom and correlated matching, a bit-parallel sampler, and window decoders."
6
+ license = "MIT"
7
+ repository = "https://github.com/Jaspersands/quantum-simulator-qec"
8
+ homepage = "https://qcompiler.jaspersands.com"
9
+ include = ["/src", "/Cargo.toml", "/Cargo.lock", "/LICENSE", "/README.md", "/pyproject.toml", "/python/README.md", "/stabilizer_qec.pyi"]
10
+ readme = "README.md"
11
+
12
+ [lib]
13
+ name = "stabilizer_qec"
14
+ crate-type = ["cdylib", "rlib"]
15
+
16
+ [dependencies]
17
+ rand = { version = "0.8", optional = true }
18
+
19
+ [dependencies.pyo3]
20
+ version = "0.22"
21
+ features = ["extension-module", "abi3-py39"]
22
+ optional = true
23
+
24
+ [features]
25
+ default = ["python"]
26
+ python = ["dep:pyo3", "dep:rand"]
27
+
28
+ [profile.release]
29
+ opt-level = 3
30
+ lto = true
31
+ codegen-units = 1
32
+
33
+ # The Python module. Release, but unstripped: Rust 1.90's default debuginfo
34
+ # strip leaves the cross-built arm64 module's symbol string table unaligned,
35
+ # and macOS's loader then refuses it ("mis-aligned LINKEDIT string pool").
36
+ [profile.python]
37
+ inherits = "release"
38
+ strip = false
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jasper Sands
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: stabilizer-qec
3
+ Version: 0.3.0
4
+ Classifier: License :: OSI Approved :: MIT License
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Topic :: Scientific/Engineering :: Physics
8
+ License-File: LICENSE
9
+ Summary: A quantum error-correction simulator and decoder in Rust: circuits and error models in Stim's formats, exact sparse-blossom, correlated and belief matching, BP+OSD for IBM's gross code, lattice surgery, and window decoders for real time.
10
+ Keywords: quantum error correction,surface code,decoder,matching,stim,bp-osd,qldpc,lattice surgery
11
+ Home-Page: https://qcompiler.jaspersands.com
12
+ Author: Jasper Sands
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
+ Project-URL: Homepage, https://qcompiler.jaspersands.com
16
+ Project-URL: Repository, https://github.com/Jaspersands/quantum-simulator-qec
17
+
18
+ # stabilizer-qec
19
+
20
+ A surface-code simulator and decoder written in Rust, with Python bindings.
21
+
22
+ - Circuits and detector error models in [Stim](https://github.com/quantumlib/Stim)'s text formats,
23
+ and error models built by walking a circuit backwards, identical to Stim's on every circuit
24
+ checked.
25
+ - Exact minimum-weight matching by sparse blossom, and correlated matching, agreeing with
26
+ [PyMatching](https://github.com/oscarhiggott/PyMatching) shot for shot except for ties.
27
+ - A bit-parallel sampler, 64 shots per machine word, that runs `REPEAT` blocks without flattening.
28
+ - Raw measurements to detection events, reproducing Google's Willow and Sycamore files bit for bit.
29
+ - Sliding and parallel window decoders for real-time decoding.
30
+ - Belief propagation reproducing the [`ldpc`](https://github.com/quantumgizmos/ldpc) library's
31
+ arithmetic bit for bit, and belief-matching equal to the `beliefmatching` package's.
32
+ - BP+OSD (OSD-0, OSD-E, OSD-CS), whose corrections equal `ldpc`'s `BpOsdDecoder`'s, and IBM's
33
+ bivariate bicycle codes: the gross code [[144, 12, 12]] and [[72, 12, 6]], with the depth-8
34
+ syndrome cycle of Bravyi et al. (Nature 627, 778, 2024).
35
+ - Lattice surgery between two surface-code patches as a single circuit, its error model equal to
36
+ Stim's.
37
+
38
+ ```python
39
+ import numpy as np, stabilizer_qec as sq
40
+
41
+ text = sq.generate_circuit("rotated", 5, 5, "sd6", 0.004) # Stim-format circuit
42
+ dets, obs, _ = sq.sample_b8_batch(text, 100_000, seed=1) # b8 rows
43
+ pred, _, errors, seconds = sq.decode_b8_own(text, dets, 100_000, threads=0, correlated=True)
44
+ failures = ((np.frombuffer(pred, "<u8") & 1) != (np.frombuffer(obs, np.uint8) & 1)).sum()
45
+ ```
46
+
47
+ The gross code, decoded by BP+OSD:
48
+
49
+ ```python
50
+ circuit = sq.bb_memory_circuit("gross", 12, 0.003) # [[144, 12, 12]], 12 cycles
51
+ dem = sq.dem_from_circuit(circuit) # each fault its own column
52
+ dets, obs, _ = sq.sample_b8_batch(circuit, 2_000, seed=1)
53
+ pred, converged, seconds = sq.decode_b8_bposd(dem, dets, 2_000) # BP+OSD-CS, order 7
54
+ truth = np.frombuffer(obs, np.uint8).reshape(-1, 2).view("<u2")[:, 0]
55
+ failures = (np.frombuffer(pred, "<u8") != truth).sum() # any of the 12 logicals wrong
56
+ ```
57
+
58
+ The explainer, with every figure computed live in the browser, is at
59
+ <https://qcompiler.jaspersands.com>. The source and the full write-up are at
60
+ <https://github.com/Jaspersands/quantum-simulator-qec>.
61
+