ConceptioArchivearXiv CS
arXiv CSopen access

When Close Enough Is Not Enough: Autoregressive Drift in Quantum Circuit Synthesis

Unknown · 2026 · arxiv_cs
arXiv CS · Papers · License: Open Access · 2026
Open Source ↗Direct PDF ↓
artificialintelligenceknowledgerepresentationreasoning
artificial intelligence, reasoning, knowledge representation

When Close Enough Is Not Enough: Autoregressive Drift in Quantum Circuit Synthesis Mehdi Saeedi, Eddie Richter, Paul Hartke

arXiv:2607.12780v1 [quant-ph] 14 Jul 2026

Advanced Micro Devices, Inc. (AMD) {mehdi.saeedi, eddie.richter, paul.hartke}@amd.com

that cascade irrecoverably. We state this result and its practical consequences up front, then substantiate it in Sections VI and VII. Classical T -count optimizers employ algebraic rewriting rules derived from ZX-calculus [3], matroid partitioning [4], and phase polynomial representations [5], [6]. Circuit simplification via peephole optimization, level compaction [7], and template matching [8] further reduces gate counts. For singlequbit unitaries, optimal Clifford+T decomposition is well understood [9], [10], but multi-qubit synthesis remains challenging. More broadly, quantum circuit synthesis encompasses a rich set of techniques, from reversible-logic methods [11], [12] to general unitary synthesis [13]. While effective, they are limited to optimization patterns captured by hand-crafted rules [14], [15]; discovering new identities becomes increasingly difficult as circuit complexity grows. We ask whether a neural network can learn circuit optimization rules directly from data,1 potentially replacing or augmenting hand-crafted rule libraries. To investigate, we train a compact encoder-decoder transformer (44.8M parameters) with a structured tokenization scheme in which every token carries circuit-semantic information, using a vocabulary of 102 tokens.2 The architecture handles two complementary tasks: • Parameterized circuits: the model predicts circuit structure with 100% structural validity across all qubit counts, while a separate regression head outputs (sin, cos) angle estimates I. I NTRODUCTION on the unit circle. Because the predicted structure is nearFault-tolerant quantum computing encodes logical qubits perfect, angle optimization reduces to a low-dimensional into many physical qubits and restricts computation to a set classical problem: a Nelder-Mead optimizer refines the of fault-tolerant operations [1]. The standard universal gate angles, yielding median fidelity 1.000 on 3–6 qubit circuits set for such architectures is Clifford+T: Clifford gates (H, S, under beam search, with performance improving at higher CNOT) can be implemented transversally at negligible cost, qubit counts. while each non-Clifford T gate requires expensive magic state • Clifford+T circuits: all gates are discrete and no angle postdistillation [2]. Minimizing the T -count—the total number of processing is possible. Trained on 200K PyZX-optimized T and T † gates—directly reduces the dominant resource cost pairs, the model produces 100% structurally valid outputs of fault-tolerant execution. In realistic algorithms, T -count whose average T -count matches the PyZX target, yet exact dominates error-correction overhead, making its optimization functional equivalence remains limited. a critical compilation step. The contrast between these settings reveals the core challenge. Our goal is to test whether a learned model can perform T -count optimization, and to pinpoint where it succeeds and 1We use “optimization” for the circuit-to-circuit task studied here—rewriting fails. Our finding is a sharp dichotomy: pairing a learned a given circuit into an equivalent, lower-cost one—a special case of the broader structure predictor with classical angle optimization attains circuit synthesis problem named in the title. 2 4 special tokens (PAD, BOS, EOS, SEP) + 21 gate types + 12 qubit tokens near-perfect fidelity on parameterized circuits, whereas for (Q0–Q11) + 1 angle placeholder = 38 base tokens, plus 64 length-conditioning discrete Clifford+T circuits exact equivalence is limited by a tokens (LEN0–LEN63) = 102 total. For Clifford+T, only 25 of these are active failure mode we name autoregressive drift—early-token errors (4 special + 9 CT gates + 12 qubits). Abstract—Quantum circuit optimization for fault-tolerant computing requires exact functional equivalence while minimizing expensive non-Clifford resources such as T gates. We study this problem using a compact 44.8M-parameter encoder-decoder transformer with structured circuit tokenization, evaluating on parameterized circuits (2–6 qubits) and Clifford+T circuits (3–6 qubits). On parameterized circuits, a hybrid approach—structure from the transformer, angles from classical optimization—achieves median fidelity 1.000 on 3–6 qubit circuits. On Clifford+T circuits, where all gates are discrete and no post-processing is possible, the model learns valid syntax and accurate T -count statistics, yet exact equivalence degrades sharply with target length—from 88% on circuits with ≤9 gates to near zero beyond 26 gates. We trace this failure to autoregressive drift: early-token divergence cascading irrecoverably through left-to-right decoding. Two levers partially mitigate the drift: inference-time strategies that generate multiple candidates and select via equivalence verification raise exact-match rates from 7% to 22.5%, while scaling training data by 2.5× pushes them to 39.5%. Yet the degradation with target length persists—even with more data, exact equivalence drops from 94% on short circuits to under 4% beyond 26 gates. The contrast between settings is our central finding: when approximate outputs can be rescued by post-processing, the transformer succeeds; when exact discrete correctness is required, autoregressive drift limits reliability, with both inference-time search and data scaling as effective levers while training-side fine-tuning and model-level diversification are not. Index Terms—autoregressive drift, Clifford+T, inference-time compute, quantum circuit optimization, T-count

On Clifford+T circuits, exact-match rates drop from 88% on short targets (≤9 gates) to near zero on longer ones (≥26 gates), driven by a failure mode we term autoregressive drift: the model diverges from the correct output within the first few tokens, and left-to-right decoding propagates the error through the entire sequence. On parameterized circuits, similar early-sequence errors arise in angle predictions, but classical post-processing rescues the output because the underlying structure is correct. This isolates the bottleneck: not the transformer’s ability to learn optimization patterns, but the impossibility of recovering from discrete token errors once they occur. From this analysis, we make four contributions: 1) A unified transformer architecture with structured tokenization achieving median fidelity 1.000 on 3–6 qubit parameterized circuits (via angle post-processing) and 100% structural validity on Clifford+T circuits (Section VI-A). 2) A reproducible diagnosis of autoregressive drift in exact discrete circuit synthesis, identifying target circuit length— not qubit count—as the dominant predictor of failure (Section VII). 3) Inference-time decoding strategies that raise Clifford+T exact-match rates from 7% (greedy) to 22.5% (Temp N =200), with explicit quality–latency tradeoffs (Section VI); the model’s high reliability on short circuits suggests deployment as a peephole-style optimization pass within production compilers (Section IX). 4) Evidence that targeted fine-tuning, candidate pooling, and model ensembling each yield only marginal gains over the 21.0% Temp N =100 baseline (M1: 22.5%, M2: 20.0%, M3: 21.5%, M4: 24.5%), while 2.5× more training data nearly doubles exact-match rates—yet preserves the drift-driven failure pattern (Section VIII). II. R ELATED W ORK A. Classical T-Count Optimization The ZX-calculus provides a graphical language for reasoning about quantum circuits; PyZX [3] leverages it to achieve substantial T -count reductions through automated simplification. Amy et al. [4] formulate T -depth optimization as a matroid partitioning problem with polynomial-time algorithms for a restricted circuit class, while Nam et al. [5] combine phasepolynomial rotation merging with gate-cancellation heuristics (Hadamard reduction, CNOT cancellation). Heyfron and Campbell [6] introduce a compiler applying a sequence of T -reducing transformations, and Amy et al. [16] give a meet-in-the-middle algorithm for depth-optimal Clifford+T synthesis of small unitaries. Architecture-aware compilation further constrains the problem: mapping circuits to hardware with limited qubit connectivity [17] introduces additional gates that compound the T -count overhead. These approaches are exact and efficient but rely on manually discovered identities, limiting applicability to patterns human experts have already identified. B. ML for Quantum Circuit Compilation Prompt-based LLMs. QUASAR [18] augments a generalpurpose language model with tool use to generate quantum

