Profiling Transpiled Quantum Circuits to Guide LLM Circuit Search

A quantum circuit written for an idealized machine almost never runs as written. Before it can run, a compiler called a transpiler rewrites it for the actual chip. The transpiler converts gates into the few the chip supports, assigns abstract qubits to physical ones, and inserts SWAP gates, which shuttle quantum states between qubits that are not wired together. These insertions can double a circuit's depth, and on noisy hardware depth means errors. Automated circuit designers, including recent ones that use a large language model (LLM) as the designer, mostly score circuits before this step or receive only one scalar number afterwards. We propose a different signal: a circuit profiler that traces every cost the transpiler and the device add back to the specific logical gate that caused it. We then give the LLM a ranked list of its own circuit's hardware hotspots to edit, the way a software profiler tells a programmer which function to rewrite.

The core claim is narrow and testable. When an LLM iteratively edits a variational circuit (a parameterized circuit whose angles are tuned by a classical optimizer, as in the Variational Quantum Eigensolver, VQE, for molecular ground states), gate-level attribution of post-transpilation cost makes it reach hardware-feasible circuits in fewer expensive evaluations than the same loop fed only the scalar cost. The profiled loop should also match or beat reinforcement-learning searchers that are trained directly against device noise. Profiling is also the scalability lever. Transpilation and calibration-weighted cost estimates are cheap at qubit counts where state simulation is impossible. The expensive simulation can therefore be reserved for a small number of candidates that have already passed a cheap profiling stage.

Where this sits

Three lines of work meet here, and each leaves the same hole. QGAS (Unleashing the Potential of LLMs for Quantum Computing) runs a GPT-4 propose–simulate–refine loop for VQE and combinatorial problems. Its feedback is idealized simulation performance, with no coupling map, no routing and no device noise. Its two-model translation into QASM also needed human pruning of invalid or overly deep circuits. This motivates our work: the LLM loop is useful, but it is blind to hardware. On the reinforcement-learning side, CRLQAS (Curriculum reinforcement learning for quantum architecture search under hardware errors) trains a Double DQN agent against IBM device noise profiles, and BenchRL-QAS (BenchRL-QAS) benchmarks nine agents under depolarizing noise with hand-written action masking. Both fold hardware into a scalar reward over a fixed grid encoding. They are our strongest competitors, and the comparison we care about is whether structured feedback beats a scalar reward at equal evaluation budget. Training-free QAS (Training-Free Quantum Architecture Search) ranks candidates with path-count and expressibility proxies. Those proxies never see the device. OmniQEC (OmniQEC) shows in error correction that abstract figures of merit can mispredict circuit-level performance. This warns us against trusting abstract proxies, so all of our final numbers are computed after transpilation.

The mechanism borrows from classical code refinement. POLO (POLO) shows that an LLM optimizes code much better when a call-graph profiler points it at the hot functions than when it rewrites blindly. Our circuit profiler plays the same role. MEIC (MEIC) shows that hardware-code repair loops need a rollback to the last good version, because LLM patches often trade one bug for another. We adopt that rollback directly, since evidence of plateauing after a few rounds (Yan et al.) suggests unguarded loops stall. GraphIR (GraphIR) shows that a structured representation of editable regions and validity rules helps LLMs edit neural architectures. We use a light quantum analogue of it to keep edits legal, but it is supporting machinery, not the contribution. From hardware-aware NAS we take one lesson. HW-NAS-Bench (HW-NAS-Bench) found FLOP–latency rank correlation as low as 0.18 on Edge TPU, so abstract cost and device cost should not be presumed to agree. We expect the same divergence between logical gate count and post-routing cost, and we will measure it rather than assume it.

Core mechanism

Take a logical circuit with gates $g$. We transpile it for a target device's coupling map and native gate set. Every physical operation $p$ in the output is tagged with its originating logical gate $a(p)$. SWAPs are charged to the two-qubit gate whose non-adjacent operands forced them, and decomposition gates are charged to the gate they decompose. Using device calibration data, each physical operation gets a cost $c(p) = -\log F(p)$, where $F(p)$ is its reported fidelity. Idle time on the critical path is charged through a decoherence term derived from T1/T2. The attributed cost of a logical gate is

