Metadata-Version: 2.4
Name: stabilizer-qec
Version: 2.0.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Dist: numpy>=1.21
Requires-Dist: scipy>=1.7 ; extra == 'bposd'
Requires-Dist: numpy>=2.0 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: scipy>=1.15.3 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: networkx>=3.1 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: matplotlib>=3.9.2 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: seaborn>=0.12 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: plotly>=6.5 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: pathos>=0.3.5 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: pandas>=2.2.2 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: tqdm>=4.66 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: galois>=0.4.11 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: uncertainties>=3.2.3 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: adjusttext>=1.3 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: typing-extensions>=4.15 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: packaging>=25 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: gql[requests]>=3.5 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: graphql-core>=3.2.11 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: requests>=2.32 ; python_full_version >= '3.11' and extra == 'deltakit'
Requires-Dist: scipy>=1.7 ; extra == 'ldpc'
Requires-Dist: qiskit[qasm3-import]>=1.0.0 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: matplotlib>=3.7.1 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: numba>=0.57 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: scipy>=1.15.2 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: z3-solver>=4.15.3 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: multiprocess>=0.70.17 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: tqdm>=4.66.2 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: networkx>=3.4.2 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: mpmath>=1 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: click>=7 ; python_full_version >= '3.10' and extra == 'mqt'
Requires-Dist: scipy>=1.8.0 ; extra == 'panqec'
Requires-Dist: pandas>=1.4.2 ; extra == 'panqec'
Requires-Dist: matplotlib>=3.3.4 ; extra == 'panqec'
Requires-Dist: tqdm>=4.59.0 ; extra == 'panqec'
Requires-Dist: python-dotenv>=0.17.0 ; extra == 'panqec'
Requires-Dist: psutil>=5.8.0 ; extra == 'panqec'
Requires-Dist: click>=8.1.2 ; extra == 'panqec'
Requires-Dist: scipy>=1.8.0 ; extra == 'panqec-gui'
Requires-Dist: pandas>=1.4.2 ; extra == 'panqec-gui'
Requires-Dist: matplotlib>=3.3.4 ; extra == 'panqec-gui'
Requires-Dist: tqdm>=4.59.0 ; extra == 'panqec-gui'
Requires-Dist: python-dotenv>=0.17.0 ; extra == 'panqec-gui'
Requires-Dist: psutil>=5.8.0 ; extra == 'panqec-gui'
Requires-Dist: click>=8.1.2 ; extra == 'panqec-gui'
Requires-Dist: flask>=2.0.1 ; extra == 'panqec-gui'
Requires-Dist: scipy>=1.1.0 ; extra == 'pecos'
Requires-Dist: matplotlib>=2.2.0 ; extra == 'pecos'
Requires-Dist: networkx>=2.1.0 ; extra == 'pecos'
Requires-Dist: sortedcontainers>=2.0.0 ; extra == 'pecos'
Requires-Dist: matplotlib>=3.5 ; extra == 'plot'
Requires-Dist: scipy>=1.3 ; extra == 'qecsim'
Requires-Dist: networkx>=2.1 ; extra == 'qecsim'
Requires-Dist: mpmath>=1 ; extra == 'qecsim'
Requires-Dist: click>=7 ; extra == 'qecsim'
Requires-Dist: scipy>=1.14.1 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: galois>=0.4.2 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: sympy>=1.12 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: cvxpy>=1.3.2 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: networkx>=2.6.2 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: diskcache>=5 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: platformdirs>=4 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: pyperclip>=1.11 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: tqdm>=4 ; python_full_version >= '3.11' and extra == 'qldpc'
Requires-Dist: scipy>=1.9.3 ; python_full_version >= '3.10' and extra == 'quits'
Requires-Dist: networkx>=2.8.8 ; python_full_version >= '3.10' and extra == 'quits'
Requires-Dist: tqdm>=4 ; python_full_version >= '3.10' and extra == 'quits'
Requires-Dist: matplotlib>=3.5 ; python_full_version >= '3.10' and extra == 'quits'
Requires-Dist: matplotlib>=3.5 ; extra == 'sinter'
Provides-Extra: bposd
Provides-Extra: deltakit
Provides-Extra: ldpc
Provides-Extra: mqt
Provides-Extra: panqec
Provides-Extra: panqec-gui
Provides-Extra: pecos
Provides-Extra: plot
Provides-Extra: qecsim
Provides-Extra: qldpc
Provides-Extra: quits
Provides-Extra: sinter
License-File: LICENSE
License-File: LICENSES/Apache-2.0.txt
License-File: THIRD_PARTY_NOTICES.md
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, window decoders for real time, the APIs of twenty-five other QEC tools, Clifford+T circuits with coherent noise, fault-tolerant compilation and resource estimates, and sampling and BP on the GPU.
Keywords: quantum error correction,surface code,decoder,matching,stim,bp-osd,qldpc,lattice surgery,clifford+t,coherent noise,resource estimation,gpu
Home-Page: https://qcompiler.jaspersands.com
Author: Jasper Sands
License-Expression: MIT AND Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://qcompiler.jaspersands.com
Project-URL: Repository, https://github.com/Jaspersands/quantum-simulator-qec

