Skip to main content

License: MIT CI Python CI Bindings codecov

QECC: An MQT tool for Quantum Error Correcting Codes written in C++

⚠️ This project is still in early development and breaking changes might happen frequently.

(Additionally to the basic numerical results already provided, further data will be published continually)

A tool for quantum error correcting codes and numerical simulations developed by the Chair for Design Automation at the Technical University of Munich based on methods proposed in [1]. QECC is part of the Munich Quantum Toolkit (MQT).

The tool can be used to:

  • Decode quantum LDPC codes and conduct respective numerical simulations.
    • At the moment the general QLDPC decoder [2] and a heuristic (which improves the runtime of the algorithm) [1] are implemented. Currently, open-source software by Joschka Roffe et al.: [3] is used to construct codes (toric, lifted product and hypergraph product).
  • Decode (triangular) color codes and conduct respective numerical simulations.
    • The decoder is based on an analogy to the classical LightsOut puzzle and formulated as a MaxSAT problem. The SMT solver Z3 is used to determine minimal solutions of the MaxSAT problem, resulting in minimum-weight decoding estimates.
  • Apply error correction to quantum circuits.
    • The framework allows to apply different QECC schemes to quantum circuits and either exports the resulting circuits or simulates them using Qiskit [4]. Currently, six different ECCs are supported with varying extent of functionality.

Documentation

If you have any questions, feel free to contact us via quantum.cda@xcit.tum.de or by creating an issue on GitHub.

Getting Started

QECC is available via PyPI for Linux, macOS, and Windows.

(venv) $ pip install mqt.qecc

The following code gives an example on the usage:

Example for decoding quantum LDPC codes

from mqt.qecc import *
import numpy as np

H = [
    [1, 0, 0, 1, 0, 1, 1],
    [0, 1, 0, 1, 1, 0, 1],
    [0, 0, 1, 0, 1, 1, 1]
]
code = Code(H, H)
decoder = UFHeuristic()
decoder.set_code(code)
x_err = sample_iid_pauli_err(code.N, 0.05)
decoder.decode(code.get_x_syndrome(x_err))
result = decoder.result
print(result)
residual_err = np.array(x_err) ^ np.array(result.estimate)
print(code.is_x_stabilizer(residual_err))

Example for decoding color codes

Simply running the following code will perform a numerical analysis of the MaxSAT color code decoder for an instance of the distance-21 triangular color code with a bit-flip error rate of 0.01 and 1000 simulations.

from mqt.qecc.cc_decoder import decoder

d = 21  # distance of the triangular code to simulate
p = 0.01  # (bit-flip) error rate
nr_sims = 1000  # number of simulations to run
decoder.run(distance=d, error_rate=p, nr_sims=nr_sims)

The dataset used in the paper evaluation on decoding quantum color codes is available on Zenodo: a

Example for applying error correction to a circuit

from mqt import qecc

file = "path/to/qasm/file.qasm"  # Path to the OpenQASM file the quantum circuit shall be loaded from
ecc = "Q7Steane"  # Error correction code that shall be applied to the quantum circuit
ecc_frequency = 100  # After how many times a qubit is used, error correction is applied

result = qecc.apply_ecc(file, ecc, ecc_frequency)

# print the resulting circuit as OpenQASM string
print(result["circ"])

A wrapper script for applying error correction to quantum circuits (provided as OpenQASM) and performing a noise-aware quantum circuit simulation (using Qiskit) is provided. The script can be used like this:

$ (venv) ecc_qiskit_wrapper -ecc Q7Steane -fq 100 -m D -p 0.0001 -n 2000 -fs aer_simulator_stabilizer -s 0 -f  ent_simple1000_n2.qasm
_____Trying to simulate with D (prob=0.0001, shots=2000, n_qubits=17, error correction=Q7Steane) Error______
State |00> probability 0.515
State |01> probability 0.0055
State |10> probability 0.0025
State |11> probability 0.477

Detailed documentation on all available methods, options, and input formats is available at ReadTheDocs.

System Requirements and Building

The implementation is compatible with any C++17 compiler and a minimum CMake version of 3.19. Please refer to the documentation on how to build the project.

Building (and running) is continuously tested under Linux and macOS using the latest available system versions for GitHub Actions. Windows support is currently experimental.

Reference

If you use our tool for your research, we will be thankful if you refer to it by citing the appropriate publication:

  • a L. Berent, L. Burgholzer, P.J. Derks, J. Eisert, and R. Wille, "Decoding quantum color codes with MaxSAT".

  • a T. Grurl, C. Pichler, J. Fuss and R. Wille, "Automatic Implementation and Evaluation of Error-Correcting Codes for Quantum Computing: An Open-Source Framework for Quantum Error-Correction," in International Conference on VLSI Design and International Conference on Embedded Systems (VLSID), 2023

  • a L. Berent, L. Burgholzer, and R. Wille, "Software Tools for Decoding Quantum Low-Density Parity Check Codes," in Asia and South Pacific Design Automation Conference (ASP-DAC), 2023

Metadata

