Papers
Topics
Authors
Recent
Search
2000 character limit reached

QAP-Router: Tackling Qubit Routing as Dynamic Quadratic Assignment with Reinforcement Learning

Published 12 May 2026 in quant-ph and cs.AI | (2605.12365v1)

Abstract: Qubit routing is a fundamental problem in quantum compilation, known to be NP-hard. Its dynamic nature makes local routing decisions propagate and compound over time, making global efficient solutions challenging. Existing heuristic methods rely on local rules with limited lookahead, while recent learning-based approaches often treat routing as a generic sequential decision problem without fully exploiting its underlying structure. In this paper, we introduce QAP-Router, framing qubit routing based on a dynamic Quadratic Assignment Problem (QAP) formulation. By modeling logical interactions, or quantum gates, as flow matrices and hardware topology as a distance matrix, our approach captures the interaction-distance coupling in a unified objective, which defines the reward in the reinforcement learning environment. To further exploit this structure, the policy network employs a solution-aware Transformer backbone that encodes the interaction between the flow matrix and the distance matrix into the attention mechanism. We also integrate a lookahead mechanism that blends naturally into the QAP framework, preventing myopic decisions. Extensive experiments on 1,831 real-world quantum circuits from the MQTBench, AgentQ and QUEKO datasets show that our method substantially reduces the CNOT gate count of routed circuits by 15.7%, 30.4% and 12.1%, respectively, relative to existing industry compilers.

Summary

  • The paper introduces QAP-Router, which recasts qubit routing as a dynamic Quadratic Assignment Problem optimized through reinforcement learning.
  • It employs a solution-aware Transformer that fuses logical and physical encodings to guide globally effective SWAP selections.
  • Empirical results demonstrate significant CNOT count reductions, validating global routing strategies while revealing transferability challenges.

QAP-Router: Dynamic QAP Formulation for Qubit Routing and Reinforcement Learning-Based Optimization

Introduction and Motivation

Qubit routing represents a bottleneck in the compilation pipeline for near-term quantum computers, particularly in NISQ devices characterized by restricted qubit connectivity and limited native gate sets. The routing problem is inherently NP-hard and dynamic: each SWAP operation alters the mapping and modifies the set of pending logical interactions, meaning myopic local decisions accumulate and propagate sub-optimally through the global circuit execution. Existing heuristic and RL-based approaches often operate with insufficient global context, optimizing locally and failing to leverage the tightly coupled interaction-structure of quantum circuits and their hardware constraints.

QAP-Router addresses this by reframing qubit routing as a dynamic instance of the Quadratic Assignment Problem (QAP). The central insight is to treat logical qubits and their pairs (pending gate operations) as facilities with structured communication patterns (captured in a flow matrix), and physical qubits as positions in space characterized by a distance matrix induced by device topology. Routing is then the process of sequentially permuting the logical-to-physical assignment so as to minimize a global cost reflecting interaction proximity over the entire circuit, while respecting device constraints and execution order. Figure 1

Figure 1: The quantum compilation pipeline decomposes algorithms into logical circuits, applies device-specific mapping, and applies routing to meet connectivity constraints via SWAP insertion.

Dynamic QAP Formulation and Reinforcement Learning Framework

The Quadratic Assignment Problem is classically defined as the task of permuting NN facilities among NN locations to minimize Tr(FXDX⊤)\mathrm{Tr}(\boldsymbol{F} \boldsymbol{X} \boldsymbol{D} \boldsymbol{X}^\top), where F\boldsymbol{F} is the facility flow matrix and D\boldsymbol{D} is the location-wise distance matrix. In QAP-Router, each time slice of the circuit defines a distinct flow matrix Ft\boldsymbol{F}_t, representing pending two-qubit interactions, and hardware connectivity is encoded by a static D\boldsymbol{D}. Routing unfolds as a series of local permutations (SWAPs) Xt\boldsymbol{X}_t, updating assignments and removing gates as their dependencies are satisfied.

By recasting the reward function in the RL environment as the negative difference in the QAP objective before and after a SWAP, QAP-Router ensures that every RL action is evaluated against its global effect on interaction proximity. This direct structural coupling between routing actions and routing cost function allows the RL agent to learn routing strategies that are not just locally greedy but globally effective. Figure 2

Figure 2: Illustration of the QAP-motivated reward where two alternative SWAPs have differing effects on distance between interacting qubits.

Policy Architecture: Solution-Aware Mixed Attention Encoding