# stabilizer-qec

A surface-code simulator and decoder written in Rust, with Python bindings.

- Circuits and detector error models in [Stim](https://github.com/quantumlib/Stim)'s text formats,
  and error models built by walking a circuit backwards, identical to Stim's on every circuit
  checked.
- Exact minimum-weight matching by sparse blossom, and correlated matching, agreeing with
  [PyMatching](https://github.com/oscarhiggott/PyMatching) shot for shot except for ties.
- A bit-parallel sampler, 64 shots per machine word, that runs `REPEAT` blocks without flattening.
- Raw measurements to detection events, reproducing Google's Willow and Sycamore files bit for bit.
- Sliding and parallel window decoders for real-time decoding, and decoding as a service
  (`decode_async`, a decoder queue with statistics, a decoder server).
- The APIs of Stim, PyMatching, sinter, ldpc, Tsim, tqec, Deltakit, PECOS and seventeen more QEC
  tools under their own names, each port checked against its original.
- Clifford+T circuits with a coherent error on every gate: a stabilizer-rank sampler for the
  gates and a joint sampler that reweights the twirl of the errors around them.
- Fault-tolerant compilation (tqec's block graphs, Loom's lattice surgery), resource estimates
  (Azure's and Qualtran's), and sampling and min-sum BP on the GPU through wgpu.
- Belief propagation reproducing the [`ldpc`](https://github.com/quantumgizmos/ldpc) library's
  arithmetic bit for bit, and belief-matching equal to the `beliefmatching` package's.
- BP+OSD (OSD-0, OSD-E, OSD-CS), whose corrections equal `ldpc`'s `BpOsdDecoder`'s, and IBM's
  bivariate bicycle codes: the gross code [[144, 12, 12]] and [[72, 12, 6]], with the depth-8
  syndrome cycle of Bravyi et al. (Nature 627, 778, 2024).
- On the gross code, every automorphism's action on the logical qubits, and the gauging measurement
  of a logical operator as a circuit, its error model equal to Stim's.
- Stim's whole circuit language (every gate, all three bases, `MPP`, `SPP`, correlated and
  heralded noise, measurement feedback, instruction tags, Pauli-target observables), checked against Stim on random circuits that use
  every gate.
- Lattice surgery as single circuits, their error models equal to Stim's: Z⊗Z and X⊗X merges, a
  logical CNOT, merges in a row, and lines of patches merged at once.
- [sinter](https://pypi.org/project/sinter/), whole (`stabilizer_qec.sinter`), for threshold
  sweeps with nothing else installed, and objects that pickle for `multiprocessing`.

```python
import stabilizer_qec as sq

circuit = sq.memory_circuit(distance=5, rounds=5, p=0.004)               # a d = 5 SD6 memory
dets, obs = circuit.compile_detector_sampler(seed=1).sample(100_000, separate_observables=True, threads=0)
dem = circuit.detector_error_model(decompose_errors=True)
pred = sq.Matching(dem, enable_correlations=True).decode_batch(dets, enable_correlations=True, threads=0)
print((pred != obs).any(axis=1).mean())                                  # logical error rate
```

The gross code, decoded by BP+OSD:

```python
gross = sq.BivariateBicycleCode("gross")                                 # [[144, 12, 12]], 12 cycles
c = gross.memory_circuit(12, 0.003)
dets, obs = c.compile_detector_sampler(seed=2).sample(2_000, separate_observables=True)
pred = sq.BpOsd(c.detector_error_model()).decode_batch(dets, threads=0)
print((pred != obs).any(axis=1).mean())                                  # any of the 12 logicals wrong
```

Threshold sweeps with `stabilizer_qec.sinter`, which is sinter whole (matplotlib to plot):

```python
from stabilizer_qec import sinter

stats = sinter.collect(tasks=tasks, decoders=["pymatching", "belief_matching", "bposd"],
                       num_workers=8, max_shots=100_000)
```

The names follow Stim (`Circuit`, `compile_detector_sampler`, `separate_observables`),
PyMatching (`Matching`, `decode_batch`, `enable_correlations`) and `ldpc` (`BpDecoder`,
`BpOsdDecoder`, `error_channel`). A seed gives the same shots on any machine and thread count.
See the [changelog](https://github.com/Jaspersands/quantum-simulator-qec/blob/master/CHANGELOG.md).

The explainer, its figures running the engine in the browser, is at
<https://qcompiler.jaspersands.com>, with a technical report. The source and the full write-up are at
<https://github.com/Jaspersands/quantum-simulator-qec>.

