skillfed

PyMatching

A package for decoding quantum error correcting codes using minimum-weight perfect matching.

pymatching v2.4.0 184.4K downloads/30d#10,039 on PyPI356
Permissive license Apache 2 Active released

What it is and what it does

PyMatching decodes quantum error correcting codes by solving the minimum-weight perfect matching problem on detector graphs derived from syndrome measurements. It is built on a sparse blossom algorithm that directly finds minimum-weight paths between detection events, avoiding the computational cost of all-to-all shortest-path searches. The library works with arbitrary weighted graphs (with or without boundaries) and can load matching graphs from check matrices, networkx graphs, or by adding edges individually using scipy, numpy, networkx, and matplotlib for numerical and graph operations.

The package is designed to decode surface codes and other code families (subsystem codes, honeycomb codes, 2D hyperbolic codes) in quantum error correction simulations. It can be configured with custom weighted graphs and integrates with external libraries for circuit-level noise simulation. As of v2.3, it also supports correlated matching to handle errors more accurately. Version 2 includes a substantially faster blossom implementation than earlier releases.

Use it for:

  • Decode surface code circuits in quantum error correction simulations by configuring matching graphs from syndrome data.
  • Estimate the threshold of an error correcting code by running multiple decoding trials with varying noise levels.
  • Decode subsystem codes, honeycomb codes, or 2D hyperbolic codes by configuring custom weighted graphs.
  • Perform correlated matching on circuits where error correlations are present between graphlike errors.
  • Build custom quantum error correction workflows by adding edges individually to a matching graph.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyMatching is a fast Python/C++ library for decoding quantum error correcting codes using the Minimum Weight Perfect Matching (MWPM) decoder, designed to find the most probable set of errors from syndrome measurements.

Yes. PyMatching is actively maintained, has no known vulnerabilities, uses a permissive Apache 2 license, and is the standard decoder for surface codes in quantum error correction research. Install friction is moderate but manageable with prebuilt wheels. Choose it if you are working with quantum error correction; skip it if you have no quantum computing workflow.

Install

pymatching on PyPI

pip

pip install pymatching

uv

uv add pymatching

poetry

poetry add pymatching

Installing PyMatching

Before you install

Medium install friction due to compiled wheels for multiple Python versions and platforms (cp310–cp314 across macOS, Linux, Windows). Active maintenance with recent release (84 days old) and steady repository activity. Four runtime dependencies (scipy, numpy, networkx, matplotlib) are standard scientific stack packages.

License in practice

Apache 2 permissive license allows use in commercial and proprietary projects with minimal restrictions; you must include a copy of the license and note any modifications.

Quickstart

pip install pymatching

import pymatching
import numpy
import networkx

matching = pymatching.Matching()
matching.add_edge(0, 1, weight=1.0)
matching.add_boundary_edge(0, weight=0.5)
syndrome = numpy.array([1, 0, 1])
prediction = matching.decode(syndrome)

Verify before relying

  • Whether the 100–1000x speedup claim in v2 applies to all use cases or primarily surface codes.
  • Exact performance characteristics on different hardware architectures beyond M1 processor benchmarks.
  • Whether correlated matching (v2.3+) is enabled by default or requires explicit configuration.
  • Integration workflow and API details for use with external quantum simulation frameworks.

Package facts

License Apache 2 (permissive)
Python support supports the current Python release (>=3.8)
Install friction medium — platform-specific wheel
Runtime dependencies 4 — scipy, numpy, networkx, matplotlib
Maintenance actively maintained — 84 days since the last release
Last repo commit
First released
Downloads 184,387/month — #10,039 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pymatching-2.4.0-cp310-cp310-macosx_11_0_arm64.whl; pymatching-2.4.0-cp310-cp310-macosx_11_0_x86_64.whl; pymatching-2.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pymatching-2.4.0-cp310-cp310-win_amd64.whl; pymatching-2.4.0-cp311-cp311-macosx_11_0_arm64.whl; pymatching-2.4.0-cp311-cp311-macosx_11_0_x86_64.whl; pymatching-2.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pymatching-2.4.0-cp311-cp311-win_amd64.whl; pymatching-2.4.0-cp312-cp312-macosx_11_0_arm64.whl; pymatching-2.4.0-cp312-cp312-macosx_11_0_x86_64.whl; pymatching-2.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pymatching-2.4.0-cp312-cp312-win_amd64.whl; pymatching-2.4.0-cp313-cp313-macosx_11_0_arm64.whl; pymatching-2.4.0-cp313-cp313-macosx_11_0_x86_64.whl; pymatching-2.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pymatching-2.4.0-cp313-cp313-win_amd64.whl; pymatching-2.4.0-cp314-cp314-macosx_11_0_arm64.whl; pymatching-2.4.0-cp314-cp314-macosx_11_0_x86_64.whl; pymatching-2.4.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pymatching-2.4.0-cp314-cp314-win_amd64.whl

Tags

quantum error correction decoderminimum weight perfect matchingsurface code decodingquantum error correction libraryMWPM decodersyndrome measurement decodingquantum circuit error correction
quantum-computingerror-correctiongraph-algorithms

More Scientific/Engineering packages