$$C(g) = \sum_{p:\, a(p) = g} c(p),$$

so that $\sum_g C(g)$ equals the negative log of the estimated success probability of the whole transpiled circuit. The decomposition is exact by construction. It therefore conveys where the scalar cost comes from without changing it.

The profiler report given to the LLM lists the top hotspot gates with their $C(g)$, how many SWAPs each caused, which physical qubit pairs they ran on, and their contribution to critical-path depth. The circuit itself is shown in a structured form: blocks, which qubits each block touches, which parameters are tied, and which edits are allowed. Allowed edits include relabeling logical qubits, reordering commuting gates, replacing an entangler pattern, or deleting a block. Each round the LLM proposes edits targeted at hotspots. A fast stage transpiles and profiles each edited candidate in seconds, without simulation. Only candidates that improve estimated success probability without growing parameter count past a budget enter the slow stage. In the slow stage, variational parameters are trained under a noisy density-matrix simulation of the device, and the energy error is measured. If a candidate's slow-stage objective regresses, the population rolls back to its best ancestor, following MEIC. The two-stage structure resembles OmniQEC's fast–slow loop, but the fast stage here evaluates the transpiled circuit itself rather than algebraic code parameters.

Research Program

The program builds three artifacts. The first is the attributing profiler, implemented as a pass that wraps a standard transpiler and preserves provenance tags through layout, routing and optimization passes. The second is the edit loop with rollback. The third is a controlled study that isolates whether attribution matters.

The analytical question is what kind of edit attribution enables. Our hypothesis is that the scalar-only loop mostly finds global changes, such as fewer layers. The attributed loop should find local, structure-preserving changes: relabeling qubits so a frequently used entangling pair sits on a high-fidelity edge, or reordering commuting entanglers so the router needs fewer SWAPs. We will classify accepted edits by type to test this, and check whether the energy error those edits preserve differs. If attribution helps only by prompting the LLM to delete gates, the contribution is weak, and the edit analysis will show it.

Baselines

The naive reference point is the hardware-efficient ansatz and the UCC-style or QGAS-style circuit for each molecule, transpiled with the transpiler's heaviest optimization setting and trained under the same noisy simulation. This is "search abstractly, let the compiler clean up". Any method that cannot beat it does not justify a search loop. TF-QAS reports that a 3-layer hardware-efficient ansatz with 42 gates failed where its 35-gate circuit reached the ground state, so this reference is beatable in the noiseless setting. Whether it is beatable after routing is open.

The strongest existing method is CRLQAS. Its agent is trained against device noise, and it reports reaching chemical accuracy ($1.6 \times 10^{-3}$ Ha) at ten times the median IBM Mumbai noise, and a 67-gate circuit for LiH-6 versus 132 for earlier methods (CRLQAS). We pair it with the best BenchRL-QAS agent per task. On BeH$_2$, BenchRL-QAS reports errors around $10^{-6}$ with 16–22 gates versus 57 for TF-QAS (BenchRL-QAS). We found no result on Lacuna for any of these methods' post-routing SWAP count, transpiled depth or estimated success probability on a sparse coupling map. Those numbers will be produced by us, using the authors' configurations. To keep the comparison fair, every method runs on the same molecules, coupling maps and calibration snapshots. Every method is capped at the same number of slow-stage evaluations (noisy parameter trainings), which is the dominant cost. RL agents also get our cheap profiler score folded into their reward at no extra charge, so they receive the hardware information the LLM gets, but in scalar form. Tuning budget is matched by giving each RL method the same number of hyperparameter configurations as we spend on prompt variants. We also report wall-clock time, LLM token cost and simulator calls.