assembly (QASM [19]) as raw text. While this can produce valid circuits, it devotes billions of parameters to parsing syntactic tokens—brackets, semicolons, whitespace—that carry no circuit-semantic information. Diffusion models. genQC [20] encodes circuits as structured gate-position tensors and generates them via denoising diffusion. The approach produces diverse candidates but struggles with exact equivalence—denoising introduces rounding errors, and fixed-size tensors handle variable-length circuits poorly. Reinforcement learning. Rietsch et al. [21] apply Gumbel AlphaZero to Clifford+T unitary synthesis, using Monte Carlo tree search (MCTS) guided by a learned value function. IBM’s RL approach [22] trains agents to synthesize Linear Function, Clifford, and Permutation circuits subject to device connectivity constraints, using step-by-step gate construction with correctness-based rewards. AlphaTensor-Quantum [23] casts T -count optimization as a tensor-decomposition problem solved by deep RL with MCTS, avoiding autoregressive decoding entirely. These methods achieve strong results on specific circuit classes but require custom reward engineering and tend to be sample-inefficient. Generative flow networks. FlowQ-Net [24] learns a stochastic policy that samples VQA ansatz architectures in proportion to a user-defined reward, explicitly targeting diversity rather than RL-style single-trajectory optimization. Like AlphaZerobased approaches, it avoids autoregressive left-to-right decoding, but it targets ansatz design for variational algorithms (VQE, MaxCut) rather than T -count optimization. Search-based and formal methods. Quartz [25] autogenerates a verified database of equivalent circuit classes (ECCs) via SMT solving and applies cost-based backtracking search over this database. Paradis et al. [26] use simulated annealing with a domain-specific energy function and a custom simplification pass to synthesize circuits over arbitrary finite gate sets. These guarantee correctness but face combinatorial explosion on larger circuits. Evolutionary methods. Genetic algorithms have long been applied to circuit compilation and optimization, evolving a population of candidate circuits under fitness functions for depth, gate count, or fidelity [27], [28], with hybrids that add a local-search step (e.g., Nelder-Mead) to refine variational parameters [29]. Like the reinforcement-learning and search methods above, these explore many candidates per instance rather than amortizing optimization into a single learned autoregressive pass. Supervised learning. Theißinger et al. [30] train a lightweight MDL-prediction model that estimates the remaining gate cost of a residual unitary, then use this estimate as a value function inside a stochastic beam search over Clifford+T gates— the closest prior work to ours. Key differences remain: their input is the target unitary (not an unoptimized input circuit), the supervised target is a scalar MDL (not a token sequence), and they do not diagnose or analyze autoregressive drift. Test-time compute scaling. Snell et al. [31] show that scaling inference-time compute (e.g., generating and verifying multiple candidates) can outperform scaling model parameters

for reasoning tasks. We instantiate this finding in quantum compilation, where an efficient verifier (unitary matrix comparison) makes generate-and-verify strategies practical. III. P ROBLEM S ETUP A. Task Definition We formulate Clifford+T optimization as sequence-tosequence translation. Given an input circuit Cin on 3–6 qubits over the gate set G = {H, S, S † , T, T † , CNOT, CZ, X, Z} (CZ appears only in PyZX-optimized targets; cf. Section IV-C), the goal is to produce an output circuit Cout over the same gate set satisfying: 1) Exact equivalence up to a global phase: process fidelity F (UCin , UCout ) > 0.999. 2) T -count reduction: the number of T and T † gates in Cout is minimized. Unlike unitary synthesis—where the input is a matrix—the model receives a circuit and must learn to recognize and eliminate redundancy in the gate sequence. This circuit-tocircuit setting enables structured tokenization (Section IV-A) and provides richer input features than a raw unitary matrix. B. Metrics

Fig. 1. End-to-end pipeline. Training pairs are generated using PyZX (Clifford+T) or Qiskit O3 (parameterized). At inference, N candidates are decoded and verified against the input unitary; the verifier selects the lowestT -count equivalent circuit.

[GATEg , Qq1 , . . . , Qqk ], and a full circuit is wrapped with delimiters: [BOS, g1 , . . . , gm , EOS]. Example. The 3-qubit circuit H(q0 ) · CNOT(q0 , q1 ) · T (q2 ) is tokenized as: [BOS, H, Q0, CX, Q0, Q1, T, Q2, EOS]

We use process fidelity as the primary correctness metric. This 9-token sequence encodes three gates, and every token Given unitary matrices U (input circuit) and V (predicted carries circuit-semantic information—no model capacity is circuit), we compute: spent on parsing syntactic delimiters. For Clifford+T circuits, all gates are discrete and no |Tr(U † V )|2 , (1) continuous angle parameters appear. For Clifford+T, the F (U, V ) = 2 d where d = 2n is the Hilbert space dimension for n qubits. active vocabulary reduces to 25 tokens: 4 special tokens F = 1.0 indicates identical operations up to a global phase; (PAD padding, BOS begin-of-sequence, EOS end-of-sequence, † † we define exact equivalence as F > 0.999, with the tolerance SEP input/output separator), 9 gate types (H, S, S , T, T , accounting for floating-point arithmetic. For n ≤ 6 qubits, the CNOT, CZ, X, Z), and up to 12 qubit tokens (Q0–Q11). The unitary is at most 64 × 64, making explicit computation of (1) remaining 77 tokens (12 additional gate types for parameterized circuits, 1 angle placeholder, and 64 length-conditioning tokens) tractable and enabling our generate-and-verify strategy. To optimize non-Clifford resource cost, we treat T -count as are unused during Clifford+T inference. This contrasts with textthe primary objective and report both predicted and PyZX target based approaches [18] that serialize circuits as QASM strings, T -counts to assess whether the model has learned the correct requiring the model to parse brackets, semicolons, register compression level. Inference latency is the wall-clock time declarations, and numerical literals; our vocabulary is ∼100× per circuit, including all candidate generation and verification smaller than a typical byte-pair encoding (BPE) vocabulary, and every token directly encodes a circuit operation. steps. C. Evaluation Protocol

B. Model Architecture

We use an encoder-decoder transformer [32] with pre-layer normalization (Figure 2). The architecture consists of: • Embedding dimension dmodel = 512, 8 attention heads • 6 encoder layers and 6 decoder layers • Feedforward dimension dff = 2048 • Learned token embeddings and learned positional embeddings (max length 256) • Dropout rate 0.1 IV. M ETHOD • Xavier uniform initialization A. Structured Circuit Tokenization This configuration follows the Transformer-base layout of Figure 1 illustrates the end-to-end pipeline. We represent Vaswani et al. [32], yielding 44.8M trainable parameters— quantum circuits as typed token sequences rather than raw text. deliberately compact to enable practical inference latency on Each gate g on qubits q1 , . . . , qk becomes the subsequence client-class GPUs (e.g., 0.2 s greedy decoding per circuit)

All evaluations use a fixed test set of 500 Clifford+T circuits (125 per qubit count, 3–6 qubits), generated independently from the training data with the same random generation pipeline. Results are stratified by target gate-count bins (1–9, 10–14, 15– 25, 26+) to expose the length-dependent failure mode. All runs use a fixed random seed (42) for reproducibility. All strategies are evaluated on a 200-sample subset of the test set.

sequence: T

LCT = −

1X log pθ (yt | y<t , x) T t=1

(2)

For parameterized circuits, the loss combines cross-entropy with angle regression: Lparam = LCE + λangle · Langle

