Skip to main content

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

Project description

PyMatching

Continuous Integration codecov docs PyPI version Unitary Fund

PyMatching is a fast Python/C++ library for decoding quantum error correcting codes (QECC) using the Minimum Weight Perfect Matching (MWPM) decoder. PyMatching can decode codes for which each error generates a pair of syndrome defects (or only a single defect at a boundary). Codes that satisfy these properties include two-dimensional topological codes such as the toric code, the surface code and 2D hyperbolic codes, amongst others. PyMatching can also be used as a subroutine to decode other codes, such as the 3D toric code and the color code. PyMatching can handle boundaries, measurement errors and weighted edges in the matching graph. Since the core algorithms are written in C++, PyMatching is much faster than a pure Python NetworkX implementation.

Documentation for PyMatching can be found at: pymatching.readthedocs.io

Installation

PyMatching can be downloaded and installed from PyPI with the command:

pip install pymatching

This is the recommended way to install PyMatching since pip will fetch the pre-compiled binaries, rather than building the C++ extension from source on your machine. Note that PyMatching requires Python 3.6 or later.

If instead you would like to install PyMatching from source, clone the repository (using the --recursive flag to include the lib/pybind11 submodule) and then use pip to install:

git clone --recursive https://github.com/oscarhiggott/PyMatching.git
pip install -e ./PyMatching

The installation may take a few minutes since the C++ extension has to be compiled. If you'd also like to run the tests, first install pytest, and then run:

pytest ./PyMatching/tests

Usage

In order to decode a parity check matrix H (a scipy.sparse matrix) with syndrome vector z (a bitstring which is a numpy array of dtype int), first construct the Matching object after importing it:

from pymatching import Matching
m = Matching(H)

Now to decode, simply run:

c = m.decode(z)

which outputs a bitstring c, which is a numpy array of ints corresponding to the minimum-weight correction. Note that the m by n parity check matrix H should correspond to the Z (or X) stabilisers of a CSS code with n qubits, m Z (or X) stabilisers, and with either one or two non-zero entries per column.

To decode instead in the presence of measurement errors, each stabiliser measurement is repeated L times, and decoding then takes place over a 3D matching graph (see Section IV B of this paper), which can be constructed directly from the check matrix H using:

m = Matching(H, repetitions=L)

and then decoded from an m by L numpy array syndrome z using:

c = m.decode(z)

The Matching object can also be constructed from a NetworkX graph instead of a check matrix, and can handle weighted edges. For full details see the documentation.

Performance

While all the functionality of PyMatching is available via the Python bindings, the core algorithms and data structures are implemented in C++, with the help of the Lemon and Boost Graph libraries. PyMatching also uses a local variant of the MWPM decoder (explained in the Appendix of this paper) that has a runtime that is approximately linear, rather than quadratic, in the number of nodes. As a result, PyMatching is orders of magnitude faster than a standard pure Python NetworkX implementation, as shown here for decoding the toric code under an independent noise model with p=0.05 and noiseless syndrome measurements:

Attribution

When using PyMatching for research, please cite:

@misc{higgott2020pymatching,
  author = {Higgott, Oscar},
  title = {{PyMatching}: A Python package for decoding quantum error correcting codes using minimum-weight perfect matching},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/oscarhiggott/PyMatching}}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyMatching-0.2.5.tar.gz (10.7 MB view details)

Uploaded Source

Built Distributions