The decisive ablation is the same LLM loop, same rollback, same budget, with the profiler report replaced by the total scalar cost and aggregate SWAP count. A second ablation removes rollback, and a third replaces the targeted hotspot list with a randomly ordered list of the same gates, to separate "being pointed at the right gates" from "seeing more text". Beating the baselines means two things at matched slow-stage budget. The method must reach chemical accuracy under device noise on more molecule–device pairs than CRLQAS and the scalar ablation. Among circuits that reach it, it must also have higher median estimated success probability, with differences outside the seed-to-seed spread across at least five seeds.

Why not just…?

Why not just add transpiled SWAP count as a penalty to an existing search? This is the most serious alternative, and it is exactly the scalar-feedback ablation. QGAS-style loops can absorb a scalar, and CRLQAS-style rewards already include noise. If the scalar ablation matches the attributed loop at equal budget, our central claim fails and we will report that. The prior evidence for attribution is indirect. POLO's gains come from directing the LLM to specific hot functions, and GraphIR's structured state raised dependency-reasoning scores from 0.406 to 0.504 over code alone. Neither result is quantum, so the experiment has to decide it.

Why not just restrict the search space to gates on native coupling edges, so no SWAPs are ever needed? This removes routing overhead by construction. It is a real threat on small, well-connected problems. Its cost is that molecular Hamiltonians need interactions between distant orbitals. On a sparse map those interactions must then be built from chains of native gates, which the restricted search must discover on its own. We include a native-only variant of both CRLQAS and our loop. If native-only search wins, the profiler's routing attribution is redundant, but its calibration-weighted attribution to heterogeneous edge fidelities may still help. We will report the two components separately, as routing-only attribution versus fidelity-only attribution.

Why not just search abstractly and trust an optimizing transpiler? This is the naive baseline. HW-NAS-Bench's finding that abstract cost and device cost can rank architectures very differently suggests that the post-hoc fix will often be too late. We will measure the analogue directly by computing Kendall correlation between logical two-qubit gate count and post-routing estimated success probability across every candidate any method evaluates.

Why not just use differentiable search over a super-circuit? DQAS (Differentiable quantum architecture search) and hybrid variants score best on QAS-Bench unitary approximation, with similarity above 0.6 versus about 0.2 for RL and evolutionary search at 5 qubits (QAS-Bench). They optimize over an abstract slot grid with no routing in the loop, however. We run DQAS on the unitary-approximation track with post-hoc transpilation as an additional baseline. That track is where it is strongest and where our method is most likely to lose.

Proposed Experiments

The main experiment covers the VQE molecules used across the cited work: H$_2$ (4 qubits), LiH (6), BeH$_2$ (6) and H$_2$O (8). Each is run on two coupling maps, a heavy-hex-style sparse map and a linear chain, with device calibration snapshots of the kind CRLQAS uses. Metrics are noisy energy error in Hartree, chemical-accuracy hit rate, post-routing two-qubit gate count and depth, estimated success probability, and slow-stage evaluations to first feasible circuit. The second experiment is the QAS-Bench unitary-approximation set (2–5 qubits), scored by its similarity metric $f$ after transpilation and noisy simulation. It tests whether attribution helps when the objective is not chemistry.

The scalability check uses the fact that profiling needs no simulation. We take QAS-Bench-style Clifford regeneration targets, extended beyond its 10-qubit cap to 20–50 qubits, because Clifford circuits stay efficiently simulable at that size. We measure how the gap between the attributed and scalar loops in routing cost changes with qubit count at a fixed evaluation budget. Our expectation is that the gap widens. With more qubits there are more gates, and a scalar says less about which one to change. If the gap instead shrinks or vanishes, attribution is a small-circuit effect, and the scalability claim should be dropped.

The decisive checks are two. First, does the attributed loop beat the scalar ablation and CRLQAS at matched slow-stage budget on the sparse map? Second, does the edit-type analysis show that its gains come from local relabeling and reordering rather than simple gate deletion? If both hold, profiler-guided editing is a real addition to hardware-aware circuit search. If either fails, the result still settles whether hardware feedback for LLM circuit designers needs to be more than a single number.