A minimum-weight perfect matching (MWPM) decoder for matchable quantum error correction codes (such as the surface code), built on the open-source PyMatching library. It is a CPU decoder: each syndrome bit becomes a detector node, and each error (column of the parity-check matrix) with one or two set entries becomes a (boundary) edge whose weight is derived from the error prior.
Note
To use the decoder, use the get_decoder API with a parity-check matrix as the decoder input:
.. tab:: Python
.. code-block:: python
import cudaq_qec as qec
import numpy as np
# Parity check matrix. Each column (error mechanism) must have one
# or two set entries so the graph is matchable.
H = np.array([[1, 1, 0],
[0, 1, 1]], dtype=np.uint8)
dec = qec.get_decoder("pymatching", H,
error_rate_vec=[0.1, 0.1, 0.1],
merge_strategy="smallest_weight")
.. tab:: C++
.. code-block:: cpp
#include "cudaq/qec/decoder.h"
cudaqx::heterogeneous_map params;
params.insert("merge_strategy", std::string("smallest_weight"));
auto dec = cudaq::qec::get_decoder("pymatching", H, params);
Note
The "pymatching" decoder implements the :class:`cudaq_qec.Decoder` interface for Python and the :cpp:class:`cudaq::qec::decoder` interface for C++, so it supports all the methods in those respective classes.
| param H: | Parity check matrix. Each column must have one or two set entries
(matchable graph). In Python, a |
|---|---|
| param O: | Observable-flips matrix, |
| param error_rate_vec: | Per-error prior probabilities, one per column of
|
| param output: | The result form this decoder instance produces, fixed at
construction: |
| param params: | Heterogeneous map of decoder parameters:
|