(3)

where Langle is MSE between predicted and target (sin, cos) pairs at ANGLE positions. C. Training Data Generation Fig. 2. Model architecture. The encoder-decoder transformer produces token logits for circuit structure. For parameterized circuits, a separate angle head predicts (sin, cos) pairs refined by Nelder-Mead optimization; this branch is disabled for Clifford+T.

Parameterized circuits. We generate 200K training pairs per qubit count (each trained as a separate model), consisting of a noisy input circuit and a Qiskit O3-optimized target. Input circuits contain 5–25 random gates sampled from a broad gate set ({H, S, T, X, . . .} for 1-qubit, {RZ , RX , RY } for rotations, and CX); noise is injected through random gate insertions and and reproducibility on a single accelerator; model scaling is identity decompositions, and Qiskit’s highest optimization level discussed in Section X. The decoder uses causal masking— (O3) transpiles targets to the basis {CX, RZ , SX, X}. Each each output token attends only to previously generated tokens example provides a clear training signal from input to O3and the full encoder output—and a linear projection maps optimized target, with the target consistently shorter in both hidden states to logits over the vocabulary. total gate count and CX count. Clifford+T circuits. We generate 200K training pairs of For parameterized circuits containing rotation gates (RZ , RX , RY ), the model uses a separate angle regression head to (unoptimized input, PyZX-optimized target) across 3–6 qubits predict continuous rotation angles. Because angles are cyclic (50K per qubit count) via the following pipeline: (0 and 2π represent the same rotation), naive scalar regression 1) Random circuit generation: sample circuits with suffers from a discontinuity at the wrap-around. We resolve this 10–50 Clifford+T gates, drawn uniformly from by predicting (sin θ, cos θ) pairs on the unit circle, recovering {H, S, S † , T, T † , X, Z, CNOT} with qubits sampled the angle via atan2(sin θ, cos θ). uniformly. gate pairs The angle head is a 3-layer MLP (dmodel → dmodel → 2) Redundancy injection: insert identity-equivalent at random positions—HH = I, SS † = I, and CNOT · dmodel /2 → 2) with GELU activations; angle values are injected CNOT = I—creating suboptimal circuits with known into token embeddings at ANGLE positions via a learned reducible patterns. projection of the (sin, cos) pair, enabling the model to condition 3) PyZX optimization: apply full_reduce (ZX-calculus on input angles during encoding. For Clifford+T circuits, all simplification) followed by basic_optimization (temgates are discrete and the angle head is disabled (λangle = 0). plate matching and phase merging). A key finding is that the transformer learns circuit structure 4) Phase decomposition: PyZX outputs rotation gates almost perfectly—100% validity, correct gate counts—but RZ (kπ/4); we decompose these to discrete gates via produces imprecise angle predictions (validation MAE from RZ (π/4) 7→ T , RZ (π/2) 7→ S, RZ (π) 7→ Z, and their 77◦ on 2-qubit circuits to 6.4◦ on 6-qubit circuits, where greater inverses. PyZX may also introduce CZ gates not present in structural regularity aids prediction). For angle post-processing, the input, extending the target gate set to G. we exploit this asymmetry by decoupling the two sub-problems: 5) Verification: confirm unitary equivalence (F > 0.999) and the transformer predicts circuit structure, then Nelder-Mead positive T -count reduction; discard failing pairs (< 0.1%). optimization searches for angles that maximize fidelity with The resulting dataset has an average T -count reduction the target unitary. Post-processing takes approximately 1– of ∼65% (input avg. 8.10 → target avg. 2.83 T -gates; cf. 2 seconds per circuit and substantially improves average fidelity Table IV). Validation (3K) and test (500) sets are generated (e.g., from 0.07 to 0.85 after optimization on 2-qubit circuits independently from the training data. with beam search). Crucially, this decoupling is unavailable for Clifford+T circuits, where every gate is discrete and a D. Decoding Strategies single incorrect token changes the output unitary entirely—an We evaluate five decoding strategies, all sharing a verifierasymmetry central to our analysis of autoregressive drift in first reranking policy for candidate selection. (1) Greedy Section VII. decoding selects the highest-probability token at each step The training objective differs by task. For Clifford+T circuits, the model minimizes cross-entropy loss on the target token

(N =1). (2) Beam search maintains w=5 partial hypotheses scored by length-normalized log-probability and returns the

top-w complete sequences. (3) Temperature sampling generates N independent candidates by sampling at τ =0.8 with nucleus filtering [33] (top-p=0.95), providing stochastic diversity. (4) Length-banded sampling generates candidates conditioned on different target lengths (predicted length ±4 gates), spreading the budget across multiple length hypotheses; we evaluate this strategy because 87% of failures involve incorrect output length, although the empirical results (Section VI) show it underperforms plain temperature at the same budget. (5) Hybrid search pools candidates from multiple temperatures (τ ∈ {0.75, 0.85, 0.95}), both length-banded and non-banded, then applies verifier-first reranking over the merged pool. All candidate-based strategies use verifier-first reranking: compute fidelity F between each candidate and the input unitary, select those with F > 0.999, and return the lowest-T count verified candidate—or the highest-fidelity one if none passes. Correctness takes priority over compression.

TABLE I PARAMETERIZED CIRCUIT OPTIMIZATION RESULTS (MI300X, BATCH =48, LR =3×10−4 ). S EPARATE MODELS TRAINED PER QUBIT COUNT (200 TEST SAMPLES EACH ). A NGLE POST- PROCESSING VIA N ELDER -M EAD TRANSFORMS MODEST RAW FIDELITY INTO NEAR - PERFECT RESULTS FOR 3–6 QUBITS .

Qubits Decoding

F >0.99 (%) Avg F

Med F

2q 2q

Greedy + opt Beam (w=5) + opt

36.0 58.5

0.734 0.849

0.938 0.999

3q 3q

Greedy + opt Beam (w=5) + opt

74.5 81.0

0.856 0.929

1.000 1.000

4q 4q

Greedy + opt Beam (w=5) + opt

84.0 85.5

0.925 0.953

1.000 1.000

5q 5q

Greedy + opt Beam (w=5) + opt

91.0 90.0

0.946 0.969

1.000 1.000

6q 6q

Greedy + opt Beam (w=5) + opt

94.5 95.0

0.965 0.987

1.000 1.000

