Exact and practical pattern matching for quantum circuit optimization
arXiv:1909.05270 · doi:10.1145/3498325
Abstract
Quantum computations are typically compiled into a circuit of basic quantum gates. Just like for classical circuits, a quantum compiler should optimize the quantum circuit, e.g. by minimizing the number of required gates. Optimizing quantum circuits is not only relevant for improving the runtime of quantum algorithms in the long term, but is also particularly important for near-term quantum devices that can only implement a small number of quantum gates before noise renders the computation useless. An important building block for many quantum circuit optimization techniques is pattern matching, where given a large and a small quantum circuit, we are interested in finding all maximal matches of the small circuit, called pattern, in the large circuit, considering pairwise commutation of quantum gates. In this work, we present a classical algorithm for pattern matching that provably finds all maximal matches in time polynomial in the circuit size (for a fixed pattern size). Our algorithm works for both quantum and reversible classical circuits. We demonstrate numerically that our algorithm, implemented in the open-source library Qiskit, scales considerably better than suggested by the theoretical worst-case complexity and is practical to use for circuit sizes typical for near-term quantum devices. Using our pattern matching algorithm as the basis for known circuit optimization techniques such as template matching and peephole optimization, we demonstrate a significant (~30%) reduction in gate count for random quantum circuits, and are able to further improve practically relevant quantum circuits that were already optimized with state-of-the-art techniques.
Raban Iten and Romain Moyard contributed equally to this work. Major updates: Added numerical analysis of the pattern matching algorithm; fixed two special cases that were missed by our algorithm and updated the worst-case complexity analysis. 10 pages summary + 23 pages main text + 7 pages appendix
References in corpus (9)
- Quantum Computing in the NISQ era and beyond
- Quantum algorithm for solving linear systems of equations
- Quantum Circuit Simplification and Level Compaction
- Automated optimization of large quantum circuits with continuous parameters
- Quantum Circuits for Isometries
- Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus
- Techniques for the Synthesis of Reversible Toffoli Networks
- Optimization of Clifford Circuits
- Introduction to UniversalQCompiler
Cited by in corpus (13)
- Scaling of the quantum approximate optimization algorithm on superconducting qubit based hardware
- Pulse-efficient circuit transpilation for quantum applications on cross-resonance-based hardware
- Simulating Open Quantum System Dynamics on NISQ Computers with Generalized Quantum Master Equations
- A Comprehensive Review of Quantum Circuit Optimization: Current Trends and Future Directions
- Clifford Circuit Optimization with Templates and Symbolic Pauli Gates
- Quantivine: A Visualization Approach for Large-scale Quantum Circuit Representation and Analysis
- Compilation for Dynamically Field-Programmable Qubit Arrays with Efficient and Provably Near-Optimal Scheduling
- Unitary Synthesis of Clifford+T Circuits with Reinforcement Learning
- Non-stabilizerness and entanglement from cat-state injection
- Controlled Gate Networks: Theory and Application to Eigenvalue Estimation
- Quantum Theory from Principles, Quantum Software from Diagrams
- Reducing depth and measurement weights in Pauli-based computation
- POPQC: Parallel Optimization for Quantum Circuits (Extended Version)