lomatching
Decoder for (fold-)transversal logical gates in surface codes based on MWPM.
Installation
This package is available in PyPI, thus it can be installed using
pip install lomatching
or alternatively, it can be installed from source using
git clone git@github.com:MarcSerraPeralta/lomatching.git
pip install lomatching/
Example
import numpy as np
import stim
from surface_sim.models import CircuitNoiseModel
from surface_sim import Detectors
from surface_sim.experiments import experiment_from_circuit
from surface_sim.circuit_blocks.unrot_surface_code_css import gate_to_iterator
from surface_sim.layouts import unrot_surface_codes
from lomatching import MoMatching
# circuit considered
circuit = stim.Circuit(
"""
RX 0
RZ 1
TICK
CNOT 0 1
MX 0 1
OBSERVABLE_INCLUDE(0) rec[-1] rec[-2]
"""
)
# generate encoded circuit
layouts = unrot_surface_codes(2, distance=3)
detectors = Detectors.from_layouts(*layouts, frame="pre-gate")
model = CircuitNoiseModel.from_layouts(*layouts)
model.setup.set_var_param("prob", 1e-3)
encoded_circuit = experiment_from_circuit(
circuit, layouts, model, detectors, gate_to_iterator, anc_reset=True
)
# prepare inputs for MoMatching
stab_coords = [{} for _ in layouts]
for l, layout in enumerate(layouts):
coords = layout.anc_coords
stab_coords[l][f"Z"] = [v for k, v in coords.items() if k[0] == "Z"]
stab_coords[l][f"X"] = [v for k, v in coords.items() if k[0] == "X"]
decoder = MoMatching.from_circuit(encoded_circuit, stab_coords)
# run MoMatching
sampler = encoded_circuit.detector_error_model().compile_sampler()
syndromes, log_flips, _ = sampler.sample(shots=10)
predictions = decoder.decode_batch(syndromes)
log_errors = (predictions != log_flips).any(axis=1)
print("Logical error probability:", np.average(log_errors))
How do I cite lomatching?
When using lomatching for research, please cite:
@article{lomatching,
title = {Decoding across Transversal Clifford Gates in the Surface Code},
author = {Serra-Peralta, Marc and Shaw, Mackenzie H. and Terhal, Barbara M.},
journal = {PRX Quantum},
volume = {7},
issue = {1},
pages = {010335},
numpages = {41},
year = {2026},
month = {Feb},
publisher = {American Physical Society},
doi = {10.1103/sk5y-25b1},
url = {https://link.aps.org/doi/10.1103/sk5y-25b1}
}
Metadata
Release files for lomatching 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lomatching-0.3.0.tar.gz | 16.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lomatching-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.0 kB
Release files / lomatching-0.3.0.tar.gz
| Download URL | lomatching-0.3.0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fa8d1c8dfa4c3b91f252b0bc1b36530682bd49f7803811acb8a4749bbaa4e69
|
|
BLAKE2b-256 checksum How to use checksums |
9e48a26a68c1d10ad4f05c64d9e8e9223b3ddea1dbec09f4b85840a59261c915
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / lomatching-0.3.0-py3-none-any.whl
| Download URL | lomatching-0.3.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78c042dce88796ff41af4c03deb7a22739494930e6b97719d84cb18c8db4e63d
|
|
BLAKE2b-256 checksum How to use checksums |
651a1b21639a07d5ae0a191f57f0f99e54bb39787f24df673153fbee04dd6cd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|