Skip to main content

QECC - An MQT Tool for Quantum Error Correcting Codes

Project description

License: MIT CI Python CI Bindings codecov

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

A tool for quantum error correcting codes and numerical simulations developed as part of the Munich Quantum Toolkit (MQT) by the Chair for Design Automation at the Technical University of Munich. It builds upon MQT Core, which forms the backbone of the 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 and macOS and supports Python 3.8 to 3.12.

(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

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

mqt.qecc-1.4.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

mqt.qecc-1.4.0-cp312-cp312-manylinux_2_28_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.4.0-cp312-cp312-macosx_10_15_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

mqt.qecc-1.4.0-cp311-cp311-manylinux_2_28_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.4.0-cp311-cp311-macosx_10_15_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

mqt.qecc-1.4.0-cp310-cp310-manylinux_2_28_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.4.0-cp310-cp310-macosx_10_15_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

mqt.qecc-1.4.0-cp39-cp39-manylinux_2_28_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.4.0-cp39-cp39-macosx_10_15_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

mqt.qecc-1.4.0-cp38-cp38-manylinux_2_28_x86_64.whl (18.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.4.0-cp38-cp38-macosx_10_15_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file mqt.qecc-1.4.0.tar.gz.

File metadata

  • Download URL: mqt.qecc-1.4.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mqt.qecc-1.4.0.tar.gz
Algorithm Hash digest
SHA256 b0a6116a90837a7beb372cc27365e2aa05cc9ae348493e0fb940d45aa4bdd588
MD5 796c3f3a78834dbe21cad9ab7796e537
BLAKE2b-256 544d191411bad2ae7cc463b00742f666b177a0997c97a9c666409bcf97e3cf35

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c1a954cc4aa1383dc36887a5e5d01db7ba1c68663a2052f8bb9729ae25ca597e
MD5 f3c89bb9174f4deee507a4fae6b21665
BLAKE2b-256 20155ff868ce16afe2e4e0539f8e6b9607741c161a66b1027111e57456d29488

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 48c041bf680080b6380a46ee76a740b45b7b973ef91361ef81164f06a2076f6e
MD5 019858e811a8b8b6756ac0d5542f539b
BLAKE2b-256 d2a336d411b74e3bea41c3b325b1de1b1d683d863a030393a3438b0258d39ca2

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85c26e40bf250fde036f2e2b872cd6e0606bbdaafd756d825b9cdf072f26afdf
MD5 860c5d74830b225a03e895071d20cf6d
BLAKE2b-256 25a3475d7cca221eebb532a110d46697971b66672e3cd910b3d0453ed2ac63f2

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c9ac01bf1a1af9fb772270bb615cbc8746eba2e3368ffb5472b4e2d9dacd8408
MD5 7d25337085ecbbf0560091509204505d
BLAKE2b-256 f6e6d37931e518c945911575e997c822f3c656b12d6fe1356732c23425d17fc1

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 940460568a01c8e57ca33f367661c1cd07547b1c0045edaaebafd59c8f5c1201
MD5 33a5bb92d8eebec26bb4dfeb3b81c34e
BLAKE2b-256 6ae14c0f9759cf35caa833372af9a0865ce48e2e3fecd9fb6d166017609c466d

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 616220d8493af165a3168bb60bab19d0f94cef002e193a5e7bb610c81300bc1a
MD5 2acbf434ef1e695612bf7081b7af9ee5
BLAKE2b-256 44376bfe320ada946028ac5e0b15d073f2b5e68fc959884b8707503acd21ed49

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 281e879d05995b25bd7394863733ccaab6c3c0ea38e8aa60a3dc5557c6440dc0
MD5 f068853b3e3ff276e2160f0e3d232df1
BLAKE2b-256 5040701526c9c6ceb241072a43acf300180e65e8e410ceecc501077e60cdd8d1

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 902d56d08166152d891a32ed413ef66824d51101dd990eee747e752c082897ae
MD5 27fc10090a75e34227f655281777cce1
BLAKE2b-256 9eabcd56d5401b0b0bbba5c05e7a97be8db9f02d837003e2ce7462bbda8d9072

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4dbed699d5695b8bce553f3d5b852f7c8bfb2de9457cd47402f3d6787b9d2e35
MD5 b524a4dabb4062187f15608d18018623
BLAKE2b-256 f4ce4ab0acf31394af1572ed7e5d6583208cd8706492ccd4437ad93a8147b1ec

See more details on using hashes here.

File details

Details for the file mqt.qecc-1.4.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for mqt.qecc-1.4.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6a3f2e140b315ce0c2d283a51fffd3eccb97b483b0d0d9168d27a8b1f6097a22
MD5 167d7543b3cd01d544540e8400382d1e
BLAKE2b-256 3152ba2d3ccb6e60ad40f4edc9e91489362766e7b537c86f5e6ae28bc1d6c4e8

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