Compilation of Quantum Circuits

In today’s digital world, creating computer programs has become a crucial element of software development. With the advent of high-level programming languages such as C++ or Python, the development process has become simpler and more efficient. These languages enable developers to produce code that is more human-readable and understandable without having to worry about the underlying hardware’s low-level features. But before these programs can be executed on a computer, they must be translated into machine code that the computer can process. This procedure is known as compilation, and it entails converting high-level code into a binary format that the computer’s processor can directly execute. By making it easier for more people to create computer programs, this has enabled the development of complex software applications that can run on many different platforms such as desktops, laptops, mobile phones or embedded devices.

Just as in classical computing, the design of quantum circuits and the development of quantum algorithms are fundamental in the development of quantum computing applications. Quantum circuits are analogous to classical functions or programs in that they are a sequence of quantum gates that perform specific operations on quantum bits or qubits instead of classical bits. Similarly to classical processors, quantum processors can only execute a certain set of native instructions, and they might further limit the qubits on which these operations might be applied. Thus, any high-level quantum circuit (describing a quantum application) must be compiled into a representation that can be executed on the targeted device. Most importantly, the resulting quantum circuit must only use gates that are native to the device on which it shall be executed. If the device only has limited connectivity between its qubits, it must only apply gates to qubits that are connected on the device. Naturally, the efficiency of this compilation process is critical because it can have a significant impact on the performance of the resulting quantum program. Inefficient compilation can lead to longer execution times, higher error rates, and reduced accuracy in the final result. Therefore, developing efficient compilation methods for quantum programs is essential to overcome the challenges of quantum computing and realize the potential of this technology.

In the following, we mainly focus on the quantum circuit mapping task. This is a crucial step in the compilation flow, as it directly affects the feasibility and performance of the quantum circuit on a given device. It involves finding a way to map the qubits of a quantum circuit to the qubits of a quantum device, while respecting the limited connectivity constraints of the device and minimizing the overhead of additional gates. In most cases, it is not possible to statically define a mapping of the circuit’s qubits to the device’s qubits such that all gates of the circuit conform to the connectivity limitations of the device. Consequently, this mapping has to change dynamically throughout the circuit. This can be accomplished by using SWAP gates that allow the position of two logical qubits on the architecture to be interchanged. However, since any additional gate increases the error rate and, hence, reduces the accuracy of the computation, it is vital to keep the number of additionally added gates as low as possible. It has been shown that even this small part in the compilation flow is an NP-complete problem [76].

The MQT offers the quantum circuit mapping tool QMAP that allows one to generate circuits which satisfy all constraints given by the targeted architecture and, at the same time, keep the overhead in terms of additionally required quantum gates as low as possible. More precisely, different approaches based on design automation techniques are provided, which are generic and can be easily configured for future architectures. Among them is a heuristic, scalable solution for arbitrary circuits based on informed-search algorithms [27, 28, 29] as well as a solution for obtaining mappings ensuring minimal overhead with respect to SWAP gate insertions [30, 31].

Additionally, the MQT offers many more methods for various compilation tasks, such as Clifford circuit synthesis [32, 33], determining optimal sub-architectures [34], compiler optimization [11, 35, 36], and compilation techniques for neutral atom technologies [40, 41], ion-trap shuttling [37, 38, 39], or multi-level quantum systems [42, 43, 44, 45]. Furthermore, it provides first automated methods regarding Fault-Tolerant Quantum Computing (FTQC) such as automatic circuit generation and evaluation for error-correcting codes [46].

Assume we want to perform the computation from Fig. 1 on a five-qubit IBM quantum computer described by the coupling map shown in Fig. 2.

../_images/bc0f465631986a00d986e28771fde0d7659cd4ad073796f23e091a8231f6f187.svg

Fig. 2 Coupling map of a generic five-qubit IBM device.

Then, mapping the circuit to that device merely requires the following lines of Python and results in the circuit shown in Fig. 3.

1from mqt.qmap import compile
2from qiskit.providers.fake_provider import Fake5QV1
3
4backend = Fake5QV1()
5circ_mapped, results = compile(circ, backend)
../_images/ebf912519da762cce1db85c4a691ce339475f6be6907fb7778108d5caceeb26c.svg

Fig. 3 Quantum circuit from Fig. 1 mapped to the five-qubit device shown in Fig. 2.

MQT QMAP
(venv) $ pip install mqt.qmap