The QAP-Router policy network employs a solution-aware Transformer encoder integrating both the logical flow information and the physical qubit placement information:

  • Logical Encoder: Each logical qubit is one-hot encoded and projected into a latent space, with message-passing via multi-head attention modulated directly by the effective flow matrix F^t\hat{\boldsymbol{F}}_t (with lookahead decay if enabled) to prioritize information about imminent and future interactions.
  • Physical Encoder: Positions of logical qubits on the hardware are determined by the current permutation and projected; kernel-weighted residual layers propagate spatial and connectivity features, normalized by the device distance matrix.
  • Fusion Layer: Logical and physical embeddings are concatenated and passed through a solution-aware Transformer, where attention weights are modulated by the interaction-distance product F^tâ‹…D\hat{\boldsymbol{F}}_t \cdot \boldsymbol{D}. The fused context is used by both the policy (SWAP selection) and value heads. Figure 3

    Figure 3: Detailed pipeline for converting a logical circuit into a stacked sequence of flow matrices and extracting logical/physical latent embeddings for policy learning.

Empirical Evaluation and Ablation

Experimental Setup

The study benchmarks QAP-Router on the MQTBench, AgentQ, and QUEKO circuit collections over grid and IBM Tokyo-like device topologies at 12, 16, and 20 qubits. The main evaluation metric is the total number of inserted CNOT gates required for compilability—an unbiased measure of routing overhead with direct correlation to circuit error rates.

Compared reference methods include Greedy, Qiskit BasicSwap, Qiskit SabreSwap (basic/lookahead), Pytket LexiRouting, and Qiskit AIRouting. All comparisons are run from fixed initial mappings to ensure statistical fairness.

Results

QAP-Router achieves substantial reductions in CNOT insertion across most datasets and device topologies. On 16-qubit AgentQ, it yields an 18.4% CNOT reduction relative to AIRouting and an 11.7% reduction compared to SabreSwap (lookahead). On MQTBench, CNOT count is reduced by 7.61% (16 qubits, 2D grid) versus AIRouting. For QUEKO benchmarks (20 qubits, 2D grid) the reduction reaches 21.8% over AIRouting.

In settings with more challenging connectivity or greater gate density (20-qubit MQTBench circuits), performance is competitive but does not outperform the strongest baselines. This highlights the sensitivity of dynamic QAP-based policies to both circuit topology and device mapping flexibility. Figure 4

Figure 4: Routing quality improves monotonically with larger lookahead horizon in the policy, for both MQTBench and AgentQ on 16-qubit devices.

Figure 5

Figure 5: Inserted CNOT count for distinct 12-qubit circuit types; QAP-Router systematically outperforms all classical and learning-based baselines.

Figure 6

Figure 6: Inserted CNOT count across 16-qubit MQTBench circuit types, highlighting the global improvement of QAP-Router's approach.

Figure 7

Figure 7: Results for 20-qubit circuits further emphasize the method's competitiveness as problem size increases.

Ablation: Lookahead Horizon

A critical architectural component is the use of decay-weighted lookahead in the flow matrix. Empirical ablation over horizon length NN0 demonstrates clearly monotonic improvement in routing efficiency as the window broadens, validating the hypothesis that routing policies benefit from global circuit context and not just local interaction structure.

Implications and Future Prospects

The QAP-Router approach provides a novel intersection of combinatorial optimization theory and deep RL, yielding policies that internalize global circuit-device structure rather than relying solely on local heuristics or black-box RL. The results suggest strong theoretical alignment between QAP and quantum circuit routing, which is underexploited in conventional compilers.

Practically, CNOT minimization correlates with reduced error rates, shallower circuits, and improved algorithmic fidelity on NISQ hardware. Integrating such RL policies into production compilers or hybrid classical-AI frameworks will likely prove essential for high-quality quantum compilation in near-term and future large-scale quantum architectures.

Several limitations persist. The current policy requires retraining for each circuit size and device topology, limiting transferability and scalability in heterogeneous or dynamically reconfigurable devices. Addressing this with size-agnostic, graph-based encoding architectures is a clear next step, as is leveraging multi-task or meta-learning to produce robust, reusable routing solutions.

Conclusion

QAP-Router introduces a theoretically justified and practically effective methodology for qubit routing via dynamic QAP-based RL. By unifying the classical structure of the QAP with learning-based optimization, it achieves superior CNOT minimization over strong baselines across realistic benchmarks and device models. This work signals the necessity—and effectiveness—of exploiting global problem structure in RL-based quantum compilation, setting the stage for further advancements in scalable, device-aware quantum software stacks.

(2605.12365)

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.