Skip to main content

qLDPC

This library contains tools for constructing and analyzing quantum low density parity check (qLDPC) codes. At least, that was the original motivation for this library. In practice, the tools here work just as well for stabilizer and subsystem codes more broadly.

In a nutshell, qLDPC provides methods to build a variety of built-in and custom codes, represented under the hood by a parity check matrix. Once a code is constructed, qLDPC automates various tasks of common interest, integrating with a variety of external tools (including ldpc, stim, sinter, QDistRnd, and MAGMA, among others). Automated tasks include:

  • constructing a code from a variety of code families,
  • constructing a canonical basis of logical Pauli operators,
  • computing (or upper-bounding) code distance,
  • computing logical error rates in a code-capacity model,
  • computing the logical error rates and post-selection rates of state preparation circuits,
  • constructing circuits of interest, such as memory experiments and logical encoding circuits,
  • defining custom Pauli noise models,
  • using a decoder of your choice for any of the above (or other, unlisted) tasks.

See the examples directory for some demonstrations and use-cases.

Where possible, this library strives to support codes over arbitrary finite (Galois) fields -- that is, for Galois qudits of any prime power dimension. Circuit-related utilities are, however, limited to qubit codes.

📦 Installation

This library requires Python>=3.10, and can be installed from the Python Package Index (PyPI) with

pip install qldpc

To install a local version of qLDPC from source:

git clone https://github.com/qLDPCOrg/qLDPC.git
pip install -e qLDPC

You can also pip install -e 'qLDPC[dev]' to additionally install some development tools.

GAP

Some features in qLDPC require an installation of the GAP computer algebra system. If you (a) use linux or macOS, and (b) use a conda to manage your python environment, then you can obtain GAP by running

conda install -c conda-forge gap

or conda install -c conda-forge gap-core. Installations without conda should also work, as long as gap is a recognized command in the command line. Unfortunately, GAP integration is clunky in Windows because I have not figured out how to call GAP from the Windows command prompt. If you figure this out, please let me know!

macOS

If you use macOS you may need to install cvxpy manually by following the instructions here before installing qLDPC. If you use conda to manage your python environment, you can obtain cvxpy by running

conda install -c conda-forge cvxpy

🚀 Features

