{"library":"pymatching","title":"PyMatching","description":"PyMatching is a high-performance Python package for decoding quantum error correcting codes using minimum-weight perfect matching algorithms. It provides an efficient C++ implementation of the blossom algorithm, significantly speeding up decoding for large codes. The library is actively maintained with frequent minor releases for bug fixes and feature additions, and major updates approximately every 1-2 years introducing significant architectural changes or performance improvements. The current version is 2.3.1.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pymatching"],"cli":null},"imports":["from pymatching import Matching"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pymatching\nimport numpy as np\nimport scipy.sparse\n\n# Example: Parity check matrix (H) for a simple [3,1,2] repetition code\n# This H matrix represents two stabilizers: qubit0^qubit1 and qubit1^qubit2\nH = scipy.sparse.csc_matrix(np.array([\n    [1, 1, 0],\n    [0, 1, 1]\n]))\n\n# Initialize the Matching object from the parity check matrix\nmatching = pymatching.Matching(H)\n\n# Simulate a syndrome measurement (e.g., after an error on qubit 1)\n# An error on qubit 1 flips both stabilizers (syndrome = [1, 1])\nsyndrome = np.array([1, 1])\n\n# Decode the syndrome to find the most likely error pattern\n# The result 'correction' is a binary vector indicating the predicted error locations\ncorrection = matching.decode(syndrome)\n\nprint(f\"Input syndrome: {syndrome}\")\nprint(f\"Predicted error pattern: {correction}\")\n# Expected output for syndrome [1,1]: [0, 1, 0] (error on qubit 1)","lang":"python","description":"This quickstart demonstrates how to create a `Matching` object from a `scipy.sparse` matrix representing a parity check matrix, simulate a syndrome, and decode it to find the most likely error pattern.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}