V. E XPERIMENTAL S ETUP All experiments run on AMD Instinct™ MI300X GPUs optimizing only rotation angles via Nelder-Mead improves (192 GB HBM3). For training, the Clifford+T model trains for performance dramatically: 40 epochs with batch size 48 using AdamW (lr = 3 × 10−4 , • 2–3 qubits: angle optimization achieves median fidelity 1.000 β1 = 0.9, β2 = 0.999, weight decay 10−2 ) and a cosine for 3q (0.999 for 2q under beam search), with validation schedule with 500-step linear warmup. Training completes token accuracy of 92.2% (2q) and 97.9% (3q). in approximately 3.7 hours. Each parameterized model (one • 4–6 qubits: the same architecture scales smoothly, reaching per qubit count) trains for 60 epochs with the same batch validation token accuracy of 98.6% (4q), 99.2% (5q), and size and learning rate, completing in approximately 5.5 hours 99.3% (6q) at the best checkpoints, with angle MAE reaching each. Convergence is smooth across all models, with small 6.4◦ for 6-qubit circuits by the end of training. train–validation gaps indicating minimal overfitting. These results reveal two insights. First, the transformer’s For evaluation, all strategies use τ =0.8, top-p=0.95, and a strength lies in learning circuit structure, not predicting exact fixed seed (42). All strategies—greedy, beam, and candidate- continuous values—once the structure is correct, angle optibased (N ∈ {20, 50, 100})—are evaluated on 200 test samples. mization reduces to a low-dimensional problem (5–15 variables The largest configuration (hybrid search, N =100) requires for 2q, up to ∼30 for 6q) that classical optimizers solve reliably ∼21 seconds per circuit. in ∼2 seconds per circuit. Second, performance improves with As a baseline, PyZX [3] (full_reduce + qubit count: larger circuits provide more structural regularity basic_optimization) serves as both the training for the model to exploit, and the angle regression head benefits oracle and the primary baseline, achieving 100% exact from the richer context. This sets up the critical contrast with equivalence at approximately 6 ms per circuit. Our goal is not Clifford+T circuits: when all gates are discrete, there is no to outperform PyZX but to study the capabilities and failure “close enough” regime, and a single wrong token cannot be modes of learned models on this task. rescued by post-processing. For reproducibility, each run produces a machine-readable Unified vs. per-qubit models. Table II compares the perJSON summary with full hyperparameters, per-sample results, qubit models (200K training samples each) against a single and per-length-bin breakdowns under fixed random seeds. unified model trained on 200K samples across all qubit counts (40K per qubit—5× less per-qubit data). The unified model VI. R ESULTS outperforms per-qubit models on 2–4 qubits (e.g., 67.0% A. Parameterized Circuit Optimization vs. 58.5% F >0.99 on 2q beam), suggesting that cross-qubit Before turning to Clifford+T—the primary focus—we estab- transfer learning compensates for reduced per-qubit data. At lish that the architecture is effective on parameterized circuits, 5–6 qubits, per-qubit specialization dominates (95.0% vs. where angle post-processing is applicable. Table I summarizes 83.5% on 6q), indicating that higher-qubit circuits benefit from results on 200 test samples per qubit count, with separate dedicated training data. This crossover suggests a practical models trained for each. Without post-processing, raw fidelity strategy: a unified model for small circuits with per-qubit fineis modest because angle predictions carry substantial error. tuning for larger ones. However, 100% of generated circuits are structurally valid with correct gate counts across all qubit counts, confirming B. Clifford+T: Main Comparison that the transformer learns circuit structure reliably regardless Table III presents the full decoding strategy comparison; of problem size. Holding the predicted structure fixed and four trends emerge.

TABLE II P ER - QUBIT VS . UNIFIED MODEL COMPARISON ( BEAM w=5 + ANGLE OPTIMIZATION , 200 TEST SAMPLES EACH ). T HE UNIFIED MODEL TRAINS A SINGLE MODEL ON 200K SAMPLES ACROSS ALL QUBIT COUNTS ; PER - QUBIT MODELS TRAIN ON 200K SAMPLES EACH .

Per-qubit (200K each) Unified (200K total) Qubits F >0.99 Avg F Med F F >0.99 Avg F Med F 2q 3q 4q 5q 6q

58.5 81.0 85.5 90.0 95.0

0.849 0.929 0.953 0.969 0.987

0.999 1.000 1.000 1.000 1.000

67.0 87.0 86.5 88.0 83.5

0.906 0.964 0.967 0.962 0.942

1.000 1.000 1.000 1.000 1.000

TABLE III D ECODING STRATEGY COMPARISON ON 3–6 QUBIT C LIFFORD +T CIRCUITS (200 TEST SAMPLES , SEED =42, τ =0.8, TOP -p=0.95, VERIFIER - FIRST RERANKING ). 95% W ILSON CONFIDENCE INTERVALS REPORTED . C OLUMN s/circ IS AVERAGE WALL - CLOCK LATENCY PER CIRCUIT; 1–9g % IS EXACT- EQUIVALENCE RATE ON THE 1–9 TARGET- GATE BIN .

Strategy

n Exact %

95% CI

Avg Fid s/circ 1–9g %

Greedy Beam (w=5)

200 200

7.0 14.0

[4.2, 11.4] [9.9, 19.5]

0.103 0.194

0.2 1.3

62.5 87.5

Temp N =20 200 Len-band N =20 200 Temp N =50 200 Len-band N =50 200 Temp N =100 200 Len-band N =100 200 Hybrid N =100 200

17.0 13.5 19.0 15.5 21.0 18.0 21.5

[12.4, 22.8] [9.4, 18.9] [14.2, 25.0] [11.1, 21.2] [15.9, 27.2] [13.3, 23.9] [16.4, 27.7]

0.260 0.225 0.301 0.262 0.333 0.299 0.326

4.1 3.6 10.3 9.0 21.1 19.6 20.5

87.5 87.5 87.5 87.5 87.5 87.5 87.5

Exact equivalence rate (%)

Inference-time compute scaling improves exact equivalence. Greedy decoding achieves 7.0% exact equivalence on 200 test samples. Beam search (w=5) raises this to 14.0%— Temp N =200 200 22.5 [17.3, 28.8] 0.360 45.1 87.5 doubling the success rate. Temperature sampling with N =100 candidates and verifier-first reranking reaches 21.0%, while 30 hybrid search (pooling diverse strategies) achieves 21.5%— a >3× improvement over greedy. Scaling plain temperature 25 beyond N =100 yields diminishing returns: Temp N =200 reaches only 22.5% (Table III), adding 1.5 pp over Temp 20 N =100 at >2× the latency (45 s vs. 21 s)—the same pass@k saturation pattern observed in code generation [34]. 15 Length conditioning hurts; pooled diversity barely helps. Despite 87% of failures involving wrong output length, length10 Greedy banded sampling underperforms plain temperature at every Beam Temperature budget (N =100: 18.0% vs. 21.0%). Hybrid pooling across 5 Length-banded multiple temperatures and length conditions reaches 21.5% Hybrid Ensemble at N =100, but the 0.5 pp gain over plain temperature lies 0 0 10 20 30 40 50 within its Wilson interval; the dominant lever is raising N , not Avg. inference time per circuit (seconds) diversifying the sampling distribution. Beam search saturates around w=10. A sweep over beam 3. Quality–latency Pareto frontier for Clifford+T optimization. Each widths w ∈ {1, 2, 3, 5, 10, 20} on 200 test samples shows Fig. point represents a (strategy, candidate budget) configuration evaluated on 200 monotonic improvement with diminishing marginal returns test samples. Inference-time compute scaling monotonically improves exact above w=10: 7.0% (w=1, greedy) → 14.0% (w=5) → 18.0% equivalence for temperature sampling. (w=10) → 19.5% (w=20), capturing roughly half of the >3× gain achievable by temperature sampling at N =100. The plateau reflects beam search exploring a narrow high- latency (0.2–21 s) for a >3× improvement in exact equivalence probability region rather than the diverse candidates needed to (7% to 21.5%). overcome early-token errors. D. T-Count Prediction Accuracy The model’s distributional knowledge is accurate. Across all Table IV confirms distributional accuracy on 200 test strategies, predicted T -count closely matches the PyZX target— 2.89 vs. 2.83 for greedy on 200 samples (Table IV)—and every samples: predicted T -count (2.89 greedy, 2.89 beam) closely generated circuit is a structurally valid Clifford+T sequence. matches the PyZX target (2.83), with a slight tendency toward The model has learned what optimized circuits look like in over-prediction—the model occasionally retains one extra aggregate, even when it fails to produce the correct circuit for T gate. Input circuits average 8.10 T -gates; the predicted average (2.89) corresponds to ∼64% reduction in aggregate, a given input. matching the PyZX target distribution (2.83, ∼65% reduction). C. Quality–Latency Tradeoff The limitation is not optimization quality (comparable to PyZX) Figure 3 shows the quality–latency Pareto frontier. Two but the reliability of producing exactly correct circuits. operating points emerge: temperature N =50 (19% exact, To quantify the realized optimization—not just distributional ∼10 s/circuit) for throughput-oriented batch use, and hybrid accuracy—we isolate the subset of outputs verified equivalent search N =100 (21.5%, ∼21 s/circuit) when correctness is to the input unitary (F >0.999) and measure the reduction prioritized; greedy (∼0.2 s) and beam (∼1.3 s) are faster at they achieve. On this subset the model attains PyZX-quality lower accuracy. The tradeoff spans two orders of magnitude in optimization: greedy reduces the average T -count from 5.50

