Skip to main content

LDPC: Python Tools for Low Density Parity Check Codes

Project description

LDPC: Software for Decoding Classical and Quantum Codes

LDPC Version 2: A C++ rewrite of the LDPCv1 package for decoding low density parity check checks. Warning, whilst efforts have been made to provide backwards compatability with LDPCv1, the new version may introduce breaking changes.

Documentation

The documentation for LDPCv2 can be found here

Installation

The easiest way to install the package is via pip. Python versions >=3.9 are supported.

pip install -U ldpc

Python - Installation from source

The C++ source code can be found in src_cpp. Python bindings are implemented using Cython and can be found in src/ldpc. To install the Python version of the repository follows the instructions below:

  • Download the repo.
  • Navigate to the root.
  • Pip install with python>=3.8. Note: installation requires a C compiler. Eg. gcc on Linux or clang on Windows.
git clone git@github.com:quantumgizmos/ldpc_v2.git
cd ldpc
pip install -Ue .

LDPCv1

If your package requires LDPCv1, this can be installed from PyPi as follows:

pip install -U ldpc==0.1.60

New features

  • A new C++ template class GF2Sparse. This is a more flexible implementation of the mod2sparse data structure used in the LDPCv1. This will make it much easier to expand the package.
  • Serial schedules for the BP decoder.
  • Run-time improvements for BP+OSD OSD-0. The decoder now implements the fast-syndrome OSD-0 implementation (https://arxiv.org/abs/1904.02703), where Gaussian elimination is terminated as soon as the syndrome becomes linearly dependent on the reduced columns.
  • BP+LSD: Belief propagation plus localised statistics decoding. A parallel decoding algorithm that matches the perforance of BP+OSD. Note that the version implemented currenlty runs in serial. We are working on the parallel version! See our paper: https://arxiv.org/abs/2406.18655
  • The union-find matching decoder (https://arxiv.org/abs/1709.06218). This is an implementation of the Delfosse-Nickerson union-find decoder that is suitable for decoding surface codes and other codes with "matchable" syndromes.
  • The BeliefFind decoder. A decoder that first runs belief propagation, and falls back on union-find if if the BP decoder fails to converge as proposed by Oscar Higgott in https://arxiv.org/abs/2203.04948
  • Flip and P-flip decoders as introduced by Thomas Scruby in https://arxiv.org/abs/2212.06985.
  • Improved GF2 linear algebra routines (useful for computing code parameters)

ToDos

LDPCv2 is still a work in progress. Ongoing projects are listed below:

  • Implement parallel version of BP+LSD algorithm using OpenMP.
  • Improve support for parallel processing across the package.
  • More decoders could be implemented (eg. small set-flip, https://arxiv.org/abs/1810.03681)
  • Stabiliser inactivation BP (https://arxiv.org/abs/2205.06125)
  • Generalised BP (https://arxiv.org/abs/2212.03214)
  • Functions need to be properly documented (in progress)
  • Further STIM integration
  • More functionality for studying classical codes. Eg. support for received vector decoding and the AWGN noise channel.

BP+LSD Quickstart

Usage of the new BP+LSD decoder from https://arxiv.org/abs/2406.18655. Similar to BP+OSD, the LSD decoder can be applied to any parity check matrix. We recommend you start with lsd_order=0. The speed/accuracy trade-off for higher order values can be explored from there. Example below:

import numpy as np
import ldpc.codes
from ldpc.bplsd_decoder import BpLsdDecoder

H = ldpc.codes.hamming_code(5)

## The
bp_osd = BpLsdDecoder(
            H,
            error_rate = 0.1,
            bp_method = 'product_sum',
            max_iter = 2,
            schedule = 'serial',
            lsd_method = 'lsd_cs',
            lsd_order = 0
        )

syndrome = np.random.randint(size=H.shape[0], low=0, high=2).astype(np.uint8)

print(f"Syndrome: {syndrome}")
decoding = bp_osd.decode(syndrome)
print(f"Decoding: {decoding}")
decoding_syndrome = H@decoding % 2
print(f"Decoding syndrome: {decoding_syndrome}")

Attribution

If you use this software in your research please cite as follows:

@software{Roffe_LDPC_Python_tools_2022,
author = {Roffe, Joschka},
title = {{LDPC: Python tools for low density parity check codes}},
url = {https://pypi.org/project/ldpc/},
year = {2022}
}

If you have used the BP+OSD class for quantum error correction, please also cite the following paper:

@article{roffe_decoding_2020,
   title={Decoding across the quantum low-density parity-check code landscape},
   volume={2},
   ISSN={2643-1564},
   url={http://dx.doi.org/10.1103/PhysRevResearch.2.043423},
   DOI={10.1103/physrevresearch.2.043423},
   number={4},
   journal={Physical Review Research},
   publisher={American Physical Society (APS)},
   author={Roffe, Joschka and White, David R. and Burton, Simon and Campbell, Earl},
   year={2020},
   month={Dec}
}

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

ldpc-2.3.6.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

ldpc-2.3.6-cp313-cp313-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.13Windows x86-64

ldpc-2.3.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ldpc-2.3.6-cp313-cp313-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ldpc-2.3.6-cp313-cp313-macosx_10_13_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

ldpc-2.3.6-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

ldpc-2.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ldpc-2.3.6-cp312-cp312-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ldpc-2.3.6-cp312-cp312-macosx_10_13_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

ldpc-2.3.6-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

ldpc-2.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ldpc-2.3.6-cp311-cp311-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ldpc-2.3.6-cp311-cp311-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ldpc-2.3.6-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

ldpc-2.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ldpc-2.3.6-cp310-cp310-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ldpc-2.3.6-cp310-cp310-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

ldpc-2.3.6-cp39-cp39-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.9Windows x86-64

ldpc-2.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ldpc-2.3.6-cp39-cp39-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ldpc-2.3.6-cp39-cp39-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file ldpc-2.3.6.tar.gz.

File metadata

  • Download URL: ldpc-2.3.6.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6.tar.gz
Algorithm Hash digest
SHA256 0bb1c48e174593f5fbf2081d7cc0e9e2b5dc9a44c5132d2c06c94b3118979a05
MD5 131e35cccce6602c132dd535ea21a85b
BLAKE2b-256 7532bc09abbf67421c4e04d823e3c3cb7496395b1b1a082a948dbaa5d42abb9a

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dcd6a9f8d3ff9c6ea603f82c7188395910081226669e1c92347bbe27c5843db4
MD5 6dcde9c8c09a9bd8e4373325f0283a83
BLAKE2b-256 9de381c98264ee9c543d453ac4c485db9467cac3ccce3eadaf34b6d8003f2c87

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 053331b35f2d928308caf0c7a3b3d62b8fbb1ac2d487a48434776b116a5547ef
MD5 d3c3d631cafa661041e29327c01399de
BLAKE2b-256 3a024408e0fb5f4c7ca7c35c8d90a8b98df70216ae047a3c4fadf5e459db0742

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 065e9dc09cedd60ce6bdab22ed219adf9059dcda7bcb573ded243245f51e6aaa
MD5 d8f693f778ea379e087a237c687a8214
BLAKE2b-256 abac7e225e42f468349ffdb253e3aa9cb99294c5769f335336e631e7989685d7

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0785f5e6c7836baecf3bb22b4f2d8d6591daf01352b495c799e6b9458bcc0ffd
MD5 b37b3f4316d255add25c8cb3adc82de7
BLAKE2b-256 59828f5dd5c701e922e5f6ce453a44d58899455bdd53c7331026e8c078c3c314

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 231caaafc6e2cb02d22825008e83f3dd338db5656d39e749a99ad24335fb0c7d
MD5 9edd4ee8ca17c0f76168548d29d49675
BLAKE2b-256 0fd5e2e34a230e17c3eb180c76fd5281ac0a18c0beca0e827635a6fcb95843f7

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b73e57fc7ad46710c9f44142f4a0ee4c33d25e8880c5cbde0e52bc14854fef32
MD5 4c4d41e7639ba605daf75c8bf2b076c0
BLAKE2b-256 5c2734fff6abe70dfac1721b1595c86fcc1361ec45fce211de59440ff428c56d

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23d4166f7a42e19cab31826088009840f34d8ea1904db18c23a8263537c42cef
MD5 81d9bf72c576acd05a73b7da97851ecb
BLAKE2b-256 e2b9210a7b0f8ef3f96d5bb5e5240ca7bad09b3abc404d250522d133cbada1b1

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b7287998fe0f31d430d43f8e4f8686ab9a289c375ea1626f29085e7868343720
MD5 fe8b78a679a6ba0bfe734b7efa6bba92
BLAKE2b-256 81d442d3473b10bf9967a7541063fba331a2bbc246288a9434ad9739ada7e08b

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 72533a6e77fd9e634df9ad223f32fffc9f7d2b1eb437f07a70b2afddb66a7e36
MD5 cc58b4281936119d406c873bb9b16673
BLAKE2b-256 cf9a46d461b9c069a4e65374c2c91efb774bcbb5aa6e74a2b8a4f8deafcb3d2a

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f42fcc5422a1b58a7e28e40d8a6e6148bd4b592af4b5dd5823d71dabcbf67172
MD5 ecdc1dffbc3969e6acd26731b031f5a1
BLAKE2b-256 3bdaf5253d8b29a71f087d684d55e85bade0f0296604073c78772c40fc1c6039

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50609e3bb421e96e9a07ea4e381d0da805b311ce284881d191bb35d727d6c336
MD5 f8f6f774cce895c818ab1d19c3563ac2
BLAKE2b-256 489eae8bbbaac02a00f81e5902487b99f7bceb008b639b0f05db926c6affc634

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e06b6baccb9e8af169a30c786ceebe2ddefba30f2b0e34bea8d728fc7e605cc8
MD5 bb29219540f1a3d67e2f9673ef13f441
BLAKE2b-256 e582338cfba69a87b5f916caae496c451bbc639e59ddd65380848306bcd36190

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f6d908e25cbdb3baf40386ddc41b6fbae9b5a73d7ea636f511f1e188151b6bcb
MD5 b83077c6b98ed34bc7df2a3b7cb47e8e
BLAKE2b-256 a13b461ea0c732409e5397a0c0574b6a6681cdc54e1077d67223987c8a4abd71

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80d7fc40841944431f9a8d1384c3b05ec1b3676bf907da6563d385ef5653d473
MD5 9092b9cdff7a749055c27297fe920f60
BLAKE2b-256 6965f57668d77de40d63475040029748d23937539bfd74cdb6d84f8db64fdf50

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 602e429559bef0dcc1665a355e6ba3508b04c7b829ae3fa085e8f442d69bbbac
MD5 20da4940be5280ca5a58544145d37caa
BLAKE2b-256 3ffd276ae8054c875457190fd647f3959b359229bd4e81b7713fea24da24ff46

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3472d9a651e25e9c7c641c502a1f6d7043555fc6ef2c2b71eb2a0eb1d1f822e1
MD5 def2f53f734a5a73ccd6aec346290f2d
BLAKE2b-256 06d10d6942e55bb10182bcb66cbb0cb673dcf881f446e3bb3f1dc08a8073704d

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e090a83f7c0bdc1f199d673e9dcc568d0211d9d17b69c754d43324c30f98d16a
MD5 0f374cba4d82b8af3171f46f3226872b
BLAKE2b-256 9174e9bcfd997b68a3c87d1d70b70a4f1d5f3c1595404007cf2e247471d5ba30

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ldpc-2.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2b734bbc61c5688860da2658819e9d4d3cc0cabe5857afc4b695255034aae56
MD5 7ad7b806aa2d19280176c359ef477be2
BLAKE2b-256 01b15b5d1c92e6ff06f134096bb00f47d201073b59aea7eec3ccee8faaa5593e

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d72cb69f856efe97cd13184fe568758215b8ce645bd1cff8aa1a32f0f52064f1
MD5 9cf1e4a023add14ea96bd18799edc38a
BLAKE2b-256 c5010ee8bf15b642d1607ef69776211b6cbe5c1cc413dde7292f9a0fe90c732f

See more details on using hashes here.

File details

Details for the file ldpc-2.3.6-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: ldpc-2.3.6-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ldpc-2.3.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 789c5348e574b1bfd5164f0237eef99c024dcd0d19c0ac527cf1e11e5f3cb0a3
MD5 3116d531ebfc28b9445c576dce284ea6
BLAKE2b-256 d7ec5e71e2a7924f4af86a68239dc3cc85bcb14f5b38638e6f6664b053ee229b

See more details on using hashes here.

Supported by

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