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.
- 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.
If you have any questions, feel free to contact us via quantum.cda@xcit.tum.de or by creating an issue on GitHub.
QECC is available via PyPI for Linux, macOS, as well as Windows and supports Python 3.9 to 3.13.
(venv) $ pip install mqt.qecc
The following code gives an example on the usage:
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))
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)
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.
The implementation is compatible with any C++17 compiler, a minimum CMake version of 3.19, and Python 3.9+. 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.
If you use our tool for your research, we will be thankful if you refer to it by citing the appropriate publication:
-
L. Berent, T. Hillmann, J. Eisert, R. Wille, and J. Roffe, "Analog information decoding of bosonic quantum LDPC codes".
-
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:
-
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
-
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
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.