Metric

Greedy

Beam

Valid circuits Avg. input T-count Avg. target T-count (PyZX) Avg. predicted T-count

100% 8.10 2.83 2.89

100% 8.10 2.83 2.89

TABLE V E XACT EQUIVALENCE RATE (%) BY TARGET CIRCUIT LENGTH (200 TEST SAMPLES ). S HORT CIRCUITS (≤9 GATES ) ARE RELIABLY OPTIMIZED ; LONG CIRCUITS (≥15 GATES ) REMAIN CHALLENGING ACROSS ALL STRATEGIES .

Strategy

1–9

10–14

15–25

26+

Greedy Beam (w=5) Temp. N =100 Hybrid N =100

62.5 87.5 87.5 87.5

8.0 22.0 38.0 44.0

0.0 2.8 8.4 6.5

0.0 0.0 0.0 0.0

to 1.64 (a 64% reduction) and total gate count by 70% (beam: 61% and 68%). In 100% of verified cases the predicted T -count equals the PyZX target—the model never produces a worse optimization on a circuit it solves, but it also does not discover reductions beyond PyZX. Notably, the verified-equivalent rate coincides with the exact-match rate: every circuit the model optimizes correctly matches PyZX’s T -count. The optimization quality on solved instances is therefore not the bottleneck; the binding constraint is the reliability of producing an exactly correct circuit in the first place, which Section VII traces to autoregressive drift. VII. FAILURE A NALYSIS

100

Exact equivalence rate (%)

TABLE IV M ODEL PREDICTION QUALITY: THE TRANSFORMER LEARNS THE T- COUNT DISTRIBUTION OF OPTIMIZED CIRCUITS (3–6 QUBITS , 200 SAMPLES ).

200K greedy 200K beam 200K temp N=100

500K greedy 500K beam 500K temp N=100

80 60 40 20 0

19

10 14

15 25

Target gate count bin

26+

Fig. 4. Exact equivalence rate by target gate-count bin for both the 200K baseline (lighter bars) and 500K model (darker, hatched bars). Data scaling improves all length bins substantially, but the degradation pattern persists: performance drops sharply with target length across all configurations.

Fig. 5. Autoregressive drift illustrated. The model matches the first few tokens (green) but diverges early (red X), after which every subsequent token is conditioned on wrong context. The Clifford+T fidelity distribution is bimodal (F ≈ 0 or F ≈ 1), whereas parameterized fidelity is smooth and recoverable via angle post-processing.

A. Length Is the Dominant Failure Predictor Table V and Figure 4 break down exact-match rates by target circuit length (gates in the PyZX-optimized reference); the pattern is striking:

B. Autoregressive Drift: Root Causes

Detailed per-sample diagnostics on the 200-sample evaluation subset reveal three root causes (Figure 5): • 1–9 gates: 62.5% (greedy) to 87.5% (beam). The model Wrong sequence length. 87% of failed predictions produce handles short circuits reliably. incorrect-length output, with an average deviation of ∼3 gates • 10–14 gates: 8.0% (greedy) to 44.0% (hybrid N =100). (∼7 tokens). Only 13% of predictions match the target length Performance drops sharply at the transition from single-digit exactly; however, most length errors are modest (1–5 gates), to double-digit gate counts. indicating the model captures approximate output length but • 15–25 gates: 0% (greedy) to 8.4% (temperature N =100). diverges in gate-level details. Inference-time scaling provides only marginal improvement. Early divergence. The median first-error position is at 3.13% • 26+ gates: 0% across all strategies. No configuration achieves of the target sequence—within the first 1–2 gates; the 10th any exact matches. percentile is at 1.1%. Token-level accuracy analysis on 500 Critically, qubit count is a much weaker predictor than test samples confirms the rapidity of divergence (Figure 7): length. On the full 500-sample test set under greedy decoding, the very first content token (position 1, after BOS) is correct per-qubit exact-match rates span a narrow range (3q: 8.0%, only 56.2% of the time, and accuracy continues to decline, 4q: 7.2%, 5q: 15.2%, 6q: 13.6%); under the same greedy reaching 16.0% by position 30. Once an incorrect gate or protocol on the 200-sample subset, length-bin rates range from qubit is emitted, every subsequent token is conditioned on 62.5% (1–9 gates) to 0% (26+ gates), confirming that the wrong context, producing a cascading error that never recovers dominant bottleneck is sequence length rather than problem (Figure 6b). Crucially, this pattern persists even with 2.5× dimensionality. training data (500K). On the 500-sample drift-analysis subset,

(a) Success 3-qubit, 6 target gates Target

BOS

H

q0

T

q1

H

q1

S

q1

T

q2

Predicted

BOS

H

q0

T

q1

H

q1

S

q1

T

0

1

2

3

4

5

6

7

8

9

X

q2

EOS

q2

X

q2

EOS

10

11

12

13

(b) Failure 3-qubit, 11 target gates (first error at position 8)

extra tokens

Target BOS CX q2 q1 S q2 H q2 S q2 T q2 CX q1 q0 S q1 H q1 S q0 CX q2 q0 H q2 EOS first error

Predicted BOS CX q2 q1 S q2 H q2 T q2 S q2 CX q1 q0 S q1 H q1 S q0 CX q2 q0 H q2 S q2 H q2 EOS 0

1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Fig. 6. Concrete example from evaluation data. (a) A short 3-qubit circuit (6 target gates) predicted exactly. (b) A longer circuit (11 target gates) where the model matches the first 8 tokens but swaps S↔T at position 8, triggering cascading errors and extra trailing tokens.

Token-position accuracy (greedy decoding)

Token accuracy (%)

100 80 60 40 20

500K pos 1: 63.2%

200K pos 1: 56.2%

44.8M (200K data) 133.6M (200K data) 44.8M (500K data)

bimodal: circuits cluster at F ≈ 1.0 or F ≈ 0, with virtually nothing between. This contrasts with parameterized results (Section VI-A), where a smooth fidelity distribution improves substantially via angle post-processing. The contrast isolates the mechanism: the transformer makes similar early-sequence errors in both settings, but parameterized outputs can be rescued by refitting angles, whereas a single wrong discrete gate irreversibly corrupts the unitary. No post-processing can recover from such errors in the discrete setting. We term this combination autoregressive drift: Definition. Autoregressive drift is a failure mode of left-toright sequence generation in which an early-token prediction error propagates through the conditioning context, causing all subsequent tokens to diverge from the target—irrecoverably when the output domain is discrete. The mechanism explains why scaling N helps: each temperature sample independently avoids (or fails to avoid) the initial divergence, and the verifier selects any successful candidate. For a circuit with per-sample success probability p, the probability of at least one success in N trials is 1−(1−p)N , which saturates once N p ≫ 1. This yields a two-part pattern: (i) for circuits with p > 0, modest N =50–100 drives per-circuit success close to 1; (ii) the 88% ceiling on the 1–9 gate bin reflects the fraction of solvable short circuits—the ∼12% remainder have p ≈ 0, and no candidate budget rescues them. The failure mode is thus not “almost right” but complete early divergence.

Samples