Notable features include:

  • ClassicalCode: class for representing classical linear error-correcting codes over finite fields.
    • Various pre-defined classical code families, including RepetitionCode, HammingCode, SimplexCode, ReedMullerCode, ReedSolomonCode, TannerCode, and more.
    • Communication with the GAP/GUAVA package for even more codes.
  • QuditCode: class for constructing Galois-qudit codes, including both stabilizer and subsystem codes.
    • QuditCode.get_logical_ops: method to construct a complete basis of nontrivial logical Pauli operators for a QuditCode.
    • QuditCode.get_distance: method to compute the exact code distance of a QuditCode (i.e., the minimum weight of a nontrivial logical operator). Includes options to compute an upper bound on code distance using QDistRnd or (for CSS codes) a decoder-based method introduced in arXiv:2308.07915.
    • QuditCode.concatenate: method to concatenate QuditCodes in various ways.
  • CSSCode: subclass of QuditCode for the special case of constructing a quantum CSS code out of two mutually compatible ClassicalCodes. Special cases (subclasses) with specialized constructors and helper methods include:
  • qldpc.decoders: module for decoding code and circuit errors.
    • BP-OSD, BP-LSD, and belief-find (via ldpc), Relay-BP (via relay-bp), minimum-weight perfect matching (via pymatching), lookup-table decoding, and others. Includes an interface for using custom decoders.
    • SinterDecoder: class to construct circuit-level decoders that are usable by sinter.
    • SlidingWindowDecoder: the overlapping-recovery sliding-window decoder of arXiv:quant-ph/0110143 and arXiv:2209.08552.
    • SequentialWindowDecoder: a generalization of the SlidingWindowDecoder for arbitrary decoding and commit regions.
    • DetectorErrorModelArrays: representation of a stim.DetectorErrorModel with scipy.sparse and numpy arrays (detector_flip_matrix, observable_flip_matrix, error_probs).
  • qldpc.circuits: module for stim circuits and circuit utilities, including:
    • get_memory_experiment: circuit to test the performance of a code as a quantum memory (using various pre-built syndrome measurement strategies), appropriately annotated with detectors and observables.
    • get_state_prep_diagnostic_circuit, get_state_prep_diagnostic_tasks, get_logical_error_and_discard_rate: helper methods for computing the logical error rates and post-selection rates of state preparation circuits.
    • NoiseModel: class for constructing expressive Pauli noise models, which map noiseless circuits to noisy circuits. Built-in subclasses include a single-parameter DepolarizingNoiseModel and a superconducting-inspired SI1000NoiseModel.
    • get_encoding_circuit: circuit to encode physical states of qubits into logical states of a code, for example to prepare a logical all-|0> state. (Warning: current encoding circuits are not fault-tolerant. The construction of fault-tolerant encoding circuits is an open issue.)
    • get_transversal_ops: logical tableaus and physical circuits for the SWAP-transversal logical Clifford gates of a code, constructed via the code automorphism method of arXiv:2409.18175. (Warning: exponential complexity.)
    • get_transversal_circuit: find a SWAP-transversal physical circuit (if any) that implements a given logical Clifford operation in a code. (Warning: exponential complexity.)
  • qldpc.abstract: module for abstract algebra (groups, rings, modules, and representations thereof).
  • qldpc.objects: module for constructing helper objects such as Cayley complexes and chain complexes, which are instrumental for the construction of various quantum codes.

🤔 Questions and issues

This project aspires to one day have a proper documentation page. In the meantime, I recommend looking at source code and the detailed comments therein, as well as help(qldpc.object_of_interest). qLDPC requires every file (such as qldpc/codes/quantum.py) to be covered by its own test file (such as qldpc/codes/quantum_test.py), so test files are a good place to look for example usage of any function, class, etc. Finally, the examples directory has some helpful notebooks to get you started.

If you have any questions, feedback, or requests, please open an issue on GitHub or email me at mika.perlin@gmail.com!

⚓ Attribution

If you use this software in your work, please cite with:

@misc{perlin2023qldpc,
  author = {Perlin, Michael A.},
  title = {{qLDPC}},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/qLDPCOrg/qLDPC}},
}

This may require adding \usepackage{url} to your LaTeX file header. Alternatively, you can cite

Michael A. Perlin. qLDPC. https://github.com/qLDPCOrg/qLDPC, 2023.

Download files

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

Source Distribution

qldpc-0.3.2.tar.gz (262.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qldpc-0.3.2-py3-none-any.whl (308.8 kB view details)

Uploaded Python 3

File details

Details for the file qldpc-0.3.2.tar.gz.

File metadata

  • Download URL: qldpc-0.3.2.tar.gz
  • Upload date:
  • Size: 262.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qldpc-0.3.2.tar.gz
Algorithm Hash digest
SHA256 f58c1338a33ab30e4fb5ff438a08f7adfcb694c6df6d921146fe45b782d01b43
MD5 0c40cc1653fd61ef7c5bbce86d3c063c
BLAKE2b-256 7bc73ad727077390a011ac1fc38f56bac13386bb99c1a16f17f9f808a050a846

See more details on using hashes here.

File details

Details for the file qldpc-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: qldpc-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 308.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for qldpc-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d56d4cdefef92e3ad8a9f0d00e10d54f03ac59561f82ef46ccaacca5b0e8b704
MD5 6abec25e6df4affac21a12dd716c0d01
BLAKE2b-256 d49f9dd9757bd612c13cfde2e7f85222783d20dde963a2971a7aabf405b1c08a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

2 files

This release

0.3.2 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page