Release files for mqt.qecc 1.3.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 mqt.qecc 1.3.1
File Size Uploaded Provenance Actions
mqt.qecc-1.3.1.tar.gz 1.8 MB Without provenance Details for mqt.qecc-1.3.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mqt.qecc 1.3.1
File Actions
mqt.qecc-1.3.1-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for mqt.qecc-1.3.1-cp311-cp311-manylinux_2_28_x86_64.whl
mqt.qecc-1.3.1-cp311-cp311-macosx_10_15_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.15+ x86-64 Details for mqt.qecc-1.3.1-cp311-cp311-macosx_10_15_x86_64.whl
mqt.qecc-1.3.1-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for mqt.qecc-1.3.1-cp310-cp310-manylinux_2_28_x86_64.whl
mqt.qecc-1.3.1-cp310-cp310-macosx_10_15_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.15+ x86-64 Details for mqt.qecc-1.3.1-cp310-cp310-macosx_10_15_x86_64.whl
mqt.qecc-1.3.1-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details for mqt.qecc-1.3.1-cp39-cp39-manylinux_2_28_x86_64.whl
mqt.qecc-1.3.1-cp39-cp39-macosx_10_15_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.15+ x86-64 Details for mqt.qecc-1.3.1-cp39-cp39-macosx_10_15_x86_64.whl
mqt.qecc-1.3.1-cp38-cp38-manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.28+ x86-64 Details for mqt.qecc-1.3.1-cp38-cp38-manylinux_2_28_x86_64.whl
mqt.qecc-1.3.1-cp38-cp38-macosx_10_15_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.15+ x86-64 Details for mqt.qecc-1.3.1-cp38-cp38-macosx_10_15_x86_64.whl

Total release size: 92.5 MB

Release files / mqt.qecc-1.3.1.tar.gz

Download URL mqt.qecc-1.3.1.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
9cdafa79df8af6f708779433daa41f21266cf1d2167253be29b8644dcdf629dd
BLAKE2b-256 checksum
How to use checksums
ca682629e51567d0244b6ec6dccfa5978dc72c4a8c250a5bb07cadc9d5baf607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL mqt.qecc-1.3.1-cp311-cp311-manylinux_2_28_x86_64.whl
Size 18.2 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
343f069451ab9579ae9f371132088a8dc1537ab0e0c4f7d45f01ac81f47abbcd
BLAKE2b-256 checksum
How to use checksums
0ecd981e32623ca850f007075cd9e50eb08ad5713e7da2b869050246e840b6b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp311-cp311-macosx_10_15_x86_64.whl

Download URL mqt.qecc-1.3.1-cp311-cp311-macosx_10_15_x86_64.whl
Size 4.5 MB
Tags CPython 3.11 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
4d3829f4f9a17ff9f3f298f8268483ca09b768f08cf3bcc9740f0e4186246ac6
BLAKE2b-256 checksum
How to use checksums
147df5f154a94533d101b9f8a2890d4dc5adceb32408ac4241b4abac465c74de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL mqt.qecc-1.3.1-cp310-cp310-manylinux_2_28_x86_64.whl
Size 18.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2f3c63b20f70569237be7f0b59c477b4238e9a7ef779e208149034ae61475782
BLAKE2b-256 checksum
How to use checksums
a13c714a031462f7faa3a03fc5c89f64ca8b96dce13fd54c0f080551a92fd0d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp310-cp310-macosx_10_15_x86_64.whl

Download URL mqt.qecc-1.3.1-cp310-cp310-macosx_10_15_x86_64.whl
Size 4.5 MB
Tags CPython 3.10 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
70531cc50587969d2ecd3eacb1560088e96e63c58d2a12d36395f922b2dffb8f
BLAKE2b-256 checksum
How to use checksums
3a22b4086184bb6abf080b51b07f5d43749d5ed991561f32787401ac9bbfee95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL mqt.qecc-1.3.1-cp39-cp39-manylinux_2_28_x86_64.whl
Size 18.2 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
36ea5032e63b57ac078bdc7703cdd0378ce456bdfb10af68b89d75a5a6c9bcb1
BLAKE2b-256 checksum
How to use checksums
dc9663b27b4e4270d6b58d33ba1974e395731e40010f38ff061942b464c6167d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp39-cp39-macosx_10_15_x86_64.whl

Download URL mqt.qecc-1.3.1-cp39-cp39-macosx_10_15_x86_64.whl
Size 4.5 MB
Tags CPython 3.9 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
31b00ce8f9a0f3cce57f05d7062f9db90cecea47cb0e9f45c0a06d88b69fc02d
BLAKE2b-256 checksum
How to use checksums
c2c88b9450f28503ca4827890b5a16f252803c979871269448cdc219b4d8763a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp38-cp38-manylinux_2_28_x86_64.whl

Download URL mqt.qecc-1.3.1-cp38-cp38-manylinux_2_28_x86_64.whl
Size 18.2 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
924092795ebf19425e68387ffd999118f5ad3c3c754daa24c3c3707f161b727c
BLAKE2b-256 checksum
How to use checksums
621cce4b21c694db1e258fcf5c1f520199e3577c958da9ef01057074e9057d35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / mqt.qecc-1.3.1-cp38-cp38-macosx_10_15_x86_64.whl

Download URL mqt.qecc-1.3.1-cp38-cp38-macosx_10_15_x86_64.whl
Size 4.5 MB
Tags CPython 3.8 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
da9d9a6f46c866bb8fce21c4b185ac7758e17798636ca6fced37c87bc985ffb5
BLAKE2b-256 checksum
How to use checksums
4d8a6e023c84504992cc319796b360db5537e13cb05d873d421379537edf82f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for mqt.qecc 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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