VIII. I NTERVENTIONS Given the autoregressive drift diagnosis, we tested five 0 targeted interventions spanning training-time fine-tuning, 44.8M (200K) inference-time compute, model diversity, and data scaling 400 133.6M (200K) 44.8M (500K) (Table VI). Each targets a specific hypothesis about the root 200 cause; all evaluations use the same locked protocol and test 0 subset as the baseline. 0 20 40 60 80 M1: Long-only fine-tuning. Hypothesis: concentrating Token position in output sequence training on long circuits will improve the 15–25 gate bin. Method: fine-tune the 200K baseline for 5 epochs on the ≥15Fig. 7. Token-position accuracy under greedy decoding (500 test samples). −4 All three models—44.8M (200K), 133.6M (200K), and 44.8M (500K)—show gate subset (151,328 samples, lr = 10 ). Result: at Temp the same degradation shape. Data scaling (500K) raises the curve uniformly N =100, 22.5% exact on 200 test samples (vs. 21.0% baseline), (e.g., 56% → 63% at position 1) but does not change the slope of decline. and the targeted 15–25 gate bin is unchanged at 8.4% (9/107). Neither model scaling (3× parameters) nor data scaling (2.5× data) alleviates M2: Weighted sampling. Hypothesis: upweighting long the drift. circuits while preserving the full distribution avoids catastrophic forgetting. Method: fine-tune 3 epochs on the full 200K set the 500K model nearly doubles greedy exact match from with 2× oversampling of ≥15-gate examples (lr = 5 × 10−5 ). 11.0% to 22.2% and improves first-token accuracy from 56.2% Result: 20.0% exact on 200 samples (vs. 21.0% baseline); to 63.2%.3 Yet the 500K model’s median first-error position 15–25 gates drops to 7.5% (8/107). (3.57% of the target sequence) is statistically indistinguishable M3: Hybrid search. Hypothesis: pooling candidates from from the 133.6M model’s (3.59%) and from the 200K baseline’s diverse strategies increases the probability of finding a correct (3.13%), and all three position-accuracy curves share the same one. Method: generate at τ ∈ {0.75, 0.85, 0.95} from both shape (Figure 7). Data scaling helps the model “get it right length-banded and plain sampling, pool N =100 total, apply from the start” more often, but does not alter the cascading verifier-first reranking. Result: 21.5% exact equivalence on nature of drift once an error occurs. 200 test samples (vs. 21.0% for plain temperature at N =100). Bimodal fidelity distribution. Clifford+T fidelity is strongly Conclusion: pooling candidates from diverse strategies provides only marginal improvement in correct-candidate diversity. 3 These 500-sample drift numbers complement the 200-sample protocol used M4: Model ensemble. Hypothesis: pooling candidates from for tables III to VII; the corresponding 200-sample greedy rates are 7.0% (200K) and 18.5% (500K). architecturally diverse models yields more diverse correct

TABLE VI I NTERVENTIONS VS . BASELINE . F INE - TUNING (M1, M2), HYBRID SEARCH (M3), AND MODEL ENSEMBLING (M4) YIELD ONLY MARGINAL GAINS ON THE 15–25 GATE BIN ; ONLY 2.5× TRAINING DATA (M5) PRODUCES SIGNIFICANT IMPROVEMENT, YET THE DRIFT- DRIVEN LENGTH DEGRADATION PERSISTS ( CF. TABLE VII).

TABLE VII E FFECT OF TRAINING DATA SCALE (200K → 500K, SAME 44.8M ARCHITECTURE ). 2.5× MORE DATA IMPROVES ALL METRICS SUBSTANTIALLY, YET THE DRIFT- DRIVEN DEGRADATION WITH TARGET LENGTH PERSISTS .

(a) Overall exact equivalence (%) by strategy Intervention

Setting

n Exact % 15–25g %

Baseline (44.8M, 200K)

Temp N =100

200

21.0

8.4

M1: Long-only FT M2: Weighted sampling

Temp N =100 Temp N =100

200 200

22.5 20.0

8.4 7.5

M3: Hybrid search N =100 pooled 200 M4: Ensemble (2×model) N =100/model 200

21.5 24.5

6.5 —

39.5

23.4

M5: 2.5× data (500K)

Temp N =100

200

Strategy

n

Greedy 200 Beam (w=5) 200 Temp N =100 200

200K 500K 7.0 14.0 21.0

18.5 27.0 39.5

∆ +11.5 +13.0 +18.5

(b) Temp N =100: exact equivalence (%) by target length Gates

200K 500K

1–9 10–14 15–25 26+

87.5 38.0 8.4 0.0

93.8 76.0 23.4 3.7

∆ +6.3 +38.0 +15.0 +3.7

+1.5pp (2× cost)

Exact equivalence rate (%)

Exact equivalence rate (%)

circuits than a single model at the same budget. Method: All configurations evaluated on 200 test samples. generate N =100 candidates from each of two models (44.8M and 133.6M parameters, 200 total) at τ =0.8, pool, apply (a) Candidate budget scaling (b) Beam width sweep 45 25 verifier-first reranking (200 test samples). Result: 24.5% exact 40 20 35 equivalence—above hybrid search (21.5%) at the same total 30 w=5 15 25 budget, and marginally above single-model N =200 temper20 10 ature sampling (22.5%). Conclusion: architecturally diverse 15 200K temp. 10 5 500K temp. models do not produce meaningfully more diverse correct 200K hybrid 5 200K ensemble 0 0 candidates, suggesting model errors are correlated across 1 5 20 50 100 200 500 1 2 3 5 10 20 Beam width (w) Candidate budget (N) architectures trained on the same data. M5: Training data scaling (2.5×). Hypothesis: the model Fig. 8. Exact equivalence rate vs. candidate budget N . Both the 200K baseline is data-limited; more training examples will improve per- and 500K model improve monotonically with more candidates but exhibit sample success probability. Method: generate 500K Clifford+T strong diminishing returns. Data scaling (2.5×) shifts the entire curve upward, training pairs (2.5× the original 200K) with the same pipeline providing larger gains than any inference-time strategy alone. (Section IV-C), train the identical 44.8M architecture, and evaluate all strategies on 200 test samples. Result: data scaling Summary. Only data scaling (M5) yields meaningful gains; produces significant gains across all strategies (Table VII): M1–M4 leave the 15–25 gate bin near the 8.4% baseline. greedy improves from 7.0% to 18.5% (2.6×), beam from Figure 8 shows the scaling relationship between candidate 14.0% to 27.0% (1.9×), and temperature N =100 from 21.0% budget and exact-equivalence rate for both the 200K baseline to 39.5% (1.9×)—an absolute gain of 11–19 pp at every and the 500K model. Temperature sampling improves monooperating point. The improvement extends to longer circuits: tonically as N increases but with strong diminishing returns: exact equivalence on the 15–25 gate bin rises from 8.4% to the 200K model gains only 1.5 percentage points from N =100 23.4%, and for the first time a non-zero result appears on to N =200 (21.0% → 22.5%), and even N =500 reaches only circuits with 26+ gates (3.7%, i.e., one out of 27). Conversely, 28.0% on a 50-sample subset. The 500K model exhibits the reducing data below 200K reveals a sharp cliff: models trained same diminishing-returns pattern at a uniformly higher level: on 50K and 100K samples achieve 0% exact equivalence across N =200 achieves 38.5% (vs. 39.5% at N =100), and N =500 all strategies (200 test samples), despite training to convergence. reaches only 40.0% (also on a 50-sample subset)—suggesting a Conclusion: the model is not data-saturated, and more training practical ceiling of ∼40% for the current architecture and data examples improve the per-sample success probability p that scale. Hybrid search achieves the best 200K result at N =100 drives both greedy accuracy and the effectiveness of candidate- (21.5%), but is surpassed by the 500K model at every budget. based search. A sharp transition occurs between 100K (0%) and 200K (≥7%) training pairs; the precise threshold lies in IX. D ISCUSSION this interval but we did not characterize it further. Crucially, however, the drift-driven degradation pattern persists: even with A. Inference-Time vs. Training-Time Compute 2.5× data, exact equivalence still drops from 94% (≤9 gates) For tasks requiring exact correctness with efficient verifiers, to 3.7% (26+ gates)—a 25× degradation ratio. Token-level scaling inference-time compute provides reliable gains over drift analysis confirms this: the 500K model’s median first-error greedy decoding [31], [35]—but scaling training data provides position (3.57% of the sequence) is comparable to the 200K larger gains still: the 2.5× data experiment (M5) nearly doubles baseline (3.13%), and the position-accuracy curve (Figure 7) exact equivalence at every operating point, while fine-tuning on shifts upward uniformly without changing slope. the same 200K data (M1, M2) is statistically indistinguishable (paper default)

