Dynamic quantum circuit compilation

Kun Fang, Munan Zhang, Ruqi Shi, Yinan Li · DOI

Abstract: Quantum computing has shown tremendous promise in addressing complex computational problems, yet its practical realization is hindered by the limited availability of qubits for computation. Recent advancements in quantum hardware have introduced mid-circuit measurements and resets, enabling the reuse of measured qubits and significantly reducing the qubit requirements for executing quantum algorithms. In this work, we present a systematic study of dynamic quantum circuit compilation, a process that transforms static quantum circuits into their dynamic equivalents with a reduced qubit count through qubit-reuse. We establish the first general framework for optimizing the dynamic circuit compilation via graph manipulation. In particular, we completely characterize the optimal quantum circuit compilation using binary integer programming, provide efficient algorithms for determining whether a given quantum circuit can be reduced to a smaller circuit and present heuristic algorithms for devising dynamic compilation schemes in general. Furthermore, we conduct a thorough analysis of quantum circuits with practical relevance, offering optimal compilations for well-known quantum algorithms in quantum computation, ansatz circuits utilized in quantum machine learning, and measurement-based quantum computation crucial for quantum networking. We also perform a comparative analysis against state-of-the-art approaches, demonstrating the superior performance of our methods in both structured and random quantum circuits. Our framework lays a rigorous foundation for comprehending dynamic quantum circuit compilation via qubit-reuse, bridging the gap between theoretical quantum algorithms and their physical implementation on quantum computers with limited resources.

Introduction: The Challenge of Qubit Scarcity

In the current Noisy Intermediate-Scale Quantum (NISQ) era, qubits are a precious and scarce resource. Most quantum algorithms are traditionally designed as static circuits, where all qubits are initialized at the start and measured only at the very end. This approach is often inefficient; many qubits sit idle for long periods or complete their operations early while the rest of the circuit continues to execute.

Comparison between a static 3-qubit circuit and its dynamic 2-qubit equivalent using qubit reuse.

To address this, researchers are turning to qubit-reuse: the process of measuring a qubit mid-circuit, resetting it to a known state (like $|0\rangle$), and reusing it for a different part of the algorithm. This transformation converts static circuits into dynamic circuits, allowing larger programs to run on smaller hardware. However, determining the optimal schedule for qubit reuse—deciding which qubits can be recycled and when—is a complex optimization problem, especially when considering gate commutativity.

A Graph-Based Framework for Compilation

This research introduces a systematic framework for dynamic quantum circuit compilation based on graph manipulation. The core of the approach involves representing the dependencies within a quantum circuit as a Directed Acyclic Graph (DAG).

The transformation of a quantum circuit into a DAG and a simplified bipartite DAG to analyze qubit reachability.

Methodology Overview

  1. Graph Representation: The compiler maps the circuit to a DAG. To streamline the optimization, it utilizes a "simplified DAG"—a bipartite graph that tracks reachability between the circuit's input roots and output terminals.
  2. Reducibility Testing: The authors developed an efficient $O(mn)$ algorithm (where $m$ is gates and $n$ is qubits) to determine if a circuit can be reduced. A key insight is the Reachability Rule: a circuit is irreducible if and only if every qubit eventually interacts with every other qubit, forming a complete bipartite reachability graph.
  3. Optimal Compilation via BIP: The problem of finding the absolute minimum number of qubits is formulated as a Binary Integer Programming (BIP) problem. This provides a theoretical benchmark for any circuit.
  4. Scalable Heuristics: For large-scale circuits where BIP is computationally prohibitive, the framework offers three heuristic algorithms: Minimum Remaining Values (MRV), which prioritizes the most constrained qubits; a Greedy approach for local optimization; and a Hybrid method combining brute-force search with heuristics.
  5. Flexible Dependencies: Unlike previous tools that treated gate sequences as fixed, this compiler recognizes commutable gates. By allowing these gates to be reordered, the framework identifies significantly more opportunities for qubit reuse.

Key Results and Performance

The framework was evaluated against a wide range of benchmarks, including classic algorithms (Shor’s, Grover’s, QFT), Quantum Machine Learning (QML) ansatzes, and random hardware benchmarks.

Superiority over State-of-the-Art

The proposed greedy algorithm outperformed the previous leading method, DCKF, in 98.5% of random circuits and nearly 100% of Instantaneous Quantum Polynomial (IQP) circuits. This success is largely attributed to the framework's ability to exploit gate commutativity.

Massive Resource Reductions

The reductions achieved are often dramatic:

  • Simon’s Algorithm: Reduced from $2n$ qubits to just 3 qubits, regardless of the input size $n$.
  • Bernstein-Vazirani: Reduced from $n$ qubits to just 2 qubits.
  • QML Ansatzes: Circularly entangled circuits, common in machine learning, were reduced to a constant 3 qubits.

Fidelity Improvements

Beyond saving qubits, the research demonstrates a "fidelity bonus." In noisy simulations of trapped-ion hardware, using fewer qubits allowed the compiler to avoid the noisiest physical qubits on the chip. This strategic reuse improved the success probability of the algorithms by approximately 8%.

Conclusion and Future Directions

This work establishes a rigorous mathematical foundation for dynamic quantum circuit compilation. By bridging the gap between theoretical algorithms and resource-constrained hardware, it provides a practical path toward executing more complex computations on today's quantum devices.

Future work will focus on adapting the framework for specific hardware topologies (like grid-based superconducting chips) and extending the optimization to circuits that already contain dynamic conditional logic. As hardware support for mid-circuit measurement becomes standard, these compilation techniques will be essential for the efficient operation of quantum computers.

Summary updated

BibTeX
@misc{fang2023dynamic,
  author = {Kun Fang and Munan Zhang and Ruqi Shi and Yinan Li},
  title = {{Dynamic quantum circuit compilation}},
  year = {2023},
  eprint = {2310.11021},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.11021},
}
Figure