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 [78].

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, 32].

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

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/b368c939ee1e2e33911debf58115e3560200061a2c0dea867cc6d3ba1036d2fe.svg

Fig. 2 Coupling map of a generic five-qubit 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 GenericBackendV2
3
4backend = GenericBackendV2(
5    num_qubits=5,
6    coupling_map=[[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [0, 4], [4, 0]]
7)
8
9circ_mapped, results = compile(circ, backend)
../_images/cbc40e43253bb9e348657815a6dea72dc6e071e755bcf778571ac05d0a11e9a3.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