Skip to main content

QECC - An MQT Tool for Quantum Error Correcting Codes

Project description

PyPI OS License: MIT CI CD Documentation 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.
  • WIP: Decode bosonic quantum LDPC codes and conduct numerical simulations for analog information decoding under phenomenological (cat qubit) noise.

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)

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, T. Hillmann, J. Eisert, R. Wille, and J. Roffe, "Analog information decoding of bosonic quantum LDPC codes".

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

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

  • 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

Credits

The contributors to this tool are:

  • Lucas Berent
  • Lukas Burgholzer
  • Thomas Grurl
  • Peter-Jan H.S. Derks
  • Timo Hillmann

Acknowledgements

The Munich Quantum Toolkit has been supported by the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation program (grant agreement No. 101001318), the Bavarian State Ministry for Science and Arts through the Distinguished Professorship Program, as well as the Munich Quantum Valley, which is supported by the Bavarian state government with funds from the Hightech Agenda Bayern Plus.

TUM Logo Coat of Arms of Bavaria ERC Logo MQV Logo

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.7.0.tar.gz (526.0 kB view details)

Uploaded Source

Built Distributions

mqt_qecc-1.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ x86-64

mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

mqt_qecc-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11 macOS 11.0+ x86-64

mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_arm64.whl (989.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

mqt_qecc-1.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_arm64.whl (988.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

mqt_qecc-1.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9 macOS 11.0+ x86-64

mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_arm64.whl (988.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

mqt_qecc-1.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8 macOS 11.0+ x86-64

mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_arm64.whl (988.4 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

File details

Details for the file mqt_qecc-1.7.0.tar.gz.

File metadata

  • Download URL: mqt_qecc-1.7.0.tar.gz
  • Upload date:
  • Size: 526.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for mqt_qecc-1.7.0.tar.gz
Algorithm Hash digest
SHA256 555d333cb46996d5a49ceab49dce89f5fed452b16b1af3a4ae43b7f218339660
MD5 6643c7926bb32d51561f741dfce79319
BLAKE2b-256 bb60beefeb00712dd519a1725a357f2e2ae32b4217fce8f202539a68616a6b20

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 449c8a50b4a9895e2b29b731fd490aece891c2c1f310658d7e23a72a58b7e803
MD5 73157daf5c1836d3e32243438c34d257
BLAKE2b-256 2fcf49028f7b6956bb06cf1ecc0b8fb0fb811714913de8494f72c3c02176c903

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 1d1c0670ceb4e416aa0daa66e349ac0bab3c2ed5cece1d994dff44866f9ba100
MD5 215a2b416455c6d9784a636c299a7e57
BLAKE2b-256 2f5c0aca626dce73f0c65a48c82e8ab5d781fc9e6958f8bac5084ca51dcc028c

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 858c28921927df6d4d4ad7ff0cfea59bcbb07348c5b1a10ea44d85959d47c0cf
MD5 8b95c0657f67a6ed9ff2da653bdee854
BLAKE2b-256 e38ef7cc439500ac209bd391107bfbddb02c6438dbf2987ca20d46cbd4949851

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c0ee8cdda3f9ab52e1fa4f7d9afc7c159b3070ac16a788f5458015dacb34740
MD5 4f56a6d99cec48b126eb6864cee22488
BLAKE2b-256 5e6d89e641865496fd69f0f3962efc282c932e4aa1b4abfb9bd15b0f783942c5

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 6b7d350c2d90637df1d991ba16723c10d9d241f1fa970c317444b079fcc95c94
MD5 550de0be183e85117626c16dc9c21497
BLAKE2b-256 dc6485fa22b79ca9aeb1fef4f17c1c1430d1223f39040e69269073b6cdf20e35

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3bc001db5d555e8198fb333a2430acdf6a2d871f34ed84bf34f40bf889a93d84
MD5 604d1f0b83a6a716f9d91b3d62567af0
BLAKE2b-256 71dc5a206e26e8488ca1bdfccde95bb46a60f309a1d1857bcd852de7be35d8af

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c3212cb08391f2ebc24c5393f2c90c2835da11c25f88a611b29bf828e5e4afb
MD5 edf6c73a0663af26fd704dcbdaf23a5a
BLAKE2b-256 cd6dc2da7f7f28a963e1c64bccddda684999bf53952c2beaabdf198b3e19063d

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c56e7ec53cb48cca474b2ef62e169c258be74c460d7e13cae63697456fc57506
MD5 e96593e75b2107b46f588603f7156a2d
BLAKE2b-256 85dd74a2510a1b2ea625ffec197353834c98f9dbda2e001b29fe8d4991fd23f1

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a385f87cbb4de892fdebda236eabd0935ad28a45e9bcfb15f8c698d4949132b
MD5 abff1d2861eba03390c4f903ba829735
BLAKE2b-256 77b8123b41a59f22125006f065d2448d632b2d195cfff502b2bc4a36e71c2e98

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a66efa7f48ad5118105d878333c6dad6f9921f956670a1e3ba99c5d6013e006
MD5 d79fa2b1cb58880546ad6ef35c2cfe19
BLAKE2b-256 e062f859defcbe4094db16cbbad9fa598915c5c4e9d6bbd6394783aa4393f007

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f1b826ac2daa75db252ee7d5654b9d04551bc35154b75c00473e0096cb9d842f
MD5 1191a3ecd30e016a1c20373dc92e4de1
BLAKE2b-256 2960ab8e96469ab430866116d1dc5b351bf5d769f6c0e31ccf1ad3700bf66f97

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f529c6224fec20b4169b5610c463267a6f41baace3a4936ac2ed13f9bdc7ff9
MD5 a697623c03b41ec8fe4fbf9e036b1105
BLAKE2b-256 60b8f4ad9466372fb4d5a8dd46db78771ae7d835d523593cbfc529e4ba2f8814

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 341e554ef1acb0592c75ae18dc631ec86d1a312d58e6fe3dd39ccf886a60d630
MD5 6d7c6d1d29b8c3af2c1eb07e7d515cab
BLAKE2b-256 2ad519bf4fa75936f6fcd4777de38ada6fff56952f8e9fbdbc7765cf89ff216e

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f496f287dbb2549688ce2034f2de834b41ed642ed6d9788d14bac7576f89ddfe
MD5 5e1f082f362ca9f457bd260ecf8c7ee7
BLAKE2b-256 982914edd1e6e487a47434daa49f005f5c3138449a8571ab328e2cff7d5ee25d

See more details on using hashes here.

File details

Details for the file mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_qecc-1.7.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03fb65e16ab6399fc33add702ca9396834a693c6a999c19bdcdb419461f079a0
MD5 bb855963a1104cd8e79f4790f6e5c0e0
BLAKE2b-256 7722265e726d8c67e8f119c848e553451892fc22777449e714e341fa150632cc

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