from the baseline. This suggests that the per-sample success probability p is the fundamental quantity: data scaling increases p, amplifying subsequent inference-time search. The structural requirement is verification asymmetry: unitary comparison (O(4n ), ∼0.1 ms for 6 qubits) is orders of magnitude faster than autoregressive generation (∼0.2 s per candidate), so the verifier scales freely with N . B. Practical Deployment Considerations The model’s strength on short circuits (e.g., ∼74% exact equivalence for the 500K model on ≤14-gate subcircuits) maps directly to peephole optimization in classical compilers. Production tools like Qiskit [36], tket [37], and MQT [38] decompose circuits into small subcircuits (2–4 qubits, 5–15 gates) and optimize each independently. A model with 100% structural validity and 62–88% exact equivalence on this range can serve as a complementary optimization pass: invoke it on matching subcircuits, fall back to PyZX on verification failure. C. Comparison with PyZX PyZX achieves 100% exact equivalence at ∼6 ms per circuit— faster and more reliable than our model at every operating point. We do not position the learned model as a replacement; the contributions are diagnostic (identifying autoregressive drift as the bottleneck), methodological (establishing inference-time scaling and data scaling as the most effective levers), and empirical (a reproducible benchmark with explicit operating points). The long-term potential of learned models lies in discovering patterns not captured by existing identities; whether the model’s learned rewrites extend beyond PyZX’s repertoire is best tested on circuit families where PyZX is known to be suboptimal. D. Relation to Drift in Other Domains Autoregressive drift shares the mechanism of exposure bias in neural machine translation [39], [40], but the consequence differs: translation errors degrade quality smoothly, whereas a single wrong discrete gate irreversibly corrupts the unitary—the bimodal F ≈ 0 vs. F ≈ 1 regime of Section VII, with no partial credit. This also explains why pass@k scaling, effective in code generation [35], [34], saturates earlier here: code training enjoys partial-credit feedback (compile errors, failing tests) that Clifford+T pairs lack, so mitigations such as execution-guided decoding must be reformulated without that gradient-shaping signal. X. L IMITATIONS AND F UTURE W ORK All strategies are evaluated on 200 test samples; the 95% Wilson confidence interval for a 20% rate at n=200 spans ±6 percentage points. Exact equivalence on circuits with ≥15 target gates remains below 9% for the 200K model; the 500K model pushes this to 23.4% on 15–25 gates but still reaches only 3.7% on 26+ gates. Breaking this ceiling likely requires departing from pure autoregressive decoding—for example, non-autoregressive decoders [41] that generate all tokens in parallel with iterative

refinement, subcircuit decomposition with a keep/remove gate mask, or peephole windowing that operates within the model’s high-accuracy regime. Our contribution is a diagnosis, not a leaderboard entry, so we compare only against the PyZX oracle; head-to-head comparisons with other ML approaches (genQC [20], RL methods [22], [21]) are confounded by differing gate sets, input representations, and objectives. Our results are likewise conditioned on the training distribution—random circuits with injected redundancy optimized by PyZX—so generalization to circuits emitted by production compilers remains untested. The more pointed question—whether non-autoregressive architectures (discrete diffusion, MCTS, iterative refinement) escape the drift failure mode—is a direct target for future work. Model scaling. Primary experiments use a 44.8M-parameter model on a single MI300X accelerator. A 133.6M-parameter variant (dmodel =768, h=12, 8+8 layers) improves greedy to 9.5% and beam to 16.5% (vs. 7.0%/14.0% for 44.8M), but ensembling it with the 44.8M model (M4) yields only 24.5%— within the Wilson interval of single-model Temp N =200 (22.5%)—so capacity scaling has diminishing returns without additional data. Qubit scaling. All experiments use 2–6 qubits (unitaries ≤ 64 × 64), where verification is trivial. Scaling to 7–10 qubits is feasible, but beyond ∼12 qubits explicit unitary computation becomes prohibitive, breaking the generate-and-verify strategy that underlies both training-data validation and inference-time reranking and requiring symbolic equivalence checking [42]. XI. C ONCLUSION We studied transformer-based quantum circuit optimization across two settings. On parameterized circuits, decoupling structure prediction from angle optimization achieves median fidelity 1.000 on 3–6 qubit circuits. On Clifford+T circuits, where all gates are discrete, exact equivalence is limited by autoregressive drift—early-token divergence cascading through left-to-right decoding—with target length as the dominant failure predictor. The contrast is our central finding: approximate outputs can be rescued by classical post-processing, but exact discrete correctness cannot—inference-time search (22.5%) and data scaling (39.5%) help, while fine-tuning, candidate pooling, and model-level diversification add only marginal gains. The length-dependent degradation persists across all conditions (94% on short circuits, <4% beyond 26 gates, even with 2.5× data), marking autoregressive drift as the key bottleneck for learned quantum circuit compilation. ACKNOWLEDGMENT The authors acknowledge the use of PyZX [3] and Qiskit [36] for training-data generation and verification. LLM-based coding assistants were used for code scaffolding and editorial refinement; all AI-assisted content was reviewed and verified by the authors.

