Skip to main content

qLDPC

qLDPC is a Python toolkit for constructing and analyzing finite-size quantum low-density parity-check codes, as well as stabilizer and subsystem codes more broadly. The goal is simple: make the quantum error-correction literature easier to explore, reproduce, and build on. Codes can start from parity-check matrices or from higher-level ingredients such as polynomials, group rings, Tanner graphs, and chain complexes. Once a code is built, you can inspect its logical operators, compute or bound its distance, plug in a decoder, estimate logical error rates, and—for qubit codes—build stim circuits.

Most code-level tools work over arbitrary finite fields. Circuit tools currently only support qubit codes.

✨ A taste of qLDPC

  • From textbook codes to the research frontier. Build familiar surface, toric, Hamming, and Reed–Muller codes alongside hypergraph-product, lifted-product, bivariate-bicycle, quantum Tanner, SHYPS, GALA, and other modern families.
  • Go beyond binary. Many constructions and core algorithms work over arbitrary prime-power finite fields, not just qubits.
  • Ask more of a code than [[n, k, d]]. Work with check matrices, Tanner graphs, canonical logical operators, subsystem gauges, exact distances, upper bounds, and code-capacity error estimates.
  • Move from codes to circuits. Build memory experiments, encoding circuits, Pauli noise models, state-preparation diagnostics, Sinter decoders, sliding-window decoders, and transversal Clifford searches.
  • Use the algebra that modern constructions need. qLDPC includes finite groups, group rings, lifted matrices, Cayley complexes, chain complexes, and optional GAP integration.
  • Steal from the examples. The notebooks progress from the basics to circuit-level logical error rates, custom noise, transversal gates, and experimental lattice surgery.

qLDPC is still research software, and it is honest about the tradeoffs. Some searches are expensive, some bounds are heuristic, experimental APIs can change, and optional tools may have side effects.

📦 Installation

Standard installation

qLDPC requires Python 3.11 or later:

python -m pip install qldpc

Optional extras

Decoders

qLDPC installs ldpc and pymatching by default, which include a host of decoders. You can install every decoder available in qldpc for your platform with:

python -m pip install 'qldpc[decoders]'

You can also use individual extras to install a specific optional decoder:

python -m pip install 'qldpc[relay-bp]'
python -m pip install 'qldpc[tesseract]'

The Tesseract decoder requires CPython 3.12–3.14 on macOS arm64 or Linux x86-64.

GAP integration

Some algebra tools, code lookups, and distance estimates require GAP. For the recommended in-process integration, install qLDPC with its maintained libgap extra:

python -m pip install 'qldpc[gap]'

qLDPC uses passagemath-gap when available, so supported GAP operations do not launch a separate process. The in-process binding requires Python 3.13 on a non-Windows platform. If passagemath-gap is unavailable, qLDPC relies on a GAP executable in your PATH (possibly obtainable with conda install -c conda-forge gap), and a manual copy/paste fallback. GAP integration on Windows remains limited; see issue #294.

sqetch distance estimation

You can install the optional sqetch distance-estimation backend with:

python -m pip install 'sqetch[gpu] @ git+https://github.com/a7b/yarn.git@e9ce9d0fcecc973988558bfee27fab6d6b8d7f97#subdirectory=sqetch'

This command installs the upstream version of sqetch that qLDPC is tested against, with GPU support. sqetch is not published on PyPI, so it is not available as a qLDPC extra. For binary CSS codes, you can select this backend with code.get_distance_bound(backend="sqetch").

Troubleshooting

On macOS, you may need to install cvxpy manually by following its installation instructions before installing qLDPC. If you use Conda to manage your Python environment, install cvxpy with:

conda install -c conda-forge cvxpy

Development installation

For a development installation:

git clone https://github.com/qLDPCOrg/qLDPC.git
cd qLDPC
python -m pip install -e '.[dev]'

🚀 Quickstart

from sympy.abc import x, y

from qldpc import codes

# The [[144, 12, 12]] bivariate bicycle "gross code".
code = codes.BBCode({x: 12, y: 6}, x**3 + y + y**2, y**3 + x + x**2)

print(code)
print("physical qubits:", len(code))
print("logical qubits:", code.dimension)

Go deeper: a subsystem lifted-product code

The next example builds a parity-check matrix over the group algebra GF(2)[C₅], lifts each group-ring entry to a 5×5 binary block, and hands the result to SLPCode. The subsystem lifted-product construction produces an 80-qubit CSS subsystem code with 5 logical qubits and 45 gauge qubits.

from qldpc import abstract, codes

group = abstract.CyclicGroup(5)
ring = abstract.GroupRing(group)
x = ring.generators[0]

repetition = abstract.RingArray.build(
    [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1]],
    ring,
)
connections = abstract.RingArray.build(
    [[0, x, 0, 0], [0, 0, x, 0], [0, 0, 0, x]],
    ring,
)
code = codes.SLPCode(repetition + connections)

print("physical qubits:", len(code))            # 80
print("logical qubits:", code.dimension)        # 5
print("gauge qubits:", code.gauge_dimension)    # 45

Continue with the library map for the data model and package structure, or open the example notebooks for complete workflows.

🧭 Find your way around

Goal Start here
Understand code representations and how packages fit together Library map
Learn by running complete workflows Examples
Browse code families, functions, and exact signatures API reference
Construct and analyze a first code qLDPC basics
Estimate logical error rates Logical-error-rate examples
Build memory circuits or noise models Circuit examples
Change or extend qLDPC safely Agent and contributor guide

For the complete list of classes and functions, including construction-specific literature, use the API reference and source docstrings. This README focuses on getting started and finding the right documentation.

⚠️ Limitations and caveats

  • Circuit and tableau tools only work with qubit codes, even though other parts of qLDPC support prime-power-dimensional qudits.
  • Circuits returned by get_encoding_circuit are not fault-tolerant. Fault-tolerant encoding is tracked in issue #327.
  • Exact distance calculations and transversal-gate searches can be exponential. When a method returns a bound rather than an exact distance, its docstring explains what kind of bound it is.
  • Features that use GAP may start subprocesses, use local disk caches, access online resources, or ask for manual input or permission to install a package.
  • Everything under qldpc.experimental has an unstable public API and may change without deprecation. In particular, lattice-surgery support has not yet received independent expert review; validate its results independently and pin the qLDPC version if you depend on it.

📚 Documentation and support

Questions, feedback, and ideas are welcome through GitHub issues or by email 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:

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

qLDPC is distributed under the Apache License 2.0.

Metadata

Release files for qldpc 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qldpc 0.4.1
File Size Uploaded
qldpc-0.4.1.tar.gz 573.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qldpc 0.4.1
File Interpreter ABI Platform
qldpc-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / qldpc-0.4.1.tar.gz

Download URL qldpc-0.4.1.tar.gz
Size 573.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ee4c988bdffa26cde9bdf65b3676be81c35d6d53ac87c44a0c9462f4380e267c
BLAKE2b-256 checksum
How to use checksums
1020a82b0c6f943628a0b706dfd24d2a1588ceae2a7a8056bdfea15d90ec4118
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.12

Release files / qldpc-0.4.1-py3-none-any.whl

Download URL qldpc-0.4.1-py3-none-any.whl
Size 658.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27c971d58e9ffe12859cedd6e41c366b272d0b5008e28c95e7c0c0c6d7d3826c
BLAKE2b-256 checksum
How to use checksums
8914c2fe1beef714c0687c38614bc15832ecad5b3dab3606cf26acdf23dadbdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release 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