PyMatching-0.2.5-cp39-cp39-win_amd64.whl (148.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

PyMatching-0.2.5-cp39-cp39-manylinux2010_x86_64.whl (175.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

PyMatching-0.2.5-cp39-cp39-manylinux2010_i686.whl (183.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

PyMatching-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl (150.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

PyMatching-0.2.5-cp38-cp38-win_amd64.whl (147.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

PyMatching-0.2.5-cp38-cp38-manylinux2010_x86_64.whl (175.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

PyMatching-0.2.5-cp38-cp38-manylinux2010_i686.whl (183.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

PyMatching-0.2.5-cp38-cp38-macosx_10_9_x86_64.whl (150.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

PyMatching-0.2.5-cp37-cp37m-win_amd64.whl (148.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

PyMatching-0.2.5-cp37-cp37m-manylinux2010_x86_64.whl (177.8 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

PyMatching-0.2.5-cp37-cp37m-manylinux2010_i686.whl (186.0 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

PyMatching-0.2.5-cp37-cp37m-macosx_10_9_x86_64.whl (149.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

PyMatching-0.2.5-cp36-cp36m-win_amd64.whl (148.4 kB view details)

Uploaded CPython 3.6m Windows x86-64

PyMatching-0.2.5-cp36-cp36m-manylinux2010_x86_64.whl (177.8 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

PyMatching-0.2.5-cp36-cp36m-manylinux2010_i686.whl (185.9 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

PyMatching-0.2.5-cp36-cp36m-macosx_10_9_x86_64.whl (149.5 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file PyMatching-0.2.5.tar.gz.

File metadata

  • Download URL: PyMatching-0.2.5.tar.gz
  • Upload date:
  • Size: 10.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5.tar.gz
Algorithm Hash digest
SHA256 09331fc70f51462fe5b1fad0b92ee8f0cb74a4310e33f818107b3367222906d0
MD5 1857a995e872f71500194254f389443f
BLAKE2b-256 5324cb7410a8276911230b10c14fef770d0d31058bf997fc20645216e5358212

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 148.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cd750a4381e09330cc035d807e8ecd3319c2aec285dc58de5ee63b3c9e5f0437
MD5 8bddc708ffe1a0492674c3968acfb7b0
BLAKE2b-256 4f02d0083bed5aec97d2e71a5a1cc72d532abcf076ff7fe2a8c77be65ba3567e

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 175.6 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 32f9933ebb91a6b445555fce718c1cfe13b1cc25f4cff26402ef54fb227132c0
MD5 673fec47cfa33b5cd9b176d49b703bda
BLAKE2b-256 d9b2afe77e185f0adcf7cd0827d48cdc97a121b8aed975da7a75d72e87baf90b

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp39-cp39-manylinux2010_i686.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp39-cp39-manylinux2010_i686.whl
  • Upload date:
  • Size: 183.3 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp39-cp39-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 40b2a3c8d9e9a2d5ef3d6cbc500ccd8bea843dfe7546fabb735013a09ad75236
MD5 72329909c694c251e4cdfac295ffa01b
BLAKE2b-256 0dabbf99e27b0f981308b3c8db767caecb53e7cc5863132f172e253abd8c60e0

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 150.8 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b42ef0e8083fb0606a6a6718c4cf1774527be0870c46516400cc557896b2e484
MD5 a93e6e6eba61aad989a81e001cfe5481
BLAKE2b-256 7d319b8c119b0f98b7e19f4a4f22aeb2c5e21613801ed151cb87a1feae1a2321

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 147.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 338a0e809f10c590f2b259d0dd88110468b63918e9d7470be1b17262db53bab9
MD5 68305e1753d8c526a8b5f602bafa1383
BLAKE2b-256 d3ebb6d4a3a5fd2d587bc9e15e2e0d146b5a0387b318fe76f21335be36c695a9

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 175.8 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 fd954c62337e59aec0d14e25b996c250d406363d1a2d3354d919274575d003e7
MD5 0fa71e871d33af733eb6bfc18df38efb
BLAKE2b-256 99638ed688a3b37ca6c19f2cd6abf0ae6ae91932ead40350efa170c17120cee2

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp38-cp38-manylinux2010_i686.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp38-cp38-manylinux2010_i686.whl
  • Upload date:
  • Size: 183.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 fb4a3223fa75e107b03205fb366b0fcaff0fbb4f6d232e3078043404bfa469e1
MD5 5f05d66c8c6d69e3aebb9724b4674830
BLAKE2b-256 b077cf6c504b4afb42b96827be05764060d7d1ac51a425c2072359172a4c5378

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 150.7 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5e02048c81a86d5f7a09746396153d336fe57052a51dfac745af2c21f66a6a0b
MD5 12eca8f08adc9c4f1f1da0cab564f539
BLAKE2b-256 9f6c317534007e7eb7cd6995ae86ed2ce9c3af28964b9a172a4e5fdd3a5d9e49

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 148.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a0d68edad3e9d3397aa02527166d078ab740285894bd20f1dc3409e8fddcebbc
MD5 a38371180382f1f74b10c4d6bb34fc9c
BLAKE2b-256 d7c20038e7b8295c9f80c81040a4a3637e63ed7c8a2a5b71cf004a93ebe16b3f

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 177.8 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 17fbad194a7f6f1f50387f866de6f85d09a83ff72c6c81d1b74b7b545a9d07ed
MD5 625f0880c59f35542505eff6a471bd13
BLAKE2b-256 db565b6407fb4fc8737f2a0589ca6a0e99f3d9c21439f9cf1c6117bb8dc403cb

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp37-cp37m-manylinux2010_i686.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp37-cp37m-manylinux2010_i686.whl
  • Upload date:
  • Size: 186.0 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 567eea45ec0e497aaa5d3453c812c8ba0729c39d294c61386b7188a59f8f4ca3
MD5 55a70e84d49e479b900e8db6e00c5849
BLAKE2b-256 12a5c4435f740337218314f9c399dca98141403c504b82dfd5f86edad37df707

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 149.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e6574eb5ab74181ffa14fb8bccbe6e412fb7137ebdbf6be6b2506c3fb5ad1b00
MD5 931ccf9181d6ed8c876da3b9ca1e261e
BLAKE2b-256 685f109be3cb21fc459f8fb19bae8660c176879305ce6aa411fda954397bdc22

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 148.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7a4c778a260e5a705f726082ae8411ec4427e45653f3ef50de8ac69b2bcc0fbb
MD5 e9b0cb382fd6481c51408f53fadb4151
BLAKE2b-256 7908799262b87e1c4eb1b0baac1ea2b230357629675e8488d188eacff6a573f8

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 177.8 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e4fcecab208ca78ae059bf38a1bd7f766a060d6f0619b048aa048b4162b0fd8e
MD5 2671309175b01918cf39661ee4c8ce4f
BLAKE2b-256 eac51b573f84ea684efd26524ff2421c9cc4fb13de82d6a202f0be6ebfdb13a7

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp36-cp36m-manylinux2010_i686.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp36-cp36m-manylinux2010_i686.whl
  • Upload date:
  • Size: 185.9 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 2bbcf17d106586080bfc8c79680a86c882a7a95c19542f7739d074ce1f40d2a5
MD5 0e072e5efc57f82369dd0bed1f427fea
BLAKE2b-256 533bb33d717d1defdc84aeb0acda235d0d53500461e4a4fe39dd2f1f8c73d726

See more details on using hashes here.

File details

Details for the file PyMatching-0.2.5-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: PyMatching-0.2.5-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 149.5 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for PyMatching-0.2.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b6f9a6a22ebdc66ad6319de060d11ed9bf78d7e9eefed7b59d9b5771ca27f133
MD5 e756fe834d16aa7c7fae15bbf93ef642
BLAKE2b-256 51f5deb5866dd5fcbcb86096b631d2c6b9c234222a889ecfbb7c090628c6d63c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page