Skip to main content

mdopt — code-agnostic tensor-network (MPS-MPO) decoder for quantum error-correcting codes.

logo

codecov tests DOI Documentation Status pre-commit.ci status lint mypy CI Unitary Fund MIT license

mdopt is a python package built on top of numpy for discrete optimisation (with the main application to classical and quantum decoding) in the tensor-network (specifically, Matrix Product States / Operators) language. The intended audience includes physicists, quantum information / error correction researchers, and those interested in exploring tensor-network methods beyond traditional applications.

Installation

To install the current release, use the package manager pip.

pip install mdopt

Otherwise, you can clone the repository and use poetry.

poetry install

Minimal example

import numpy as np
import qecstruct as qec
from mdopt.examples.decoding.decoding import decode_css

# Define a small instance of the surface code
LATTICE_SIZE = 3
surface_code = qec.hypergraph_product(
    qec.repetition_code(LATTICE_SIZE),
    qec.repetition_code(LATTICE_SIZE),
)

# Input an error and choose decoder controls
logicals, success = decode_css(
    code=surface_code,
    error="IIXIIIIIIIIII",
    bias_prob=0.01,
    bias_type="Bitflip",
    chi_max=64,
    renormalise=True,
    contraction_strategy="Optimised",
    tolerance=1e-12,
    silent=False,
)

Examples

The examples folder contains full workflows that demonstrate typical use cases, such as quantum / classical LDPC code decoding, ground state search for the quantum Ising model and random quantum curcuit simulation. Each example is fully documented and serves as a starting point for building your own experiments. The package has been tested on macOS and Linux (Compute Canada clusters) and does not currently support Windows.

Cite

If you happen to find mdopt useful in your work, please consider supporting development by citing it.

@article{berezutskii2025mdopt,
  title={mdopt: A code-agnostic tensor-network decoder for quantum error-correcting codes},
  author={Berezutskii, Aleksandr},
  journal={Journal of Open Source Software},
  volume={10},
  number={115},
  pages={9125},
  year={2025}
}

Contribution guidelines

If you want to contribute to mdopt, be sure to follow GitHub's contribution guidelines. This project adheres to our code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs, please direct specific questions to the maintainers.

The mdopt project strives to abide by generally accepted best practices in open-source software development, such as:

  • apply the desired changes and resolve any code conflicts,
  • run the tests and ensure they pass,
  • build the package from source.

Developers may find the following guidelines useful:

  • Running tests. Tests are executed using pytest:

    pytest tests
    
  • Building documentation. Documentation is built with Sphinx. A convenience script is provided:

    ./generate_docs.sh
    
  • Coding style. The project follows the Black code style. Please run Black before submitting a pull request:

    black .
    
  • Pre-commit hooks. Pre-commit hooks are configured to enforce consistent style automatically. To enable them:

    pre-commit install
    

License

This project is licensed under the MIT License.

Documentation

Full documentation is available at mdopt.readthedocs.io.

Download files

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

Source Distribution

mdopt-2.0.0.tar.gz (123.0 kB view details)

Uploaded Source

Built Distribution

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

mdopt-2.0.0-py3-none-any.whl (173.1 kB view details)

Uploaded Python 3

File details

Details for the file mdopt-2.0.0.tar.gz.

File metadata

  • Download URL: mdopt-2.0.0.tar.gz
  • Upload date:
  • Size: 123.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mdopt-2.0.0.tar.gz
Algorithm Hash digest
SHA256 062d771a629138bfc11223607b51427330eab27f4be92fdca001ab9a622b37d6
MD5 7ef72034fa005ef29ba4cdc62379bafa
BLAKE2b-256 8c6ac921f533547d86ab82da12c1e13ababb207aac1f0ddf0a57a77a942bfcb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdopt-2.0.0.tar.gz:

Publisher: cd.yml on quicophy/mdopt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdopt-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: mdopt-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 173.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mdopt-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61c5464cfc344cfbacfeee19a191d9312e16ec9ad9c5b66a8075e1938665abd8
MD5 8a8a0c2f7a013539be35622cb293d031
BLAKE2b-256 cebb1cc1c0ea6a055fd9f0d70433d9be5e64e25b27464b71c18e71d4feeaaa6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdopt-2.0.0-py3-none-any.whl:

Publisher: cd.yml on quicophy/mdopt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.1.1

2 files

1.0.1

2 files

1.0.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

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