TuniQ: Autotuning Compilation Passes for Quantum Workloads at Scale for Effectiveness and Efficiency

Mohammad Abrarul Hasanat, Jason Ludmir, Tirthak Patel, Rohan Basu Roy

TL;DR

TuniQ is a reinforcement learning-based framework that dynamically customizes the sequence of compilation passes for quantum circuits based on their unique structure, the target hardware topology, and real-time device noise profiles. By replacing the traditional "one-size-fits-all" compilation strategy, TuniQ simultaneously improves quantum execution fidelity and slashes classical compilation time, scaling efficiently up to utility-scale (65-qubit) workloads.

What Problem Does This Paper Address?

Before a quantum circuit can run on real hardware, it must undergo transpilation—a classical compilation process that translates abstract logical gates into hardware-native operations, maps logical qubits to physical ones, and inserts SWAP gates to satisfy physical connectivity constraints.

State-of-the-art quantum compilers (like IBM's Qiskit) typically use a fixed, predetermined sequence of compilation passes. However, the optimal choice of passes is highly moving target. It changes depending on the specific circuit structure, the hardware backend's coupling graph, and the daily (or hourly) drift of hardware noise. Applying too many aggressive optimization passes can actually inflate circuit depth or introduce overhead, while applying too few leaves the circuit highly vulnerable to decoherence and gate errors.

Furthermore, optimizing each compilation stage (layout, routing, optimization) in isolation fails because early decisions propagate downstream. A locally optimal choice in the layout stage might completely block a powerful optimization opportunity later on.

The quantum transpilation pipeline showing how different pass sequences lead to vastly different physical circuit sizes and qualities.

Methods

The authors introduce TuniQ, which formulates quantum pass selection as a Markov Decision Process (MDP) solved via reinforcement learning (specifically, MaskablePPO). TuniQ features three key architectural innovations:

  1. Dual-Encoder Architecture: Quantum circuits look completely different before and after hardware mapping. TuniQ uses a pre-layout encoder to capture the spatio-temporal structure of logical qubit interactions, and switches to a post-routing encoder that injects real-time hardware calibration data (gate error rates, $T_1/T_2$ coherence times) directly into the state representation.
  2. Shaped Intermediate Rewards: To solve the challenge of delayed feedback (where you only truly know if a circuit is good at the very end), TuniQ introduces intermediate proxy metrics—Layout Quality (LQ) and Routing Quality (RQ)—to give the RL agent step-by-step feedback before final Estimated Success Probability (ESP) can be calculated.
  3. Dynamic Action Masking: To prevent the agent from generating illegal or unexecutable pass sequences, a dynamic mask restricts the available choices at each step, guaranteeing a valid physical circuit by construction.

Datasets

  • Training: TuniQ was trained exclusively on synthetic, randomly generated circuits (5–15 qubits, varying depths) using Qiskit's random circuit generator.
  • Evaluation: To test generalization, TuniQ was evaluated on structured algorithmic workloads from two major benchmark suites:
  • MQTBench: Quantum Phase Estimation (QPE), HHL, Deutsch-Jozsa, QAOA, Grover, Quantum Walk, and Bernstein-Vazirani.
  • QASMBench: QFT, QNN, Toffoli, WState, and VQE.
  • Scaling Workloads: Large-scale variants of QPE and QFT up to 65 qubits.

Key Insights and Ideas

  • Random-to-Structured Generalization: Remarkably, by training only on small, random circuits, TuniQ successfully learns fundamental structural properties of quantum compilation. This allows it to generalize "zero-shot" to complex, highly structured algorithms it has never seen before.
  • The Perils of Greediness: The authors prove that greedy, stage-by-stage optimization often results in worse final circuits. TuniQ's cross-stage awareness allows it to make occasionally suboptimal local choices early on to unlock massive optimization gains in later stages.
  • Noise-Aware Adaptability: Because TuniQ conditions its decisions on real-time calibration data, it automatically adjusts its pass selection as hardware noise profiles scale down or drift over time, eliminating the need for constant model retraining.
Optimal pass configurations vary significantly across different algorithmic benchmarks.

Key Results

Evaluated on real IBM Quantum Cloud processors (including the 133-qubit Torino and 156-qubit Pittsburgh Heron-generation chips), TuniQ demonstrated substantial improvements over Qiskit's highest optimization level (Level 3):

  • Fidelity Boost: TuniQ improved output fidelity (measured via Total Variation Distance) by an average of 20% on MQTBench and up to 39% on QASMBench.
  • Faster Compilation: It reduced classical compilation time by an average of 34% (and up to 51%), which is vital for variational algorithms that re-compile circuits thousands of times.
  • Strong Scaling: When replaying learned pass sequences on utility-scale circuits up to 65 qubits, TuniQ's advantage grew, yielding up to 40% fewer gates and 50% lower circuit depth compared to Qiskit.

Limitations and Future Work

While TuniQ marks a major step forward, some limitations remain:

  • Advanced Noise Phenomena: TuniQ relies on standard calibration data ($T_1, T_2$, gate errors) and does not explicitly model complex, dynamic noise like crosstalk or gate-type-specific error variations.
  • Out-of-Distribution Drift: If a hardware device experiences an extreme calibration shift or a completely new architectural layout is introduced, the policy may eventually require periodic fine-tuning or retraining.
  • Pre-QEC Focus: TuniQ operates at the physical circuit level for near-term (NISQ) devices. Integrating it with fault-tolerant, error-corrected logical compilation layers remains an open avenue for future research.

Summary updated

BibTeX
@inproceedings{hasanat2026tuniq,
  author = {Mohammad Abrarul Hasanat and Jason Ludmir and Tirthak Patel and Rohan Basu Roy},
  title = {{TuniQ: Autotuning Compilation Passes for Quantum Workloads at Scale for Effectiveness and Efficiency}},
  booktitle = {ICS},
  year = {2026},
  doi = {10.1145/3797905.3807862},
}
Figure