Optimizing Quantum Circuits, Fast and Slow

Amanda Xu,Abtin Molavi,Swamit Tannu,Aws Albarghouthi
2024-11-07
Abstract:Optimizing quantum circuits is critical: the number of quantum operations needs to be minimized for a successful evaluation of a circuit on a quantum processor. In this paper we unify two disparate ideas for optimizing quantum circuits, rewrite rules, which are fast standard optimizer passes, and unitary synthesis, which is slow, requiring a search through the space of circuits. We present a clean, unifying framework for thinking of rewriting and resynthesis as abstract circuit transformations. We then present a radically simple algorithm, GUOQ, for optimizing quantum circuits that exploits the synergies of rewriting and resynthesis. Our extensive evaluation demonstrates the ability of GUOQ to strongly outperform existing optimizers on a wide range of benchmarks.
Programming Languages,Quantum Physics
What problem does this paper attempt to address?
### Problems the paper attempts to solve This paper aims to solve the key problem in quantum circuit optimization, that is, how to minimize the number of quantum operations to ensure the successful evaluation of the circuit on a quantum processor. Specifically, the paper proposes a unified framework that combines two different quantum circuit optimization methods: rewrite rules and unitary synthesis. These two methods are respectively characterized by fast but local optimization and slow but global optimization. By proposing a simple and effective algorithm (guoq), the paper shows how to utilize the synergy of these two methods, thus significantly outperforming existing optimizers in a wide range of benchmarks. ### Background and overview #### 1. Background of quantum circuits A quantum circuit consists of a series of quantum operations (or gates) applied to qubits. Common quantum gates include single - qubit gates (such as the Hadamard gate \(H\)) and two - qubit gates (such as the controlled - NOT gate \(CX\)). Another common category of quantum gates is the parameterized rotation gate, for example, \(R_z(\theta)\). #### 2. Rewrite rules Rewrite rules are a pair of semantically equivalent circuits. Although rewrite rules are in principle bidirectional, for simplicity, we usually call the left half of it the pattern and the right half the replacement. The process of applying rewrite rules is to search for parts that match the pattern and replace them with the corresponding replacement parts. For example, Figure 3 shows some commonly used rewrite rules. #### 3. Unitary synthesis The unitary synthesis of a circuit utilizes a large number of research results on unitary synthesis to resynthesize the circuit by optimizing the objective. Given the unitary matrix of a circuit, unitary synthesis constructs a new circuit whose unitary matrix differs from that of the original circuit by no more than \(\epsilon\) under a certain distance metric. This synthesis method is essentially a slow combinatorial search process. For example, the BQSKit compiler uses two - qubit sub - circuits for bottom - up search. ### Comparison between rewrite rules and unitary synthesis Rewrite rules and unitary synthesis each have their own advantages and disadvantages: - **Rewrite rules**: Fast but limited to local optimization, suitable for small - scale patterns. - **Unitary synthesis**: Slow but supports any number of gates, suitable for deep - level circuits and can perform approximation to a certain extent. ### Unified framework The paper proposes a unified framework that abstracts rewrite rules and unitary synthesis into closed - box circuit transformations, each transformation having an approximation degree \(\epsilon\). The framework allows these transformations to be applied in any order and proves the upper bound of the final approximation degree after applying a series of transformations. ### guoq algorithm guoq is a simple algorithm inspired by simulated annealing for optimizing quantum circuits. The main steps of the algorithm are as follows: 1. **Initialization**: Set the initial best solution and the current solution. 2. **Randomly select transformation**: Randomly select a transformation from the set of transformations. 3. **Randomly select sub - circuit**: Randomly select a sub - circuit from the current solution. 4. **Apply transformation**: Apply the selected transformation to the selected sub - circuit. 5. **Accept or reject**: If the transformation improves or maintains the quality of the solution, accept it; otherwise, accept it with a certain probability. 6. **Update best solution**: If the current solution is better than the best solution, update the best solution. ### Experimental results The paper conducts a wide - range evaluation of guoq, using a benchmark suite containing 247 diverse quantum circuits. The experimental results show that: 1. **Superior performance**: guoq significantly outperforms existing tools in most benchmarks. 2. **Importance of random search**: The random search method of guoq is crucial for efficiently combining rewrite rules and unitary synthesis. 3. **Flexibility**: guoq performs well in both NISQ and FTQC scenarios. ### Summary This paper effectively combines the advantages of rewrite rules and unitary synthesis by proposing a unified framework and the guoq algorithm, significantly improving the effect of quantum circuit optimization. This method...