Recent advances in the development of quantum technology have made it possible to run small quantum programs on real quantum computers. This has created a need for compiling methods specific to these quantum computers. Unlike classical computers, if a quantum computation takes too long, the qubits might decohere and lose their information, making the computation useless. Hence, well-optimized quantum programs are a necessity. Like classical computers, quantum computers have registers for qubits that are generally sparsely connected. However, classical compilation methods that rely on copying data from one register to another do not apply to quantum computers because qubits cannot be copied. This problem is called the qubit routing problem. Following classical compilation, one could solve the connectivity constraints by moving the qubits to adjacent qubit registers. However, this requires the addition of SWAP gates throughout the quantum circuit, resulting in a strictly longer program. Additionally, a SWAP gate on qubits is not cheap and requires three CNOT gates each. Instead, in this thesis, we have defined a new method for quantum compilation that is based in the quantum nature of the program to be compiled. Instead of routing the qubits directly, we generate new machine code (in the form of quantum circuits) from an intermediate representation. We call this process quantum circuit synthesis. During synthesis, we make sure that all generated gates are supported by the target quantum hardware. Additionally, if the synthesis process is optimal, the resulting quantum circuit will also be optimal, although the methods proposed in this thesis are all heuristic in nature due to the computational complexity of optimal architecture-aware synthesis. We construct the nested intermediate representation starting from sequences of CNOT circuits interleaved with single qubit gates and incrementally generalize the intermediate representation to a universal representation. In particular, we propose two algorithms for synthesizing CNOT circuits from their parity matrix representation and one algorithm for synthesizing phase polynomials (i.e. CNOT+$R_z$ circuits). Additionally, we show that when combining these methods into the universal representation called Mixed ZX-phase polynomial, it is competitive with existing commercial quantum compilers IBM's Qiskit and Quantinuum's TKET for large circuits. This thesis additionally contains a proposal for a framework to benchmark the quality of circuits used in an algorithm called Variational Quantum Eigensolver (VQE). This framework attempts to measure how close the solution found by the VQE is to our best estimate of a real molecule (i.e. accuracy), rather than a classical simulation of the approximate molecule as given to the quantum computer (i.e. precision).
Recent advances in the development of quantum technology have made it possible to run small quantum programs on real quantum computers. This has created a need for compiling methods specific to these quantum computers. Unlike classical computers, if a quantum computation takes too long, the qubits might decohere and lose their information, making the computation useless. Hence, well-optimized quantum programs are a necessity. Like classical computers, quantum computers have registers for qubits that are generally sparsely connected. However, classical compilation methods that rely on copying data from one register to another do not apply to quantum computers because qubits cannot be copied. This problem is called the qubit routing problem. Following classical compilation, one could solve the connectivity constraints by moving the qubits to adjacent qubit registers. However, this requires the addition of SWAP gates throughout the quantum circuit, resulting in a strictly longer program. Additionally, a SWAP gate on qubits is not cheap and requires three CNOT gates each. Instead, in this thesis, we have defined a new method for quantum compilation that is based in the quantum nature of the program to be compiled. Instead of routing the qubits directly, we generate new machine code (in the form of quantum circuits) from an intermediate representation. We call this process quantum circuit synthesis. During synthesis, we make sure that all generated gates are supported by the target quantum hardware. Additionally, if the synthesis process is optimal, the resulting quantum circuit will also be optimal, although the methods proposed in this thesis are all heuristic in nature due to the computational complexity of optimal architecture-aware synthesis. We construct the nested intermediate representation starting from sequences of CNOT circuits interleaved with single qubit gates and incrementally generalize the intermediate representation to a universal representation. In particular, we propose two algorithms for synthesizing CNOT circuits from their parity matrix representation and one algorithm for synthesizing phase polynomials (i.e. CNOT+Rz circuits). Additionally, we show that when combining these methods into the universal representation called Mixed ZX-phase polynomial, it is competitive with existing commercial quantum compilers IBM's Qiskit and Quantinuum's TKET for large circuits. This thesis additionally contains a proposal for a framework to benchmark the quality of circuits used in an algorithm called Variational Quantum Eigensolver (VQE). This framework attempts to measure how close the solution found by the VQE is to our best estimate of a real molecule (i.e. accuracy), rather than a classical simulation of the approximate molecule as given to the quantum computer (i.e. precision).
In the NISQ era, where quantum computing is dominated by hybrid quantum algorithms, it is important for quantum circuits to be well-optimized to reduce noise from unnecessary gates. We investigate different phase polynomial-based compilation strategies to determine the current best practices and compare them against the DAG-based Qiskit and TKET compilers. We find that phase polynomial-based compiling is very fast compared to DAG-based compiling. For long circuits, these compilers generate fewer CNOT gates than Qiskit or TKET, but for short circuits, they are quite inefficient. We also show that supplementary algorithms such as Reverse Traversal and simulated annealing mightimprove the generated CNOT count slightly, but the effect is negligible in most settings and generally not worth the additional compiler runtime. Instead, more sophisticated phase polynomial synthesis algorithms are needed.
The current phase of quantum computing is in the Noisy Intermediate-Scale Quantum (NISQ) era. On NISQ devices, two-qubit gates such as CNOTs are much noisier than single-qubit gates, so it is essential to minimize their count. Quantum circuit synthesis is a process of decomposing an arbitrary unitary into a sequence of quantum gates, and can be used as an optimization tool to produce shorter circuits to improve overall circuit fidelity. However, the time-to-solution of synthesis grows exponentially with the number of qubits. As a result, synthesis is intractable for circuits on a large qubit scale.
In this paper, we propose a hierarchical, block-by-block optimization framework, QGo, for quantum circuit optimization. Our approach allows an exponential cost optimization to scale to large circuits. QGo uses a combination of partitioning and synthesis: 1) partition the circuit into a sequence of independent circuit blocks; 2) re-generate and optimize each block using quantum synthesis; and 3) re-compose the final circuit by stitching all the blocks together. We perform our analysis and show the fidelity improvements in three different regimes: small-size circuits on real devices, medium-size circuits on noise simulations, and large-size circuits on analytical models. Using a set of NISQ benchmarks, we show that QGo can reduce the number of CNOT gates by 29.9% on average and up to 50% when compared with industrial compilers such as t|ket>. When executed on the IBM Athens system, shorter depth leads to higher circuit fidelity. We also demonstrate the scalability of our QGo technique to optimize circuits of 60+ qubits. Our technique is the first demonstration of successfully employing and scaling synthesis in the compilation toolchain for large circuits. Overall, our approach is robust for direct incorporation in production compiler toolchains.
Practical realizations of quantum computers are poised to deliver outstanding computational capabilities far beyond the reach of any classical supercomputer. While classical systems are reliably implemented using CMOS technology, the fabrication of quantum hardware has not yet reached a commercially viable level of maturity. Nowadays, many different technologies are being developed as competing candidates to build the first error-corrected quantum computer. Among the software resources required to operate such a system, quantum compilers translate a high-level description of a quantum algorithm into low-level, technology-dependent quantum instructions. Many quantum algorithms, including Shor's and Grover's algorithms, require to compute some classical logic functions on the quantum computer. The first part of this thesis deals with the problem of compiling quantum circuits that perform such classical Boolean functions, called oracles, into a fault-tolerant set of instructions. Oracle circuits often demand many resources in terms of the number of qubits and gates. The focus is on compiling quantum circuits starting from multi-level logic networks representing large Boolean functions while minimizing the resource footprint of the obtained quantum circuits. At the same time, the trade-off between memory resources and the number of operations typical of such a compilation process is explored. As part of the effort in reducing the resources required to perform a given quantum program, I also present some quantum circuit optimization techniques. The researched algorithms leverage data structures and techniques borrowed and adapted from classical logic synthesis, e.g., SAT solvers, LUT mapping, and multi-level logic networks. I implemented all the compilation algorithms presented in this thesis as part of open-source projects. In particular, I develop and maintain caterpillar---a C++ header-only library dedicated to the quantum compilation of oracles and quantum memory management. The second part of this thesis describes how to equip quantum programming language compilers with automatic accuracy management. Despite the availability of many of such languages, resource estimation of quantum algorithms does not yet support taking approximation errors into account. This general methodology is applicable to any programming language and I demonstrate its integration into the Q# compiler. The technique consists of providing language support to ease the accuracy-aware programming task. The user can define accuracy parameters that will be automatically optimized according to a constraint and a cost function directly generated from the source code. In the presented practical evaluations, the constraint function is the overall allowed accuracy, while the cost function is application-dependent and related to the number of gates. During the optimization process, such functions are evaluated hundreds of times. For this reason, we extract them as (near-)symbolic expressions, whose evaluation time does not depend on the quantum algorithm size. The algorithms and the methodologies presented in this thesis are part of a widespread effort of the research community to build a complete and efficient software stack to program and control the first practical universal quantum computer.
Rapid progress in quantum technology in this decade has dramatically increased the coherence time of qubits (quantum bits) and the fidelity of operations on qubits.Although currently available quantum computers are noisy and intermediate in scale, it is believed that they will be used in some specific applications such as quantum chemistry, machine learning, optimization, and sampling in the near future.Along with progress in quantum computing hardware, development of the software stack has also become more active.A quantum compiler, which translates a quantum program into a sequence of control instructions, is one of the most essential software components to provide a human-friendly programming interface for quantum algorithms.In quantum compilers, optimizing the output instructions is very important: For noisy quantum computers, it increases the probability of completing all the operations before any qubit decoheres, yielding computational results with higher fidelity.Even for fault-tolerant quantum computers, optimization increases the throughput.In this thesis, we address two important optimization tasks in quantum compilers: quantum circuit mapping and quantum circuit scheduling.We provide their formulations as classical optimization problems considering commutation between quantum gates, which are not fully considered in previous studies.We also provide exact and heuristic algorithms for solving them.We examine how considering gate commutation in our algorithms improves the quality of solutions by computational experiments in practical settings.The thesis is organized as follows.After reviewing studies on quantum compilers, we consider the problem of mapping quantum circuits to quantum computers, whose operations are limited by their coupling architecture, with as few additional gates as possible.We propose exact and heuristic algorithms for quantum circuit mapping, which use gate commutation rules and a gate transformation rule of Bridge gate.We compare these algorithms with the state-of-the-art algorithms by computational experiments with circuits of a commonly used benchmark dataset.Next, we consider the problem of scheduling operations in a given circuit with the shortest total execution time.We demonstrate that quantum circuit scheduling can be seen as an optimization problem only when we consider gate commutation and can be interpreted as a special type of job-shop problem.We provide Constraint Programming and Mixed Integer Programming formulations and show how solving circuit scheduling independently improved the schedule length through experiments with real circuits and a compiler.We believe that our algorithms are useful in practical quantum compilers and the developed techniques provide new insight into optimization in quantum compilers.We hope that they will be helpful to advance software stack development and improve the utility of quantum computers.
Simulating quantum systems is one of the most important potential applications of quantum computers. The high-level circuit defining the simulation needs to be compiled into one that complies with hardware limitations such as qubit architecture (connectivity) and instruction (gate) set. General-purpose quantum compilers work at the gate level and have little knowledge of the mathematical properties of quantum applications, missing further optimization opportunities. Existing application-specific compilers only apply advanced optimizations in the scheduling procedure and are restricted to the CNOT or CZ gate set. In this work, we develop a compiler, named 2QAN, to optimize quantum circuits for 2-local qubit Hamiltonian simulation problems, a framework which includes the important quantum approximate optimization algorithm (QAOA). In particular, we exploit the flexibility of permuting different operators in the Hamiltonian (no matter whether they commute) and propose permutation-aware techniques for qubit routing, gate optimization and scheduling to minimize compilation overhead. 2QAN can target different architectures and different instruction sets. Compilation results on four applications (up to 50 qubits) and three quantum computers (namely, Google Sycamore, IBMQ Montreal and Rigetti Aspen) show that 2QAN outperforms state-of-the-art general-purpose compilers and application-specific compilers. Specifically, 2QAN can reduce the number of inserted SWAP gates by 11.5X, reduce overhead in hardware gate count by 68.5X, and reduce overhead in circuit depth by 21X. Experimental results on the Montreal device demonstrate that benchmarks compiled by 2QAN achieve the highest fidelity.
The current phase of quantum computing is in the Noisy Intermediate-Scale Quantum (NISQ) era. On NISQ devices, two-qubit gates such as CNOTs are much noisier than single-qubit gates, so it is essential to minimize their count. Quantum circuit synthesis is a process of decomposing an arbitrary unitary into a sequence of quantum gates, and can be used as an optimization tool to produce shorter circuits to improve overall circuit fidelity. However, the time-to-solution of synthesis grows exponentially with the number of qubits. As a result, synthesis is intractable for circuits on a large qubit scale. In this paper, we propose a hierarchical, block-by-block optimization framework, QGo, for quantum circuit optimization. Our approach allows an exponential cost optimization to scale to large circuits. QGo uses a combination of partitioning and synthesis: 1) partition the circuit into a sequence of independent circuit blocks; 2) re-generate and optimize each block using quantum synthesis; and 3) re-compose the final circuit by stitching all the blocks together. We perform our analysis and show the fidelity improvements in three different regimes: small-size circuits on real devices, medium-size circuits on noise simulations, and large-size circuits on analytical models. Using a set of NISQ benchmarks, we show that QGo can reduce the number of CNOT gates by 29.9% on average and up to 50% when compared with industrial compilers such as t|ket>. When executed on the IBM Athens system, shorter depth leads to higher circuit fidelity. We also demonstrate the scalability of our QGo technique to optimize circuits of 60+ qubits. Our technique is the first demonstration of successfully employing and scaling synthesis in the compilation toolchain for large circuits. Overall, our approach is robust for direct incorporation in production compiler toolchains.