R EFERENCES [1] E. T. Campbell, B. M. Terhal, and C. Vuillot, “Roads towards faulttolerant universal quantum computation,” Nature, vol. 549, pp. 172–179, 2017. [2] S. Bravyi and A. Kitaev, “Universal quantum computation with ideal Clifford gates and noisy ancillas,” Physical Review A, vol. 71, no. 2, p. 022316, 2005. [3] A. Kissinger and J. van de Wetering, “PyZX: Large scale automated diagrammatic reasoning,” in Proceedings of QPL 2020, ser. EPTCS, vol. 318, 2020, pp. 229–241. [4] M. Amy, D. Maslov, and M. Mosca, “Polynomial-time T-depth optimization of Clifford+T circuits via matroid partitioning,” IEEE Transactions on Computer-Aided Design, vol. 33, no. 10, pp. 1476–1489, 2014. [5] Y. Nam, N. J. Ross, Y. Su, A. M. Childs, and D. Maslov, “Automated optimization of large quantum circuits with continuous parameters,” npj Quantum Information, vol. 4, no. 1, p. 23, 2018. [6] L. E. Heyfron and E. T. Campbell, “An efficient quantum compiler that reduces T count,” Quantum Science and Technology, vol. 4, no. 1, p. 015004, 2018. [7] D. Maslov, G. W. Dueck, D. M. Miller, and C. Negrevergne, “Quantum circuit simplification and level compaction,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 27, no. 3, pp. 436–444, 2008. [8] D. Maslov, G. W. Dueck, and D. M. Miller, “Toffoli network synthesis with templates,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 24, no. 6, pp. 807–817, 2005. [9] V. Kliuchnikov, D. Maslov, and M. Mosca, “Asymptotically optimal approximation of single qubit unitaries by Clifford+T circuits using a constant number of ancillary qubits,” Physical Review Letters, vol. 110, no. 19, p. 190502, 2013. [10] N. J. Ross and P. Selinger, “Optimal ancilla-free Clifford+T approximation of z-rotations,” Quantum Information and Computation, vol. 16, no. 11–12, pp. 901–953, 2016. [11] D. M. Miller, D. Maslov, and G. W. Dueck, “A transformation based algorithm for reversible logic synthesis,” in Proceedings of the 40th Annual Design Automation Conference (DAC), 2003, pp. 318–323. [12] M. Saeedi and I. L. Markov, “Synthesis and optimization of reversible circuits—a survey,” ACM Computing Surveys, vol. 45, no. 2, pp. 1–34, 2013. [13] V. V. Shende, S. S. Bullock, and I. L. Markov, “Synthesis of quantumlogic circuits,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 25, no. 6, pp. 1000–1010, 2006. [14] M. Arabzadeh, M. Saeedi, and M. S. Zamani, “Rule-based optimization of reversible circuits,” in 15th Asia and South Pacific Design Automation Conference (ASP-DAC), 2010, pp. 849–854. [15] M. Soeken, R. Wille, G. W. Dueck, and R. Drechsler, “Window optimization of reversible and quantum circuits,” in IEEE Symposium on Design and Diagnostics of Electronic Circuits and Systems (DDECS), 2010, pp. 431–435. [16] M. Amy, D. Maslov, M. Mosca, and M. Roetteler, “A meet-in-themiddle algorithm for fast synthesis of depth-optimal quantum circuits,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 32, no. 6, pp. 818–830, 2013. [17] A. Zulehner, A. Paler, and R. Wille, “An efficient methodology for mapping quantum circuits to the IBM QX architectures,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 38, no. 7, pp. 1226–1236, 2019. [18] C. Yu, V. Uotila, S. Deng, Q. Wu, T. Shi, S. Jiang, L. You, and B. Zhao, “QUASAR: Quantum assembly code generation using tool-augmented LLMs via agentic RL,” arXiv preprint arXiv:2510.00967, 2025. [19] A. Cross, A. Javadi-Abhari, T. Alexander, N. de Beaudrap, L. S. Bishop, S. Heidel, C. A. Ryan, P. Sivarajah, J. Smolin, J. M. Gambetta, and B. R. Johnson, “OpenQASM 3: A broader and deeper quantum assembly language,” ACM Transactions on Quantum Computing, vol. 3, no. 3, pp. 12:1–12:50, 2022. [20] F. Fürrutter, G. Muñoz-Gil, and H. J. Briegel, “Quantum circuit synthesis with diffusion models,” Nature Machine Intelligence, vol. 6, pp. 515–524, 2024. [21] S. Rietsch, A. Y. Dubey, C. Ufrecht, M. Periyasamy, A. Plinge, C. Mutschler, and D. D. Scherer, “Unitary synthesis of Clifford+T circuits with reinforcement learning,” arXiv preprint arXiv:2404.14865, 2024.

[22] D. Kremer, V. Villar, H. Paik, I. Duran, I. Faro, and J. Cruz-Benito, “Practical and efficient quantum circuit synthesis and transpiling with reinforcement learning,” arXiv preprint arXiv:2405.13196, 2024. [23] F. J. R. Ruiz, T. Laakkonen, J. Bausch, M. Balog, M. Barekatain, F. J. H. Heras, A. Novikov, N. Fitzpatrick, B. Romera-Paredes, J. van de Wetering, A. Fawzi, K. Meichanetzidis, and P. Kohli, “Quantum circuit optimization with AlphaTensor,” arXiv preprint arXiv:2402.14396, 2024. [24] J. Dai, M. Rizvi-Martel, and G. Rabusseau, “FlowQ-Net: A generative framework for automated quantum circuit design,” arXiv preprint arXiv:2510.26688, 2025. [25] M. Xu, Z. Li, O. Padon, S. Lin, J. Pointing, A. Hirth, H. Ma, J. Palsberg, A. Aiken, U. A. Acar, and Z. Jia, “Quartz: Superoptimization of quantum circuits,” in Proceedings of the 43rd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2022, pp. 625–640. [26] A. Paradis, J. Dekoninck, B. Bichsel, and M. Vechev, “Synthetiq: Fast and versatile quantum circuit synthesis,” Proceedings of the ACM on Programming Languages, vol. 8, no. OOPSLA1, p. 96, 2024. [27] R. Rasconi and A. Oddi, “An innovative genetic algorithm for the quantum circuit compilation problem,” in Proceedings of the AAAI Conference on Artificial Intelligence, vol. 33, no. 01, 2019, pp. 7707–7714. [28] L. Arufe, M. A. González, A. Oddi, R. Rasconi, and R. Varela, “Quantum circuit compilation by genetic algorithm for quantum approximate optimization algorithm applied to MaxCut problem,” Swarm and Evolutionary Computation, vol. 69, p. 101030, 2022. [29] H. Wakaura and T. Tomono, “Genetic-multi-initial generalized VQE: Advanced VQE method using genetic algorithms then local search,” arXiv preprint arXiv:2109.02009, 2021. [30] L. Theißinger, T. Gerlach, D. Berghaus, and C. Bauckhage, “Beyond reinforcement learning: Fast and scalable quantum circuit synthesis,” arXiv preprint arXiv:2602.15146, 2026. [31] C. Snell, J. Lee, K. Xu, and A. Kumar, “Scaling LLM test-time compute optimally can be more effective than scaling model parameters,” arXiv preprint arXiv:2408.03314, 2024. [32] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin, “Attention is all you need,” Advances in Neural Information Processing Systems, vol. 30, 2017. [33] A. Holtzman, J. Buys, L. Du, M. Forbes, and Y. Choi, “The curious case of neural text degeneration,” in International Conference on Learning Representations (ICLR), 2020. [34] B. Brown, J. Juravsky, R. Ehrlich, R. Clark, Q. V. Le, C. Ré, and A. Mirhoseini, “Large language monkeys: Scaling inference compute with repeated sampling,” in Advances in Neural Information Processing Systems (NeurIPS), 2024. [35] M. Chen, J. Tworek, H. Jun, Q. Yuan, H. P. de Oliveira Pinto, J. Kaplan et al., “Evaluating large language models trained on code,” arXiv preprint arXiv:2107.03374, 2021. [36] Qiskit Contributors, “Qiskit: An open-source framework for quantum computing,” 2024. [37] S. Sivarajah, S. Dilkes, A. Cowtan, W. Simmons, A. Edgington, and R. Duncan, “t|ket⟩: A retargetable compiler for NISQ devices,” Quantum Science and Technology, vol. 6, no. 1, p. 014003, 2021. [38] R. Wille, L. Berent, T. Forster, J. Kunasaikaran, K. Mato, T. Peham, N. Quetschlich, D. Rovara, A. Sander, L. Schmid, D. Schönberger, Y. Stade, and L. Burgholzer, “The MQT handbook: A summary of design automation tools and software for quantum computing,” in IEEE International Conference on Quantum Software (QSW), 2024, pp. 1–8. [39] S. Bengio, O. Vinyals, N. Jaitly, and N. Shazeer, “Scheduled sampling for sequence prediction with recurrent neural networks,” in Advances in Neural Information Processing Systems (NeurIPS), 2015. [40] M. Ranzato, S. Chopra, M. Auli, and W. Zaremba, “Sequence level training with recurrent neural networks,” in 4th International Conference on Learning Representations (ICLR), 2016. [41] J. Gu, J. Bradbury, C. Xiong, V. O. Li, and R. Socher, “Non-autoregressive neural machine translation,” in International Conference on Learning Representations (ICLR), 2018. [42] L. Burgholzer and R. Wille, “Advanced equivalence checking for quantum circuits,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, vol. 40, no. 9, pp. 1810–1824, 2021.

Record · ID 366309 · SHA-256 6e723d3f3a09e058
Retrieved via Conceptio — every document is proof-bundled with source, license, and retrieval metadata.