Skip to main content

QECC - An MQT Tool for Quantum Error Correcting Codes

Project description

License: MIT CI Python CI Bindings codecov

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

:warning: 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

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.3.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

mqt.qecc-1.3.0-cp311-cp311-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.3.0-cp311-cp311-macosx_10_15_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

mqt.qecc-1.3.0-cp310-cp310-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.3.0-cp310-cp310-macosx_10_15_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

mqt.qecc-1.3.0-cp39-cp39-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.3.0-cp39-cp39-macosx_10_15_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

mqt.qecc-1.3.0-cp38-cp38-manylinux_2_28_x86_64.whl (18.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

mqt.qecc-1.3.0-cp38-cp38-macosx_10_15_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: mqt.qecc-1.3.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for mqt.qecc-1.3.0.tar.gz
Algorithm Hash digest
SHA256 03287b3c9c2444f47abddb76412e639516618b97650f600c125045ae696d34d8
MD5 45535be64608425dca81f47912d784ad
BLAKE2b-256 3dfe97d4b4fd00b447316f7f0e9396dc18003ab3de4243ec3140206d8fac8a0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4089f7b0df65edb059f934c5edd8a3d475b974d1fa5476b315d71a84dea1a495
MD5 83fb33a2770313f2cc35a7fb252c267c
BLAKE2b-256 c0fec5d8102b17b451a452460fa18851c33271a256250c4d46c5cd8aeb53a2ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 64ca620db12a7115aceb90698a56993d1b75991c35bc937490bbde097cb5093d
MD5 7994ec121c6230130259388c293750f4
BLAKE2b-256 402e4736744d1637c70f8c62e922bb3fba61568fe41e5c7c446826d77da82407

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12055a9714d0341b8689e60f5ff58614ec9b6c5c7e539dd2abe262adc1dcad93
MD5 fc32b4d63cbf34a56587fdea8c5a18bf
BLAKE2b-256 f96244f2be9d310bce9ebe7d669882e3b762250257c10d82296d84d684026faf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c28f191bf21278cd7fb49384efce795d5e831f52ecf86251e020e3bf75d7bdc5
MD5 43f61be2c136b9994298d4bc3e68d660
BLAKE2b-256 bb10d3214319e9398e4a857bb200631a3c9f88535169f1455f75988cc3f072cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93912bd188ef29d438eb53ea9ff95a4a7f520c02521983ed2faa6a927053ad95
MD5 58d4bf435c441ec5167e9a01460857f5
BLAKE2b-256 ba25a70022554ce628f7d567d816eebfe3ccbcbc46686f1869dee90f49bfebd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 908cec7b51bc7527501f70aa1517d223cb486c4e7a322b5b491b56e72d3af8b1
MD5 f0586dba13499f891f73aaf1487f4e4a
BLAKE2b-256 fcaf2b7dde70438060650af6c7fd6828d6cdf0146ecfe524aded449e6e16c8bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 46a35e892046bcce6380011aa3f75a74cb0f9a8ec3ed36e9c306b8b41f494eaa
MD5 ad7ca3bb6f8b55c4e2358cc6c034d813
BLAKE2b-256 1bbbee914c448796a075c332ba01ca650336258ad0d994b61f617e17c1cbfd47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mqt.qecc-1.3.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0a274d6d3b850b4e4c49b32842f2a7c3c55b68476176267e0fb901d5ffb1e5a9
MD5 f82b88f5d05df6690946f7fcf8c65ffe
BLAKE2b-256 0168ec7d7bf5718dd3b4e2d719bc2f1078208705db6fbe87d68eaa0b28aa5cbd

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