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.4.tar.gz (969.0 kB view details)

Uploaded Source

Built Distributions

ldpc-2.3.4-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13 Windows x86-64

ldpc-2.3.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.13 macOS 11.0+ ARM64

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

Uploaded CPython 3.13 macOS 10.13+ x86-64

ldpc-2.3.4-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

ldpc-2.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.12 macOS 10.13+ x86-64

ldpc-2.3.4-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

ldpc-2.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

ldpc-2.3.4-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

ldpc-2.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

ldpc-2.3.4-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

ldpc-2.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ldpc-2.3.4-cp39-cp39-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for ldpc-2.3.4.tar.gz
Algorithm Hash digest
SHA256 a1b2db1669ceac54ad47b02fddc5c3b17c28b40830f068a35e188e65e46c1308
MD5 29e54c8fd56600bb4280e705eab25a6d
BLAKE2b-256 c4e5c5fd21623e024eb93e68a992f53a2d190ddd853328d5e5ebc29053be642c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ldpc-2.3.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ab4afa3359eef13034d7fbb58382d66f460e6ed7299c9a784670198d99ca4100
MD5 a1338723d5ab30235c226422d5fcd2e1
BLAKE2b-256 67a32785b85f2e9afefec949fc379d05491c7a8f848b84cb82b82906f01786b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16a74081e23271a2bd7f41b1ff79340d7ea89f265a67235942daca30a57ff73e
MD5 a0f519dff237fd68ed46ad808d0260cb
BLAKE2b-256 1d94b1e5cfad4028e7bfef096118ad0cbe5b6bfab3ba74ff9c41370aeeecf1ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a4f9a8d19a3d00b6e03269600b51a58d532956107cbaf145b051b6c99fe1058
MD5 7a86f5cf9a72fd47433d16a64eb28dfe
BLAKE2b-256 c6579ac04d12b7ce6f89159731f87ad59445b94bcc2d951d933e37e6cbd80ed1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bd4c56123ad0b7c754eb2b64c18fbbcbc7d186ef486a0a37cea89d6e202e731b
MD5 5aa27e53281cda5305557ceb3ee3f39a
BLAKE2b-256 9254386006dccf46d93d7f9eb92a768cfb1511be45703294888be14630deb85c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ldpc-2.3.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 21e1b5b6dd5e539a18e53ce78458f852f3b68b91d52ac875526daab6e801dfcc
MD5 7066c2c68e7969e88f7e86abd97f9d83
BLAKE2b-256 12452958dc5f4abfb18b9d5fa1867448d40d64c65759e764e9dc5ca225347779

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 81ec15b7c547947e4307be6400f9adde4c4d6df52965c8c3004edb77b2ca9469
MD5 b9006b607fe49395af8f7c97288c0eaa
BLAKE2b-256 2015a520f790a6beeba4f4beea16c09dc7be3d841ac172d4dd3c41a9f24124cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c997de0e680a7dec79b80e52c452f9ef06f9ff0883d639c6972fd4c2311ad03
MD5 66b70a5c6038b66b69feb75145a75bdc
BLAKE2b-256 5de64c82ff776177493edb3c9d5c07fe7eff3d67abcdd473068b7d6ccc4f77d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ac8173979200439fde3e6acefd36bb68eb26b9f5f3dbb6e69fc91fa347500b95
MD5 80751fa17764fb4b7fafa26b14bbd4d8
BLAKE2b-256 d002313f40d2233f2f5f34326873d91f66db89069a9cd4c218ccf6e543649112

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ldpc-2.3.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a4108fa3dd7baa1b249e40737afc7f159d56b50cebcc2f469dbce8fdc149a2f0
MD5 fef78c12fe5ebf7070fd8a43f9928eed
BLAKE2b-256 2597cfebb905f2b7fdc4d24e91978c5583ed8c974efd1633ced35342a973c7ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 210b22462dacbf3bb1c54b31b67ed13aa0fccc32707e2d99da825c7bcd8c4437
MD5 1a7f0b3148073bee0bd07f137df79392
BLAKE2b-256 e1c930ed9afa085aece9018d3d34eeeb9437db6226263bbfdb5d429af56eca4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63fd76d203366230043e76cd9b7e42da44e6f1ee0e4b3a6bc4ce08ebd9be4df0
MD5 52d277f47646a684344343d90ada0d97
BLAKE2b-256 e03088d9ab51b54d35c9a11af553aa938faade643b6777a8c65489afc174d517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 79586214795694557efd379499ad8cc1d69b5c7a477d19913553c8f16fe1053d
MD5 7afbe229ec5b0fe1be4063595ec4651a
BLAKE2b-256 426d6857dd8ed1c7ddef1be5018fc6b35684492f1946afed1588fdea231aa7aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ldpc-2.3.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5c781ab4d616ca8e1bb40e49a6c0947704a99359a6bed63922dbb8bb25c166e3
MD5 c880767d499eb8f9132d693b93748dda
BLAKE2b-256 53f66827b92dc7b407a782eb6caf2e13c565838c088d95b34e18cf318f438b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7386b8f055baf6db54377a5150cc6d34fbaf42db1cebfb3255be9103094a30b9
MD5 a384d792472b28166d9748efad895a09
BLAKE2b-256 976cd1b61598758f728c341e728c45712b9633b96326c267d7fd8d4dfa8232ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 125abf89bc9140f35d9c11bc61ae0361b3900a3fc28ac630b18e6e4b8f3cd4db
MD5 b55129ed5ec6dd7218df7fffb4fea280
BLAKE2b-256 e72fcc782d7af38d6d58861cf4f0c1d271f11549dc34a989aeb64e4f1b3e6979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e554017e287c2ce06401b1e79fb387e970eac0dc5d442c3ee25ed333813bba79
MD5 d147d6dfc70be4ff537427b9bc9cc194
BLAKE2b-256 202cf62b106166486dab023dfe40a69582857d16efd719793fedee44c2bff67d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ldpc-2.3.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1951c2c196f3e9e7ff69d76ed65fcc4a0f0ca1e6c7d50db229ad8fa177ed88f3
MD5 aaf18d505757ce41b16e58e42beb406e
BLAKE2b-256 21f88b677172fcc8af493bd9b983e32b80ba86d5c5825ee4b6517e751673b21b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62cada7dd5c9a0fabbaa947141a23e759beef02a4f54d9a2c01651fcc91234b2
MD5 0f61417299f7fd9118eda08e2629b64a
BLAKE2b-256 e2544971058082bebd5eea71a005a703f83126d99d7ea17bd40d49d478be7fcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee3f24c1691563bd2e30d005efd843d1608f7586028f66ec93b339b21b632150
MD5 b44d53b189d86a61bc6eb0c4dc13d8cf
BLAKE2b-256 b8907910b9421e95c360290d8485bf9cb7a0ec9b98c9abf5ae6f48ce3858ae06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ldpc-2.3.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2d41b6ea1e7b4a079415b66d6803ac6b6d8c49c21d6a3f231100dedd5d2978f3
MD5 ec7b5aaded8671d87882eb89e15f7964
BLAKE2b-256 1039ca38a04dd23a8b9dd1609b3b084e02398a10291633380be9a4317f9cec1d

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page