Abstract
Implementing a quantum circuit on specific hardware with a reduced available gate set is often associated with a substantial increase in the length of the equivalent circuit. This process is also known as transpilation and due to decoherence, it is mandatory to keep quantum circuits as short as possible, without affecting functionality. In this work we propose three different transpilation approaches, based on a localized term-replacement scheme, to substantially reduce circuit lengths while preserving the unitary operation implemented by the circuit. The first variant is based on a stochastic search scheme, and the other variants are driven by a database retrieval scheme and a machine learning based decision support. We show that our proposed methods generate short quantum circuits for restricted gate sets, superior to the typical results obtained by using different qiskit optimization levels. Our method can be applied to different gate sets and scales well with an arbitrary number of qubits.
Introduction: The Challenge of Quantum Transpilation
To execute a theoretical quantum algorithm on physical hardware, it must undergo transpilation—the translation of abstract gates into a hardware-specific, restricted gate set. In the current Noisy Intermediate-Scale Quantum (NISQ) era, qubits are highly susceptible to decoherence; every additional gate introduces latency and error. Naive transpilation often results in "bloated" circuits that suffer heavily from noise.
Finding the absolute shortest equivalent circuit—a process akin to classical logic minimization—is mandatory to obtain reliable results before the quantum state collapses. While heuristic optimizers, such as those built into Qiskit, are fast, they often leave significant redundancies in the compiled circuit. This paper introduces a localized term-replacement framework to bridge this gap.
Methodology: Localized Term-Replacement
The authors treat quantum circuits as "token chains" (where each token represents a gate) and propose a scheme to iteratively shorten these chains without altering the underlying mathematical operation (the unitary matrix). Three distinct variants were developed:
- V1-RS (Random Search): This baseline approach selects a random sub-block of the circuit and attempts to find a shorter replacement by randomly generating alternative token chains and verifying their unitary equivalence.
- V2-DR (Database Retrieval): To improve efficiency, the authors pre-computed "compute graphs"—extensive maps of optimal paths for small unitary operations—stored in a database. The algorithm performs a lookup to find the shortest known sequence for a given sub-block.
- V3-RF (Random Forest): To avoid fruitless database queries on irreducible blocks, a Random Forest classifier is employed. It predicts whether a block is likely to be reducible; the database is queried only upon a positive prediction.
To ensure scalability, the algorithm isolates sub-blocks and temporarily removes qubits not involved in the local operation. This dimensionality reduction keeps the matrix mathematics tractable even for systems with many qubits.
Key Results and Performance
The variants were benchmarked using synthetic circuits and real-world hardware tests on IBM Eagle r3 processors (IBM:Brisbane and IBM:Kyiv).
Algorithmic Efficiency
V3-RF emerged as the fastest and most stable variant. On average, it reduced a 100-gate circuit in 38 seconds, significantly outperforming V2-DR (55 seconds) and V1-RS (199 seconds). The use of a Random Forest as a "gatekeeper" is particularly effective because inference is extremely fast (<0.0001 seconds), preventing time-consuming database lookups on blocks that cannot be simplified.
Compression and Hardware Fidelity
The proposed methods demonstrated superior compression compared to standard tools. In a 3-qubit ion-trap benchmark, an original circuit of 86 RX gates was reduced to 21 gates by Qiskit (Level 3), while the authors' method achieved a reduction to just 5 gates.
On real IBM hardware, a 40-gate circuit that typically expanded to ~150 gates under standard transpilation was compressed to just 8 gates. This drastic reduction allowed the execution results to closely match ideal, noise-free simulations, proving the real-world value of aggressive circuit minimization in the NISQ era.
Conclusion and Future Work
While the proposed V3-RF method is computationally more intensive than standard transpilers (which often finish in under a second), its ability to drastically reduce gate counts makes it ideal for final production runs or frequently reused circuit components. Future research will focus on integrating hardware-specific noise profiles into the cost function—penalizing gates with higher error rates or longer execution times—and exploring reinforcement learning and ZX-calculus for further optimization.
Summary updated