betaFeedback

WorksPhysics and Astronomy

Multimodal Generative Quantum Circuit Optimization with Verifier-Guided Reinforcement Learning

Abstract

Quantum circuit optimization replaces a circuit with an equivalent one using fewer costly operations: two-qubit gates, which dominate error on noisy hardware, and non-Clifford TT gates, which dominate fault-tolerant overhead. We formulate this task as graph-conditioned sequence-to-sequence generation and introduce \method{} (Graph-Augmented Fusion Transformer for Quantum circuit optimization), a multimodal GNN-Transformer that jointly encodes a source circuit's gate-token sequence and simplified ZX diagram in a Transformer encoder and autoregressively generates an optimized circuit. The model is first pretrained by supervised learning on millions of verified triples of a random source circuit, its simplified ZX diagram, and a target circuit optimized by PyZX. It is then fine-tuned by reinforcement learning: a verifier checks whether each generated circuit is equivalent to the reference circuit, and a reward function scores its gate-count reduction relative to that reference. We compare Group Relative Policy Optimization (GRPO) with Maximum-Likelihood Reinforcement Learning (MaxRL), whose binary-reward objective we generalize to continuous non-negative rewards, and propose a Hybrid advantage estimator that combines the strengths of both. A size curriculum further extends training from short (20–100-gate) circuits up to 300 gates on 5–20 qubits. On held-out benchmarks, verifier-guided RL with curriculum training raises equivalence accuracy (pass@8) on 20–100-gate circuits from 67.7%67.7\% under supervised learning to 94.1%94.1\% while surpassing PyZX in two-qubit gate reduction and nearly matching its TT-gate counts, and scales optimization to 300-gate circuits while generalizing to deeper unseen circuits.

Keywords

quantum circuit optimization, quantum compilation, ZX-calculus, sequence-to-sequence learning, graph neural networks, reinforcement learning, GRPO, maximum-likelihood RL

Introduction

Quantum computers promise speedups for problems such as integer factoring [1], unstructured search [2], and the simulation of quantum many-body systems and molecules [3]. Over the past decade the hardware has moved from proof-of-principle devices to processors with tens to hundreds of qubits. The first logical-qubit experiments have demonstrated surface-code memories below the error-correction threshold [4] and programmable logical processors on neutral atoms [5]. At the same time, resource estimates for cryptographically relevant algorithms keep falling as algorithms and compilation improve [6, 7]. In both the noisy intermediate-scale quantum (NISQ) regime [8] and the emerging fault-tolerant regime, the gate count and gate composition of a compiled circuit largely determine whether execution is feasible in practice.

Turning an algorithm into operations on a device is the task of quantum compilation. A compiler translates a hardware-independent circuit into an executable one: it decomposes high-level operations into a native gate set, maps logical to physical qubits and inserts routing operations to respect connectivity [9, 10], and applies semantics-preserving optimizations such as peephole output. Production toolchains such as Qiskit [11], t|ket⟩ [12], and PyZX [13], together with formally verified optimizers such as VOQC [14], implement these stages as pipelines of passes. Their cost models depend on the regime. On NISQ hardware, two-qubit gates incur substantially higher error rates than single-qubit gates, so the two-qubit gate count largely determines circuit fidelity. Under fault tolerance, non-Clifford TT gates are intrinsically more resource-intensive than Clifford operations: the Eastin–Knill theorem precludes transversal TT in most codes [15], so TT gates generally require code switching [16] or magic state preparation techniques [17, 18, 19], making TT-count a dominant cost metric.

Within this compilation stack, circuit optimization seeks a circuit that implements the same unitary as the input, up to a global phase, while using fewer costly gates. This problem is computationally intractable: exact optimization is NP-hard in general, and even approximate optimization remains hard under natural cost metrics [20]. Moreover, circuit representations are highly non-unique: commuting gates can be reordered, identities can be inserted or cancelled anywhere, and a single unitary admits exponentially many implementations, so simplifications that are invisible locally may only emerge once distant gates are brought together. Every reduction in gate count directly lowers execution error on noisy hardware or resource overhead under fault tolerance, making circuit optimization a critical stage of quantum compilation.

Existing approaches to circuit optimization include rule-based rewriters and heuristic search methods [12, 14, 21, 22, 23, 24, 25, 26], ZX-calculus simplification [27, 28, 29, 30], reinforcement-learning methods that select sequential transformations [31, 32, 33, 34, 35, 36, 37], and generative models that synthesize an optimized circuit directly, among others. Generative models offer a key structural advantage: by synthesizing an optimized circuit end-to-end, they can directly capture global circuit structure. Transformers, in particular, process the entire input globally so that each output gate can depend on arbitrarily distant gates in the source. Diffusion and flow-based models synthesize circuits from target unitaries [38] or transport source circuits to optimized equivalents [39], while large language models have been fine-tuned to generate circuits [40]. However, purely generative approaches also face significant challenges: for autoregressive models, the accuracy of generating equivalent circuits drops rapidly as circuit length grows [41], and without an explicit correctness signal their output validity is difficult to guarantee.

In this work, we adopt an encoder–decoder Transformer framework for quantum circuit optimization. A circuit is naturally represented as a sequence of gate tokens (e.g., HAD_2, T_5, or CNOT_3_7) drawn from a finite vocabulary, similar to gate statements in Open-QASM [42]. Source and target circuits share this vocabulary, casting circuit optimization as a sequence-to-sequence (Seq2Seq) task. However, a plain Seq2Seq model is insufficient. First, a flat token sequence obscures the two-dimensional qubit connectivity of the source circuit. Second, autoregressive decoding suffers from error accumulation under supervised training alone [41].

We address both limitations with GraftQ and a post-training framework (Figure 1; headline results in Table 1) built on the following contributions:

Systempass@8all2QTTbetter (2Q)
PyZX reference [13]14.350.846.26
GraftQ (SFT)67.7%14.390.846.260.1%
GraftQ (SFT + Hybrid RL)83.5%15.711.076.2521.8%
GraftQ (+ Curriculum)94.1%15.811.076.2423.6%

Table 1. Table 1: Headline comparison on 9,000 held-out 20–100-gate circuits (5–20 qubits, K=8K = 8, T=0.2\mathcal{T} = 0.2). Gate reductions are relative to the source on the three-model common success set (ncom=5,574n_{\mathrm{com}} = 5{,}574; full breakdown in Table 5); better (2Q) is the fraction of each model’s solved circuits with strictly fewer 2Q gates than PyZX (§ 6.3).

GraftQ pipeline

Figure 1. GraftQ pipeline. Components introduced in this work are shaded lavender; standard steps and existing tools are shaded gray. (1) A random source circuit is simplified into a ZX diagram and extracted by PyZX to produce a reference circuit CrefC_{\mathrm{ref}}. (2) A GNN-Transformer takes both the source token sequence CsrcC_{\mathrm{src}} and the simplified ZX diagram DD as input and is pretrained to generate CrefC_{\mathrm{ref}}. (3) The pretrained policy is fine-tuned by RL: it samples GG candidate circuits per input, a random-state verifier tests whether each candidate is equivalent to CrefC_{\mathrm{ref}}, a reward function scores gate reduction relative to CrefC_{\mathrm{ref}}, and GRPO, continuous MaxRL, or the Hybrid advantage estimator updates the policy across a curriculum of increasing circuit sizes.

  • A multimodal GNN-Transformer (§ 3.2). Each source circuit is paired with its simplified ZX diagram, which captures the topological structure of the original circuit. A graph convolutional network embeds the nodes of the diagram, and its node embeddings are concatenated with the gate-token embeddings of the original circuit. A shared Transformer encoder then processes both modalities before an autoregressive decoder generates the optimized circuit.

  • RL with an automatic verifier (§ 3.4–§ 3.6). Circuit equivalence can be verified automatically, placing circuit optimization alongside mathematical reasoning and code generation, where verifiable rewards have enabled substantial gains through reinforcement learning [43, 44, 45]. Hence, we follow the pretrain-then-RL approach of modern language models [46] and fine-tune the pretrained model with a random-state verifier, which propagates a single Haar-random input state through each generated circuit and the reference circuit to test whether they are equivalent. The reward combines output-state fidelity (for incorrect candidates) with gate-count reduction relative to the reference (for verified candidates), strictly prioritizing equivalence over gate reduction.

  • Continuous MaxRL and a Hybrid advantage estimator (§ 3.6, Appendices B–C). We adapt GRPO [44] and MaxRL [47] to this graded reward, extending MaxRL from binary to continuous non-negative rewards. We further propose a Hybrid estimator that applies MaxRL weighting to groups containing incorrect candidates and GRPO normalization to all-correct groups, automatically shifting each input from learning equivalence to reducing gate count as accuracy improves.

  • Curriculum learning over circuit size (§ 4–§ 5). To further alleviate autoregressive drift, we train on millions of verified (source circuit, ZX diagram, PyZX reference) triples on 5–20 qubits with a two-stage curriculum over circuit size. Starting from circuits with 20–100 gates, the curriculum progressively extends training through 101–200 to 201–300 gates without degrading short-circuit accuracy, and we evaluate length generalization on unseen circuits with 301–400 gates.

Background and Related Work

Quantum circuits and their optimization

An nn-qubit pure state is a unit vector ∣ψ⟩∈Cd|\psi\rangle\in\mathbb{C}^{d} with d=2nd = 2^{n}, and a quantum gate acts on it by a unitary matrix [3]. A circuit C=(g1,…,gm)C = (g_{1}, \ldots, g_{m}) is a sequence of gates, each acting on one or more qubits, whose combined action is the d×dd \times d unitary U(C)=U(gm)⋯U(g1)U(C) = U(g_{m}) \cdots U(g_{1}). We work with the gate set

G={H,X,Z,S,T,RZ(ℓπ/4),CNOT,CZ},(1)\mathcal{G} = \{H, X, Z, S, T, R_{Z}(\ell\pi/4), \mathrm{CNOT}, \mathrm{CZ}\}, \tag*{(1)}

where RZ(α)=diag⁡(1,eiα)R_{Z}(\alpha) = \operatorname{diag}(1, e^{i\alpha}) is a ZZ-axis phase rotation and ℓ∈{1,2,3,5,6,7}\ell\in\{1, 2, 3, 5, 6, 7\}. This gate set covers both our source circuits and the circuits extracted by PyZX [13]. Up to global phase, S=RZ(π/2)S = R_{Z}(\pi/2), T=RZ(π/4)T = R_{Z}(\pi/4), and Z=RZ(π)Z = R_{Z}(\pi). Hadamard, SS, and CNOT generate the Clifford group, and adding the non-Clifford TT gate makes the set approximately universal (Clifford+TT) [17]. TT counts as non-Clifford every TT gate and every phase whose angle is an odd multiple of π/4\pi/4.

Two circuits are equivalent, written C≡C′C \equiv C', when their unitaries differ by at most a global phase:

C≡C′⟺∃φ:U(C)=eiφU(C′).(2)C \equiv C' \Longleftrightarrow\exists\varphi: U(C) = e^{i\varphi} U(C'). \tag*{(2)}

Let Nall(C)N_{\mathrm{all}}(C), N2q(C)N_{2q}(C), and NT(C)N_T(C) denote the total, two-qubit, and non-Clifford gate counts, and let κ(C)=wallNall(C)+w2qN2q(C)+wTNT(C)\kappa(C) = w_{\mathrm{all}}N_{\mathrm{all}}(C) + w_{2q}N_{2q}(C) + w_TN_T(C) be a cost with non-negative weights. GraftQ targets

C⋆∈arg⁡min⁡C′∈G⋆:C′≡C κ(C′),(3)C^\star\in\underset{C' \in\mathcal{G}^\star:C'\equiv C}{\arg\min}\ \kappa(C'), \tag*{(3)}

where G⋆\mathcal{G}^\star is the set of finite circuits over G\mathcal{G} on the same nn qubits. Optimizing individual gate counts in Clifford+TT circuits is NP-hard [20]. Even checking a candidate is hard: deciding worst-case approximate equivalence in operator norm (up to global phase) is QMA-complete [48], and a dense comparison of unitaries needs O(4n)O(4^n) memory. We therefore study a learned, amortized approach: a conditional generator proposes candidates, a verifier checks equivalence, and reinforcement learning rewards lower κ\kappa. Because the optimum of Eq. (3) is unknown, we measure progress against a PyZX reference Cref≡CC_{\mathrm{ref}} \equiv C using

Δk(C′)=Nk(Cref)−Nk(C′)Nk(Cref),k∈{all,2q,T},(4)\Delta_k(C') = \frac{N_k(C_{\mathrm{ref}})-N_k(C')}{N_k(C_{\mathrm{ref}})}, \qquad k \in\{\mathrm{all}, 2q, T\}, \tag*{(4)}

where positive values mean the generated circuit uses fewer gates than the reference.

The ZX-calculus represents a circuit as a graph of spiders with phases, connected by plain or Hadamard edges [27, 30]. Graphical rewrite rules preserve semantics and can remove large numbers of spiders, revealing global structure that a flat gate sequence obscures. Extracting a simplified diagram back into a circuit, however, is efficient when the diagram has generalized flow [49] but #P-hard in general [50], and extraction can introduce additional CNOT gates [51]. Rather than relying solely on direct circuit extraction as the final output, GraftQ conditions on the simplified diagram alongside the source circuit.

Related work on circuit optimization

Rule-based optimizers apply gate cancellation, commutation, peephole rewrites, and template matching [12, 14, 21, 22], while search-based superoptimizers such as Quartz, QUESO, Quanto, and GUOQ combine synthesized rewrite rules with heuristic search to explore equivalent circuits [23, 24, 25, 26]. ZX-calculus methods [28, 29] are among the strongest TT-count optimizers.

Reinforcement-learning methods learn which circuit transformation to apply next. Fösel et al. apply deep RL to local circuit rewrites [31]. Quarl learns a GNN policy over Quartz rewrites [32]. Several works act on ZX diagrams: GNN policies trained with PPO [52] choose ZX rewrites [34, 35], and tree search with GNNs finds CNOT-reducing combinations [36]. Kremer et al. train RL agents for Clifford-circuit synthesis and transpilation [33], and AlphaTensor-Quantum reduces TT-count through tensor decompositions [37]. These methods preserve equivalence by construction, but are bounded by their action libraries and rewrite-trajectory length.

A third line of work generates optimized circuits directly. Charton et al. train Transformers to rewrite ZX diagrams [53]. Diffusion models synthesize circuits from a target unitary [38] or transport source circuits to optimized equivalents [39]. LLMs have been fine-tuned to write and optimize quantum programs [40, 54]. Closest to our setting, Saeedi et al. find that the equivalence accuracy of autoregressive circuit generation drops sharply as output length grows [41].

Specifically, autoregressive sequence-to-sequence (Seq2Seq) models map an input sequence xx to an output sequence y=(y1,…,yL)y = (y_1, \ldots, y_L)

πθ(y∣x)=∏t=1Lπθ(yt∣y<t,x),(5)\pi_\theta(y \mid x) = \prod_{t=1}^{L} \pi_\theta(y_t \mid y_{<t}, x), \tag*{(5)}

parameterized here by an encoder–decoder Transformer [55]. Tokenizing gates on explicit qubits casts circuit optimization into this framework, where each input circuit admits many equivalent target sequences. Standard maximum-likelihood training against a single reference circuit, however, optimizes token-level cross-entropy rather than unitary equivalence or gate cost, penalizes alternative lower-cost implementations, and relies solely on a one-dimensional input sequence. These limitations motivate conditioning the encoder on ZX graph structure and post-training the generator with verifier-guided reinforcement learning (§ 3).

Model and Training

GraftQ is a conditional generator πθ(y∣x)\pi_\theta(y \mid x). The input x=(Csrc,D)x = (C_{\mathrm{src}}, D) pairs the token sequence of a source circuit with a ZX diagram DD of that circuit. The output yy is the token sequence of a candidate optimized circuit C^\hat{C}. This section describes how circuits and diagrams are encoded (§ 3.1), the GNN-Transformer (§ 3.2), masked decoding (§ 3.3), the verifier and reward (§ 3.4), supervised pretraining (§ 3.5), and reinforcement learning with GRPO, MaxRL, and Hybrid advantages (§ 3.6).

Circuit and diagram representation

For the circuit modality, each token represents one gate acting on explicit qubit indices: single-qubit gates NAME_q, two-qubit gates NAME_c_t (control, then target), and phase rotations RZ(l/4)_q. Combining {H,X,S,T,Z}\{H, X, S, T, Z\} (with HH, XX written HAD, NOT) and RZ(ℓπ/4)RZ(\ell\pi/4) (ℓ∈{1,2,3,5,6,7}\ell\in\{1, 2, 3, 5, 6, 7\}, reduced to lowest terms) across up to nmax⁡=20n_{\max}=20 qubits, CNOT and CZ on ordered qubit pairs, and four framing symbols (<pad>, <unk>, <bos>, <eos>) yields ∣V∣=984|V|=984 tokens (retaining overlapping gate notations so both CsrcC_{\mathrm{src}} and PyZX outputs map directly without rewrites). Source and target circuits share this vocabulary and are wrapped as <bos>g1⋯gmg_1 \cdots g_m<eos>; for instance, the three-qubit fragment H0H_0 CNOT0,1_{0,1} T1T_1 RZ(3π/4)2RZ(3\pi/4)_2 CZ1,2_{1,2} is tokenized as

<bos> HAD_0 CNOT_0_1 T_1 RZ(3/4)_2 CZ_1_2 <eos>.

Unlike subword-tokenized QASM text, this gate-level vocabulary keeps each gate and its qubits in a single symbol, sets sequence length to gate count plus two, and supports exact qubit-range masks (§ 3.3).

Each vertex vv of the simplified ZX diagram D=(V,E)D=(V,E) (§ 4) is represented by a (2nmax⁡+5)(2n_{\max}+5)-dimensional feature vector

fv=[etype(v)  ∥  bv  ∥  sin⁡αv,cos⁡αv],(6)\mathbf{f}_v = \left[\mathbf{e}_{\mathrm{type}(v)} \;\middle\Vert\; \mathbf{b}_v \;\middle\Vert\; \sin\alpha_v,\cos\alpha_v\right], \tag*{(6)}

concatenating a spider-type one-hot vector etype(v)\mathbf{e}_{\mathrm{type}(v)} (distinguishing Z spiders from other vertices), a boundary one-hot vector bv\mathbf{b}_v (identifying input qubit qq, output qubit qq, or an internal spider), and the sine and cosine of the spider phase αv\alpha_v.

GNN-Transformer

Figure 2 illustrates the model architecture: an encoder–decoder Transformer whose encoder processes two input modalities, analogous to vision–language models that pair a visual encoder with a language model [56], except that the second modality here is a graph.

GNN-Transformer architecture

Figure 2. GNN-Transformer architecture. A GCN embeds the ZX diagram and an embedding layer maps the source gate tokens to vectors. The two sequences are concatenated and encoded by a Pre-LN Transformer encoder. A Pre-LN decoder cross-attends to the encoder memory and generates the optimized circuit one token at a time (dashed: autoregressive feedback), with a qubit-count mask restricting outputs to valid gates.

In the graph branch, graph-convolutional (GCN) layers [57], each followed by a ReLU activation, map the node features fv\mathbf{f}_v to the model dimension dmodeld_{\mathrm{model}}. Each layer adds self-loops and aggregates messages along the edge-indexed edges in the edge index (providing a topological prior while CsrcC_{\mathrm{src}} supplies exact gate and boundary-Hadamard semantics), combining each vertex’s spider type, boundary indicator, and phase with features from neighboring spiders. Ordering vertices by PyZX index, the resulting node embeddings are packed into a sequence HD∈R∣V∣×dmodelH_D \in\mathbb{R}^{|V| \times d_{\mathrm{model}}}.

The source tokens of length SS are embedded and scaled as E=dmodelEmb⁡(Csrc)∈RS×dmodelE=\sqrt{d_{\mathrm{model}}}\operatorname{Emb}(C_{\mathrm{src}})\in\mathbb{R}^{S\times d_{\mathrm{model}}}, then concatenated with the graph embeddings along the sequence dimension:

X(0)=[HD;E]∈R(∣V∣+S)×dmodel,(7)X^{(0)} = [H_D; E] \in\mathbb{R}^{(|V|+S)\times d_{\mathrm{model}}}, \tag*{(7)}

with a padding mask over the combined sequence. X(0)X^{(0)} is processed by a stack of Pre-LN Transformer encoder layers [55, 58] followed by a final LayerNorm, producing the encoder memory MM. Rotary position embeddings (RoPE) [59] are applied in every self-attention layer across the concatenated sequence, allowing gate tokens and ZX spiders to attend to one another from the first layer onward.

The decoder is a stack of Pre-LN Transformer layers, each applying causal self-attention with RoPE, cross-attention to MM, and a feed-forward network. A linear output head produces logits zt∈R∣V∣z_t \in\mathbb{R}^{|V|}; encoder, decoder, and output embeddings are untied. Architectural hyperparameters (layer counts, attention heads, hidden dimensions, and total parameter count) are listed in Table 6. Supervised training uses teacher forcing on the shifted target sequence, πθ(yt∣y<t,x)=softmax⁡(zt)\pi_\theta(y_t \mid y_{<t}, x) = \operatorname{softmax}(z_t).

parametervalue
dmodeld_{\mathrm{model}}1024
encoder layers8
decoder layers8
attention heads16
head dimension dkd_k64
FFN width2048
FFN activationReLU
normalization positionPre-LN
position encodingRoPE (self-attention only)
dropout0
GCN layers4
GCN in-features2nmax⁡+5=452n_{\max}+5=45
GCN intermediate / out1024
vocab size ∣V∣|\mathcal{V}|984
max qubits nmax⁡n_{\max}20
total parameters≈174M

Table 6. Model architecture hyperparameters.

Decoding with validity masks

Because the vocabulary covers up to nmax⁡n_{\max} qubits, for an nn-qubit circuit (n<nmax⁡n < n_{\max}) any token acting on a qubit index q≥nq \ge n is invalid. For each nn we precompute the valid subset Vn⊂V\mathcal{V}_n \subset\mathcal{V} of tokens whose qubit indices are strictly less than nn (plus <eos>), and sample from the masked distribution

πθ(yt∣y<t,x)=1[yt∈Vn]exp⁡(zt,yt/T)∑v∈Vnexp⁡(zt,v/T)(8)\pi_\theta(y_t \mid y_{<t}, x) = \frac{\mathbf{1}[y_t \in\mathcal{V}_n]\exp(z_{t,y_t}/\mathcal{T})} {\sum_{v \in\mathcal{V}_n}\exp(z_{t,v}/\mathcal{T})} \tag*{(8)}

at temperature T\mathcal{T}. Restricting support to Vn\mathcal{V}_n (e.g., 95 active gate tokens at n=5n = 5) guarantees that every sampled sequence parses into a syntactically valid nn-qubit circuit. During RL rollouts we sample from the full valid support at T=1\mathcal{T} = 1 without top-kk or nucleus truncation.

Verification by Haar-random state evolution

Constructing dense 2n×2n2^n \times2^n unitaries is infeasible at 20 qubits, so the verifier instead compares circuits by evolving a random input state. For each input circuit, it draws a Haar-random state ∣ψ⟩∈C2n|\psi\rangle\in\mathbb{C}^{2^n}, evolves it through both the reference and each candidate circuit using the state-vector simulator Qulacs [60], and computes the state fidelity

F(C^;ψ)=∣⟨ψ∣U(Cref)†U(C^)∣ψ⟩∣2.(9)F(\hat{C};\psi) = \left|\langle\psi|U(C_{\mathrm{ref}})^\dagger U(\hat{C})|\psi\rangle\right|^2. \tag*{(9)}

A candidate is marked correct if ∣F−1∣≤τF|F - 1| \le\tau_F with τF=10−4\tau_F = 10^{-4}; unparseable sequences receive F=0F = 0. Because each reference CrefC_{\mathrm{ref}} has already been verified against CsrcC_{\mathrm{src}} (§ 4), equivalence to CrefC_{\mathrm{ref}} implies equivalence to CsrcC_{\mathrm{src}}. Taking the squared modulus in Eq. (9) quotients out any global phase, matching Eq. (2). Simulating an mm-gate circuit requires O(m 2n)O(m\,2^n) time, compared with O(4n)O(4^n) memory merely to store a dense unitary.

This test is grounded in the relation between average state fidelity and process fidelity [61, 62] (Appendix § 14). With W=U(Cref)†U(C^)W = U(C_{\mathrm{ref}})^\dagger U(\hat{C}) and d=2nd = 2^n, the two circuits are equivalent up to global phase if and only if the process fidelity Fp=∣Tr⁡W∣2/d2F_p = |\operatorname{Tr} W|^2/d^2 equals one. For a Haar-random state ∣ψ⟩|\psi\rangle, F(C^;ψ)F(\hat{C};\psi) is an unbiased estimator of the average state fidelity Fˉ=Eψ[F(C^;ψ)]\bar{F} = \mathbb{E}_{\psi}[F(\hat{C};\psi)], which satisfies

Fˉ=dFp+1d+1,1−Fˉ=dd+1(1−Fp).(10)\bar{F} = \frac{dF_p + 1}{d + 1}, \qquad1 - \bar{F} = \frac{d}{d + 1}(1 - F_p). \tag*{(10)}

For n≥5n \ge5, the scaling factor d/(d+1)d/(d + 1) lies in [32/33,1)[32/33, 1), so expected single-state infidelity closely tracks process infidelity at the cost of one state-vector simulation. Although bounding worst-case false acceptance statistically requires many independent Haar-random states (Appendix § 14), empirically we find that inequivalent candidates are consistently rejected already by a single Haar-random state: among the 32,000 candidates evaluated in § 6.1, the first random state (k=1k = 1) rejected all 11,296 inequivalent candidates.

To guide RL post-training, the reward function ranks every correct candidate above every incorrect one, and among correct candidates it ranks by gate reduction relative to the reference (Eq. (4)).

For a candidate sequence yy decoding to C^\hat{C}, let c=1[∣F−1∣≤τF]c = \mathbf{1}[|F - 1| \le\tau_F] and

g(C^)=clip⁡(wΔlΔl+w2qΔq+wTΔτ,−1,1),(11)g(\hat{C}) = \operatorname{clip}(w_{\Delta l}\Delta l + w_{2q}\Delta q + w_T\Delta\tau, -1, 1), \tag*{(11)}

with non-negative weights (wΔl,w2q,wT)(w_{\Delta l}, w_{2q}, w_T) emphasizing two-qubit and TT gates (Appendix § 11). The reward is

R(x,y;ψ)={b+g(C^),c=1,s⋅clip⁡(F/(1−τF),0,1),c=0,(12)R(x,y;\psi) = \begin{cases} b + g(\hat{C}), & c = 1,\\ s \cdot\operatorname{clip}(F/(1-\tau_F), 0, 1), & c = 0, \end{cases} \tag*{(12)}

with b=2b = 2 (success bonus) and s=0.2s = 0.2 (failure scale). Correct candidates score in [1,3][1,3] and incorrect ones in [0,0.2][0, 0.2]. The condition b−1>sb - 1 > s guarantees the lexicographic order, and failures still receive a dense fidelity signal. The reward is non-negative, which MaxRL requires (§ 3.6).

Supervised pretraining

The policy is first trained by maximum likelihood on (source, diagram, reference) triples:

LSFT(θ)=−E(x,yref)[∑t=1∣yref∣log⁡πθ(ytref∣y<tref,x)].(13)\mathcal{L}_{\mathrm{SFT}}(\theta) = -\mathbb{E}_{(x,y^{\mathrm{ref}})} \left[ \sum_{t=1}^{|y^{\mathrm{ref}}|} \log\pi_\theta(y_t^{\mathrm{ref}} \mid y_{<t}^{\mathrm{ref}}, x) \right]. \tag*{(13)}

averaged over non-padding tokens. Supervised pretraining enables the model to learn valid circuit syntax, align gate tokens with ZX spiders, and approximate the PyZX optimization pipeline end-to-end. Because Eq. (13) maximizes token-level likelihood against a single reference, however, it penalizes alternative equivalent circuits and provides no direct incentive for further gate reduction. Reinforcement learning fine-tuning overcomes both limitations.

Reinforcement learning with group-relative advantages

At each step we sample a batch of BB inputs {xj}j=1B\{x_j\}_{j=1}^B, draw a group of GG candidates {yj,i}i=1G∼πθ(⋅∣xj)\{y_{j,i}\}_{i=1}^G \sim\pi_\theta(\cdot\mid x_j) per input on a shared random state ∣ψj⟩|\psi_j\rangle, and evaluate them via the verifier and Eq. (12) to obtain rewards rj,i=R(xj,yj,i;ψj)r_{j,i} = R(x_j,y_{j,i};\psi_j). A critic-free advantage estimator maps each group of rewards to scalar weights Aj,iA_{j,i}, and we perform one on-policy update minimizing

LRL(θ)=−1BG∑j=1B∑i=1GAj,i∑t=1∣yj,i∣log⁡πθ(yj,i,t∣yj,i,<t,xj).(14)\mathcal{L}_{\mathrm{RL}}(\theta) = -\frac{1}{BG} \sum_{j=1}^{B}\sum_{i=1}^{G} A_{j,i}\sum_{t=1}^{|y_{j,i}|} \log\pi_\theta(y_{j,i,t}\mid y_{j,i,<t},x_j). \tag*{(14)}

We consider three advantage estimators (GRPO, MaxRL, and Hybrid), which compute Aj,iA_{j,i} from the group mean rˉj=1G∑i=1Grj,i\bar{r}_j = \frac{1}{G}\sum_{i=1}^{G} r_{j,i} and sample standard deviation σj\sigma_j.

GRPO: Aj,i=rj,i−rˉjσj+ε⋅1[σj>σmin⁡]A_{j,i} = \frac{r_{j,i} - \bar{r}_j}{\sigma_j + \varepsilon}\cdot\mathbf{1}[\sigma_j > \sigma_{\min}],

GRPO:Aj,i=rj,i−rˉjσj+ε⋅1[σj>σmin⁡],(15)\text{GRPO:}\qquad A_{j,i} = \frac{r_{j,i} - \bar{r}_j}{\sigma_j + \varepsilon} \cdot\mathbf{1}[\sigma_j > \sigma_{\min}], \tag*{(15)}

MaxRL: Aj,i=rj,i−rˉjrˉj+ε⋅1[rˉj>0]A_{j,i} = \frac{r_{j,i} - \bar{r}_j}{\bar{r}_j + \varepsilon}\cdot\mathbf{1}[\bar{r}_j > 0],

MaxRL:Aj,i=rj,i−rˉjrˉj+ε⋅1[rˉj>0],(16)\text{MaxRL:}\qquad A_{j,i} = \frac{r_{j,i} - \bar{r}_j}{\bar{r}_j + \varepsilon} \cdot\mathbf{1}[\bar{r}_j > 0], \tag*{(16)}

Hybrid:

Hybrid:Aj,i={Aj,iGRPO,group j all correct,Aj,iMaxRL,otherwise.(17)\text{Hybrid:}\qquad A_{j,i} = \begin{cases} A_{j,i}^{\mathrm{GRPO}}, & \text{group }j\text{ all correct},\\ A_{j,i}^{\mathrm{MaxRL}}, & \text{otherwise}. \end{cases} \tag*{(17)}

for small numerical guards ε,σmin⁡>0\varepsilon, \sigma_{\min} > 0. Algorithm 1 summarizes the procedure.

GRPO [44] normalizes centered rewards by the group standard deviation, making updates invariant to positive affine transformations of the reward. For a binary reward with pass probability p=p =

Algorithm 1 RL fine-tuning of GraftQ

Require: pretrained policy πθ\pi_\theta, data mixture D\mathcal{D}, group size GG, estimator ∈{GRPO,MaxRL,Hybrid}\in\{\mathrm{GRPO},\mathrm{MaxRL},\mathrm{Hybrid}\}

  1. for each step do

  2. sample inputs {xj}j=1B∼D\{x_j\}_{j=1}^{B} \sim\mathcal{D}

  3. for each jj do

  4. sample yj,1..G∼πθ(⋅∣xj)y_{j,1..G} \sim\pi_\theta(\cdot\mid x_j) over Vnj\mathcal{V}_{n_j} ▹\triangleright Eq. (8)

  5. draw one Haar state ∣ψj⟩\lvert\psi_j\rangle; compute Fj,i,cj,i,rj,iF_{j,i}, c_{j,i}, r_{j,i} ▹\triangleright Eqs. (9) and (12)

  6. compute Aj,1..GA_{j,1..G} over the full group ▹\triangleright Eqs. (15) to (17)

  7. end for

  8. one AdamW step on LRL\mathcal{L}_{\mathrm{RL}} (Eq. (14)), gradient norm clipped to 1

  9. end for

pθ(x,ψ)p_\theta(x,\psi), its expected gradient per input scales as ∇p/p(1−p)=∇ 2arcsin⁡p\nabla p / \sqrt{p(1-p)} = \nabla\, 2\arcsin\sqrt{p}, concentrating weight on inputs of intermediate difficulty while assigning weak updates when pp is small.

Continuous MaxRL extends Maximum-Likelihood RL [47], which maximizes Elog⁡pθ\mathbb{E}\log p_\theta rather than Epθ\mathbb{E}p_\theta so that hard inputs receive inverse-probability weight (∝1/p\propto1/p). For our graded reward, we replace pθp_\theta with the expected reward μθ(x,ψ)=Eθ[R(x,y;ψ)]\mu_\theta(x,\psi) = \mathbb{E}_\theta[R(x,y;\psi)] while retaining Eq. (16), estimating the gradient of Ex,ψlog⁡μθ(x,ψ)\mathbb{E}_{x,\psi}\log\mu_\theta(x,\psi) (Appendix B proves this extension and its scale invariance and shift sensitivity). Under Eq. (12), for a fixed input, in an all-failing group with Fˉ>0\bar{F}>0, the failure scale ss cancels to give Ai≈(Fi−Fˉ)/FˉA_i \approx(F_i-\bar{F})/\bar{F}, driving the policy toward higher fidelity; in a mixed group on a hard input, rare correct candidates receive large positive advantages (b+g−rˉ)/rˉ≫1(b+g-\bar{r})/\bar{r}\gg1.

Hybrid (Eq. (17)) addresses a limitation of MaxRL on already-solved inputs: once all GG candidates in a group are correct, rewards are ri=b+gir_i=b+g_i and Eq. (16) reduces to (gi−gˉ)/(b+gˉ)(g_i-\bar{g})/(b+\bar{g}), where the bonus b=2b=2 dilutes small differences in gate score (σg≈0.1\sigma_g\approx0.1) by roughly 20× compared with GRPO. Hybrid therefore applies MaxRL whenever a group contains any incorrect candidate and switches to GRPO when all GG candidates are correct (Appendix C): in an all-correct group, bb cancels out of Ai=(gi−gˉ)/(σg+ε)A_i=(g_i-\bar{g})/(\sigma_g+\varepsilon), leaving an unattenuated advantage that directly optimizes gate count among valid candidates. Because all GG candidates pass with probability pGp^G, this switch rarely triggers on hard inputs (pG≪1p^G\ll1, retaining MaxRL) and smoothly takes over as accuracy approaches one, without extra hyperparameters.

Training Data

GraftQ learns from triples (Csrc,D,Cref)(C_{\mathrm{src}},D,C_{\mathrm{ref}}): a random source circuit, a simplified ZX diagram of it, and an equivalent reference circuit extracted from that diagram. All triples are generated synthetically, so the corpus can grow to millions of examples and every reference is checked for equivalence before it is stored. Figure 1Figure 1 summarizes the generator.

Random source circuits

Each sample starts with a qubit count nn and a gate count mm, uniformly sampled from {5,…,20}\{5,\ldots,20\} and {mmin⁡,…,mmax⁡}\{m_{\min},\ldots,m_{\max}\} (§ 4.3), respectively. The circuit is then built gate by gate. Each gate type is drawn independently from the fixed distribution in Table 2 and placed on a uniformly random qubit (single-qubit gates) or a uniformly random ordered pair of distinct qubits (CNOT, CZ). A phase gate RZ(ℓπ/4)R_Z(\ell\pi/4) takes ℓ\ell uniformly from {1,2,3,5,6,7}\{1,2,3,5,6,7\}.

gateHHXXZZSSTTRZ(ℓπ/4)R_Z(\ell\pi/4)CNOTCZ
probability0.10.10.10.10.20.10.20.1

Table 2. Gate distribution of the random source circuits.

ZX simplification and reference extraction

The reference is produced with PyZX [13] in five steps:

  1. The source is converted to a ZX diagram D0D_0.

  2. Phase teleportation [29] moves non-Clifford phases so that they can fuse without altering the graph structure, giving D1D_1.

  3. D1D_1 is converted to graph-like form [28] and simplified with the causal-flow-preserving heuristic of Hollker [63] to reduce two-qubit gates while keeping the diagram directly extractable [49], giving D2D_2 (used as the input diagram DD in §3).

  4. A circuit is extracted from D2D_2 and decomposed into basic gates.

  5. It is post-processed by PyZX’s gate-level optimization, with and without SWAP-aware rules. Of the two results, the one with fewer two-qubit gates becomes CrefC_{\mathrm{ref}}.

Every extracted reference CrefC_{\mathrm{ref}} is verified against CsrcC_{\mathrm{src}} using the Haar-state test of § 3.4 with tolerance 10−610^{-6} (discarding and regenerating any sample that fails, to guard against extraction bugs). PyZX expresses extracted phases in the RZ(ℓπ/4)R_Z(\ell\pi/4) basis (with XX-axis rotations conjugated by HH), so every token in CsrcC_{\mathrm{src}} and CrefC_{\mathrm{ref}} belongs to the vocabulary V\mathcal{V} of § 3.1. We retain CrefC_{\mathrm{ref}} even when it contains more gates than CsrcC_{\mathrm{src}}: supervised pretraining imitates the PyZX output directly, while subsequent RL fine-tuning rewards further gate reduction. Conditioning on D2D_2 alongside CsrcC_{\mathrm{src}} provides the model with both the explicit input gate sequence and the simplified ZX graph structure prior to circuit extraction.

Size buckets

For curriculum training (§ 5), the corpus is partitioned by the gate count of the source circuit into four buckets: [20,100][20,100], [101,200][101,200], [201,300][201,300], and [301,400][301,400] gates. Each bucket maintains independent training, validation, and test splits (Table 3). Supervised pretraining uses the [20,100][20,100] bucket, the two-stage RL curriculum (§ 5) progressively incorporates [101,200][101,200] and [201,300][201,300], and [301,400][301,400] is held out to evaluate length generalization to unseen longer circuits. For benchmark evaluation (§ 6), we draw a fixed subset of 9,000 circuits from each bucket’s test split, along with a qubit-stratified subset of 992 circuits (62 per qubit count across n∈{5,…,20}n\in\{5,\ldots,20\}) for high-budget (K≤64K\leq64) sampling experiments.

source gatestrainvalidtest
20–1007,000,00050,000100,000
101–2002,013,41910,0409,959
201–3002,013,0829,97810,033
301–4002,012,5649,8989,940

Table 3. Data buckets (5–20 qubits): number of samples in each split.

Experimental Setup and Training Pipeline

Training proceeds in three stages (Figure 3). Hyperparameters and software/hardware details are listed in Appendix A.

Training pipeline

Figure 3. Training pipeline. Stage 1 compares advantage estimators at fixed circuit size. Stage 2 initializes from the stage-1 Hybrid policy and progressively introduces larger circuits.

Stage 0: supervised pretraining. The 174M-parameter model of § 3.2 is pretrained with Eq. (13) to reproduce the PyZX reference on the 20–100-gate bucket conditioned on D=D2D = D_2, using AdamW [64] with a global batch size of 256 (Table 7). Validation cross-entropy reaches 0.1303 (perplexity 1.14) at approximately 248,000 steps (≈9\approx9 epochs), which initializes all RL runs.

parameterSFTRL stage 1RL stage 2
optimizerAdamWAdamWAdamW
(β1,β2)(\beta_1,\beta_2)(0.9, 0.98)(0.9, 0.98)(0.9, 0.98)
ϵ\epsilon10−910^{-9}10−910^{-9}10−910^{-9}
weight decay0.0100
peak LR2×10−42\times10^{-4}10−510^{-5}10−510^{-5}
LR schedulewarmup+cosineconstantconstant
warmup steps3000––
gradient clip1.01.01.0
global batch BB2563264
group size GG–3232
updates / batch–1 (on-policy)1 (on-policy)
rollout T\mathcal{T}–1.01.0
valid T\mathcal{T}–0.10.1
valid interval200010241024
valid samples–1024500 / bucket
steps (eval)≈248k (≈9 ep.)49,152116.7k / 255.0k
precisionbf16bf16bf16
KL penalty–nonenone
fidelity tol. τF\tau_F–10−410^{-4}10−410^{-4}

Table 7. Training hyperparameters.

Stage 1: comparing advantage estimators. Stage 1 fine-tunes the pretrained policy on 20–100-gate circuits to isolate the effect of the advantage estimator while holding all other settings fixed across GRPO, MaxRL, and Hybrid: identical initialization, training data, and reward (Eq. (12)); identical on-policy objective (Eq. (14)) with unit gradient-norm clipping; identical rollout sampling (G=32G = 32, T=1\mathcal{T} = 1, full valid support); a constant learning rate of 10−510^{-5}; and identical rollout and validation seeds. Each step samples 32 inputs (1,024 candidates per step); checkpoints are selected by mean validation reward on 20–100-gate validation circuits, and we evaluate step 49,152 of each run.

Stage 2: curriculum over circuit size. Because a policy trained solely on 20–100-gate circuits generalizes poorly to 200- or 300-gate inputs [41], we initialize from the stage-1 Hybrid policy (step 49,152) and apply a two-stage size curriculum [65] using weighted mixtures of the size buckets (§ 4.3), assigning 70% weight to the newly introduced bucket while replaying shorter buckets to prevent forgetting:

  1. Stage 2a (up to 200 gates, steps 0–116,736): 20–100 : 101–200 = 0.30 : 0.70.

  2. Stage 2b (up to 300 gates, from step 116,736; evaluated at step 254,976): 20–100 : 101–200 : 201–300 = 0.15 : 0.15 : 0.70.

Each step samples a global batch of 64 inputs with G=32G = 32 rollouts per input (2,048 candidates per step), selecting checkpoints by mean validation reward across a fixed multi-bucket validation pool. The 301–400-gate bucket is never used in training and serves strictly to evaluate out-of-distribution length generalization.

Experimental Results

We evaluate all models on the held-out sets of 9,000 random circuits per size bucket (§ 4.3).

Metrics and verification reliability

Circuit accuracy (pass@K) is the fraction of test circuits with at least one valid candidate among KK samples [66], with pass@1 estimated via c/Kc/K where cc is the number of valid samples. Among valid candidates for a given input, we select the lexicographic minimum under (Nall,N2q,NT)(N_{\mathrm{all}}, N_{2q}, N_T) (ranking by k(C^)k(\hat{C}) or (N2q,NT,Nall)(N_{2q}, N_T, N_{\mathrm{all}}) gives virtually identical results at T=0.2\mathcal{T} = 0.2) and report gate reductions Nk(Csrc)−Nk(C^)N_k(C_{\mathrm{src}}) - N_k(\hat{C}) alongside PyZX’s Nk(Csrc)−Nk(Cref)N_k(C_{\mathrm{src}}) - N_k(C_{\mathrm{ref}}). The better-than-reference (and worse-than-reference) rate is the fraction of a model’s solved circuits on which its selected circuit uses strictly fewer (or strictly more) gates than CrefC_{\mathrm{ref}}. To avoid selection bias across models with different solve rates, mean gate reductions are always computed on the common success set solved by all compared models in a table or plot.

Before presenting benchmark comparisons, we validate our single-state verifier (k=1k = 1, τF=10−4\tau_F = 10^{-4}) in two ways. First, on 32,000 candidates sampled across SFT, GRPO, MaxRL, and Hybrid on 20–100-gate circuits (5≤n≤145 \le n \le14), we compare k=1,…,10k = 1,\ldots,10 independent Haar-random state tests against exact process infidelity rp=1−Fpr_p = 1 - F_p (Figure 4). Already at k=1k = 1, the random-state test rejects all 11,296 inequivalent candidates (0 false acceptances): zero equivalent candidates fall in (10−8,0.146)(10^{-8}, 0.146), matching the exact single-gate lower bound rp,min⁡(1)=sin⁡2(π/8)≈0.1464r_{p,\min}^{(1)} = \sin^2(\pi/8) \approx0.1464 (Appendix § 14), and 89.4% have rp≥0.9r_p \ge0.9.

Figure 4. Validation of random-state verification on 32,000 candidates (5 ≤n≤14\le n \le14). (a) Fraction passing kk Haar-random state tests (solid) versus the upper bound fc+(1−fc)(15/16)kf_c + (1-f_c)(15/16)^k (dashed); empirical acceptance equals the exact equivalence rate fcf_c already at k=1k = 1. (b) Exact process infidelity rp=1−Fpr_p = 1 - F_p across all 11,296 inequivalent candidates: none lie in (10−8,0.146)(10^{-8}, 0.146).

Second, we subject all 80,674 selected best candidates across every model–bucket evaluation reported below to deterministic certification against CrefC_{\mathrm{ref}} via symbolic ZX simplification of Cref†C^C_{\mathrm{ref}}^\dagger\hat{C} [67], supplemented by exact unitary comparison for all 24,910 candidates with n≤10n \le10 (Appendix § 14). Every single candidate passes (100% certified, zero rejections).

Advantage estimators: GRPO, MaxRL, and Hybrid

Table 4 and Figure 5 first compare the three stage-1 estimators under identical initialization and compute (§ 5), confirming the analysis of § 3.6:

Figure 5. Stage-1 advantage-estimator comparison on 20–100-gate circuits (step 49,152). (a) Test pass@32 by qubit count. (b) Extra two-qubit gate reduction over PyZX on the common success set (ncom=5,443n_{\mathrm{com}} = 5{,}443). (c) Validation pass@32 during stage-1 training.

Systempass@1pass@32all2QTTbetterworse
PyZX ref.––14.190.796.21––
SFT (init.)60.8%71.6%14.240.796.210.1%0.3%
GRPO72.7%74.7%15.611.056.2021.1%10.6%
MaxRL83.4%87.6%14.880.846.1920.4%27.9%
Hybrid80.4%85.5%15.581.046.2021.9%16.0%

Table 4. Controlled stage-1 comparison on 9,000 held-out 20–100-gate circuits (K=32K = 32, T=0.2\mathcal{T} = 0.2, step 49,152). Gate reductions are on the common success set (ncom=5,443n_{\mathrm{com}} = 5{,}443); better and worse (2Q) are relative to PyZX on each model’s solved set.

  1. Correctness on hard inputs. MaxRL (87.6% pass@32) and Hybrid (85.5%) far outperform GRPO (74.7%, only +3.1 pp over SFT), with the largest gap on dense small-qubit circuits (59.8% and 60.3% vs. 39.9% at n=5n = 5; Figure 5(a)), where MaxRL’s inverse-mean weighting prioritizes low-pass-rate inputs.

  1. Gate-cost optimization on solved inputs. MaxRL yields much smaller gate reductions than GRPO (0.84 vs. 1.05 2Q; 27.9% worse than PyZX) because the success bonus bb dilutes gate-cost differences in all-correct groups. Switching to GRPO normalization on all-correct groups allows Hybrid to match GRPO’s gate reduction (1.04 2Q, 21.9% better than PyZX; Figure 5(b)) while staying within 2.1 pp of MaxRL’s pass@32.

  1. Diversity and training dynamics. The pass@32−pass@1 gap is only 2.0 pp for GRPO versus 4.2 pp for MaxRL and 5.1 pp for Hybrid, indicating narrower mode collapse under GRPO, while MaxRL and Hybrid improve validation accuracy steadily throughout training (Figure 5(c); Appendix § 15).

Hybrid thus provides the best trade-off between solve rate and gate reduction, motivating its selection as the base policy for Stage 2.

Main results

Table 5 and Figure 6 and Figure 7 summarize three central findings across the four size buckets.

Figure 6. Main evaluation on 20–100-gate circuits (5–20 qubits). (a) Test pass@8 by qubit count. (b) Mean two-qubit gates reduced on the common success set (ncom=5,466n_{\mathrm{com}} = 5{,}466). (c) Inference-time scaling of S1-Hybrid (K∈{1,…,64}K \in\{1, \ldots, 64\} on 992 stratified circuits; best-of-KK 2Q reduction assigns zero reduction when no sample in KK is valid).

Figure 7. Per-qubit pass@8 of S1-Hybrid, S2a-Hybrid (trained up to 200 gates), and S2b-Hybrid (trained up to 300 gates) on (a) 20–100, (b) 101–200, (c) 201–300, and (d) unseen 301–400 gates.

BucketSystempass@1pass@8gates reduced (common set)better than ref.
all2QT\mathcal{T}all2Q
20–100PyZX reference––14.210.826.21––
GraftQ (SFT)60.8%67.7%14.250.826.215.0%0.1%
GraftQ (S1-Hybrid)80.4%83.5%15.571.066.2059.5%21.8%
GraftQ (S2a-Hybrid)90.8%92.9%15.691.076.2060.2%23.7%
GraftQ (S2b-Hybrid)92.0%94.1%15.671.066.2059.7%23.6%
101–200PyZX reference––44.572.3117.76––
GraftQ (S1-Hybrid)12.5%15.4%47.062.3917.6569.3%35.1%
GraftQ (S2a-Hybrid)60.7%68.7%46.872.4317.6541.8%29.9%
GraftQ (S2b-Hybrid)71.4%78.8%46.752.4317.6538.5%28.6%
201–300PyZX reference––93.795.1334.56––
GraftQ (S2a-Hybrid)6.8%10.2%88.203.4334.2619.1%25.0%
GraftQ (S2b-Hybrid)38.8%50.7%87.903.3434.259.2%20.2%
301–400 (unseen)GraftQ (S2b-Hybrid)4.1%7.7%129.474.5051.75––

Table 5. Main results on held-out random circuits (9,000 circuits per bucket, 5–20 qubits, K=8K = 8, T=0.2\mathcal{T} = 0.2). S2a-Hybrid (step 116,736) is trained up to 200 gates and S2b-Hybrid (step 254,976) up to 300 gates (omitting policies with 0% pass@8); the unseen 301–400-gate bucket evaluates length generalization. Mean gate reductions are relative to CsrcC_{\mathrm{src}} on each trained bucket’s common success set (ncom=5,466n_{\mathrm{com}} = 5{,}466, 1,128, and 797) and on the 690 solved circuits for 301–400. Better (all) and better (2Q) are fractions of each model’s own solved circuits strictly beating CrefC_{\mathrm{ref}}.

First, verifier-guided RL moves the model from imitating PyZX to surpassing it in both reliability and gate count. Under supervised pretraining, the model largely copies its teacher, matching PyZX’s two-qubit gate count on nearly all solved circuits. RL post-training raises pass@8 on 20–100-gate circuits from 67.7% to 94.1%, with the largest gains on dense, small-qubit circuits where extraction is hardest (Figure 6(a)), and consistently reduces more total and two-qubit gates than PyZX across all qubit counts (Figure 6(b)). Across the three trained buckets in Table 5, the final curriculum policy (S2b-Hybrid) finds strictly fewer two-qubit gates than PyZX on 20%–29% of solved circuits while closely matching PyZX in TT count (§7); selecting the circuit with fewer two-qubit gates between CrefC_{\mathrm{ref}} and C^\hat{C} yields net full-test-set reductions of +0.47, +0.51, and +0.26 two-qubit gates per circuit over PyZX alone.

Second, the two-stage size curriculum overcomes the sharp length degradation of fixed-size RL while inducing positive backward transfer (Figure 7). Whereas S1-Hybrid trained solely on short circuits drops to 15.4% pass@8 on 101–200 gates and 0% beyond, progressive curriculum training scales pass@8 to 68.7% (S2a-Hybrid) and 78.8% (S2b-Hybrid) on 101–200 gates, reaches 50.7% on 201–300 gates, and achieves 7.7% pass@8 on unseen 301–400-gate circuits (Figure 7(b–Figure 7d)); 0% length-cap truncation or parse failures, with errors arising solely from inequivalence. Replaying shorter buckets not only prevents forgetting, but further improves pass@8 on 20–100 gates (83.5% → 92.9% → 94.1%) and 101–200 gates (68.7% → 78.8%) across Stages 2a and 2b (Figure 7(a,Figure 7b); validation trajectories in Figure 9(a,Figure 9b)) while preserving gate-reduction quality (Table 5).

Figure 9. Stage-2 curriculum dynamics and test-time scaling. (a) Per-bucket validation pass@32 across Stage 2a (steps 0–116,736) and Stage 2b (steps 116,736–262,144). (b) Mean validation reward, with red markers indicating S2a-Hybrid (116.7k) and S2b-Hybrid (255.0k). (c) Test pass@KK (K∈{1,…,64}K \in\{1, \ldots, 64\}) of S2b-Hybrid (step 254,976) on the 992-circuit stratified subsets of 201–300 (38.5% →\to 56.3%) and unseen 301–400 (3.8% →\to 9.2%) gates.

Third, increasing the test-time sampling budget from K=1K = 1 to 64 steadily improves both pass@KK and best-of-KK two-qubit gate reduction without retraining (Figure 6(c)), with especially pronounced gains on longer circuits (e.g., lifting pass@KK from 38.5% to 56.3% on 201–300 gates; Figure 9(c)).

Discussion and Conclusion

We formulated quantum circuit optimization as graph-conditioned sequence-to-sequence generation. GraftQ jointly encodes a source circuit’s gate-token sequence and simplified ZX diagram with a GNN-Transformer, and is pretrained on PyZX-optimized references before reinforcement learning post-training with a Haar-random state verifier and a gate-reduction reward. Extending MaxRL to continuous non-negative rewards and introducing the Hybrid advantage estimator combines MaxRL’s high solve rate on hard circuits with GRPO’s unattenuated gate-count optimization on solved circuits. Together with a two-stage size curriculum and symbolic ZX certification of all selected benchmark solutions, verifier-guided RL moves GraftQ well beyond supervised imitation in both equivalence reliability and two-qubit gate reduction.

On the 20–100- and 101–200-gate benchmarks, RL consistently reduces more two-qubit gates on average than PyZX while closely matching PyZX’s TT-gate counts (within 0.01–0.31 gates; fault-tolerant settings can further prioritize TT count via a larger wTw_T). This contrast reflects the reference pipeline (§ 4.2): phase teleportation [29] already fuses essentially all collapsible non-Clifford phases on random Clifford+TT circuits, leaving little headroom in TT count, whereas causal-flow extraction introduces auxiliary two-qubit gates [51] that graph-conditioned autoregressive decoding learns to avoid. On the 201–300-gate bucket, mean gate reduction still trails PyZX because moderate single-sample accuracy (pp) makes all-correct rollout groups rare (pG≪1p^G \ll1), keeping Hybrid primarily in its MaxRL correctness regime; following Hybrid training with a subsequent GRPO stage once accuracy is established offers a direct remedy.

For circuit scale, fixed-size policies fail on deeper inputs, especially at high per-qubit gate density m/nm/n (small nn, Figure 7), due to compounding autoregressive errors rather than decoding length caps [41]. Our size curriculum addresses this progressively: although our experiments stop training at 201–300 source gates (already generalizing to unseen 301–400-gate circuits), the curriculum itself can continue advancing to longer buckets to handle deeper circuits, complemented at inference time by larger sampling budgets (K≥1K \ge1) without retraining. Extending training and evaluation from synthetic random circuits and a single causal-flow ZX baseline to structured algorithmic benchmarks is a natural next step.

Finally, two directions will broaden practical deployment. First, state-vector verification scales exponentially with qubit count (reaching hundreds of milliseconds per candidate at n=20n = 20), limiting online RL training to roughly 20 qubits; scaling to wider registers motivates fast symbolic ZX rewriting or approximate tensor-network verifiers. Second, because hardware constraints enter our formulation only through the qubit-indexed gate vocabulary, validity mask, and gate-cost reward, adapting these components offers a direct path to larger qubit registers, native device gate sets, and connectivity-aware routing.

Code Availability

The inference and equivalence-verification code for GraftQ, together with the trained S2b-Hybrid model checkpoint, is publicly available at https://github.com/Xiao-diLi/GraftQ.

Acknowledgments

We thank Xue Chen, Xiaotian Nie, Hui Zhai, and Si Wei for helpful discussions.

References

Hyperparameters and Implementation Details

Table 6 lists the model architecture and Table 7 lists the training hyperparameters for all three stages.

Software and hardware. Our implementation uses PyTorch [68] and PyTorch Lightning, PyTorch Geometric [69] for GCN layers, a customized PyZX [13] incorporating the causal-flow-preserving simplification of Holker [63], and Qulacs [60] for state-vector simulation. Supervised pretraining runs on four NVIDIA A100 (48 GB) GPUs; each stage-1 RL runs use a single A100 (48 GB) GPU (≈ 85 GPU-hours); and stage-2 curriculum runs use four or eight NVIDIA A100 (48 GB) / A800 (80 GB) GPUs with a fixed global batch size of 64 inputs per step.

Reward, advantage, and decoding parameters. Reward (Eq. (12)): $b=2$, $s=0.2$, $(w_{\mathrm{all}},w_{2q},w_T)=(1,2,2)$, $\tau_F=10^{-4}$ (with a $10^{-6}$ denominator guard in Eq. (4) when Nk(Cref)=0N_k(C_{\mathrm{ref}})=0); assigning a larger weight wTw_T does not push TT-gate reduction past PyZX, because PyZX’s phase teleportation already reduces TT count very effectively on these circuits; see §7; numerical guards (Eqs. (15) and (16)): ϵ=10−8\epsilon=10^{-8}, σmin⁡=10−4\sigma_{\min}=10^{-4}. Test decoding uses temperature T=0.2\mathcal{T}=0.2 without top-kk or top-pp truncation; RL rollouts and test decoding cap output length at 1.2× the longest reference in the batch, while training-time validation uses a 512-token cap. Each RL rollout batch performs a single on-policy optimizer step without a KL penalty (14).

MaxRL with Continuous Rewards

We extend Maximum-Likelihood Reinforcement Learning [47] to continuous non-negative rewards and prove three results (Theorems B.1 to B.3) used in § 3.6.

Throughout this appendix, fix an input xx and a shared Haar-random verifier state ∣ψ⟩|\psi\rangle (Algorithm 1); the policy πθ(⋅∣x)\pi_\theta(\cdot\mid x) observes only xx, so its score function S=∇θlog⁡πθ(y∣x)S = \nabla_\theta\log\pi_\theta(y \mid x) is independent of ψ\psi. Let R=R(x,y;ψ)≥0R = R(x,y;\psi) \ge0 denote the single-state reward ((12)) with conditional expectation μθ(x,ψ)=Eθ[R(x,y;ψ)]>0\mu_\theta(x,\psi) = \mathbb{E}_\theta[R(x,y;\psi)] > 0, where Eθ[⋅]\mathbb{E}_\theta[\cdot] denotes expectation under y∼πθ(⋅∣x)y \sim\pi_\theta(\cdot\mid x) for fixed (x,ψ)(x,\psi).

Continuous MaxRL gradient

Proposition B.1. The gradient of JMaxRL(θ)=Ex,ψlog⁡μθ(x,ψ)J_{\mathrm{MaxRL}}(\theta) = \mathbb{E}_{x,\psi}\log\mu_\theta(x,\psi) with respect to θ\theta satisfies

∇θJMaxRL=Ex,ψ[Eθ[Rμθ(x,ψ)S]]=Ex,ψ[Eq[S]],(18)\nabla_\theta J_{\mathrm{MaxRL}} = \mathbb{E}_{x,\psi}\left[\mathbb{E}_\theta\left[\frac{R}{\mu_\theta(x,\psi)}S\right]\right] = \mathbb{E}_{x,\psi}\left[\mathbb{E}_q[S]\right], \tag*{(18)}

where q(y∣x,ψ)∝πθ(y∣x)R(x,y;ψ)q(y \mid x,\psi) \propto\pi_\theta(y \mid x)R(x,y;\psi) is the reward-tilted distribution. Conditioned on (x,ψ)(x,\psi), the GG group rewards {ri}i=1G\{r_i\}_{i=1}^G are i.i.d. with mean μθ(x,ψ)\mu_\theta(x,\psi); replacing μθ(x,ψ)\mu_\theta(x,\psi) with the group sample mean rˉ=1G∑i=1Gri\bar{r} = \frac{1}{G}\sum_{i=1}^G r_i yields the self-normalized advantage Ai=(ri−rˉ)/rˉA_i = (r_i-\bar{r})/\bar{r}, for which g^=(BG)−1∑j,iAj,iSj,i\hat{g} = (BG)^{-1}\sum_{j,i} A_{j,i}S_{j,i} is an asymptotically unbiased estimator of ∇θJMaxRL\nabla_\theta J_{\mathrm{MaxRL}} with finite-group bias O(1/G)O(1/G).

Proof. For fixed (x,ψ)(x,\psi), R(x,y;ψ)R(x,y;\psi) does not depend on θ\theta, so the log-derivative identity gives ∇θlog⁡μθ(x,ψ)=Eθ[RS]/μθ(x,ψ)=Eθ[(R/μθ)S]\nabla_\theta\log\mu_\theta(x,\psi) = \mathbb{E}_\theta[RS]/\mu_\theta(x,\psi) = \mathbb{E}_\theta[(R/\mu_\theta)S]. The reward-tilted rewrite follows from q(y∣x,ψ)=πθ(y∣x)R(x,y;ψ)/μθ(x,ψ)q(y \mid x,\psi) = \pi_\theta(y \mid x)R(x,y;\psi)/\mu_\theta(x,\psi). Since Eθ[S]=0\mathbb{E}_\theta[S] = 0, Eθ[(R−μθ)S/μθ]=Eθ[RS]/μθ\mathbb{E}_\theta[(R-\mu_\theta)S/\mu_\theta] = \mathbb{E}_\theta[RS]/\mu_\theta. Replacing μθ(x,ψ)\mu_\theta(x,\psi) by the i.i.d. group mean rˉ\bar{r} introduces an O(1/G)O(1/G) ratio-estimation bias that vanishes as G→∞G \to\infty, and taking expectation over (x,ψ)(x,\psi) completes the result. □

Comparison with binary MaxRL and concurrent extensions. For a binary indicator R=1[y passes on ψ]∈{0,1}R = \mathbf{1}[y\text{ passes on }\psi] \in\{0,1\}, μθ(x,ψ)=pθ(x,ψ)\mu_\theta(x,\psi) = p_\theta(x,\psi), and the objective reduces to Ex,ψlog⁡pθ(x,ψ)\mathbb{E}_{x,\psi}\log p_\theta(x,\psi). Our formula gives ∇log⁡pθ(x,ψ)=Eθ[R⋅S]/pθ(x,ψ)=Eθ[S∣R=1]\nabla\log p_\theta(x,\psi) = \mathbb{E}_\theta[R \cdot S]/p_\theta(x,\psi) = \mathbb{E}_\theta[S \mid R=1], matching the MaxRL gradient of Tajwar et al. [47] for fixed (x,ψ)(x,\psi). A concurrent extension, ArgMaxRL [70], instead decomposes graded rewards into threshold events to target best-of-kk performance; both reduce to MaxRL for binary rewards.

Latent-success lifting

Proposition B.2. For fixed (x,ψ)(x,\psi), let Rmax⁡>0R_{\max} > 0 be an upper bound on R(x,y;ψ)R(x,y;\psi) and define a latent Bernoulli variable Z∣(y,x,ψ)∼Bernoulli⁡(R(x,y;ψ)/Rmax⁡)Z \mid(y,x,\psi) \sim\operatorname{Bernoulli}(R(x,y;\psi)/R_{\max}). Then

log⁡μθ(x,ψ)=log⁡pZ+log⁡Rmax⁡,pZ=Eθ[R/Rmax⁡]=Eθ,Z[Z].(19)\log\mu_\theta(x,\psi) = \log p_Z + \log R_{\max}, \qquad p_Z = \mathbb{E}_\theta[R/R_{\max}] = \mathbb{E}_{\theta,Z}[Z]. \tag*{(19)}

Applying binary MaxRL to the GG lifted samples (yi,Zi)(y_i,Z_i) gives the per-(x,ψ)(x,\psi) objective

JG(θ;x,ψ)=−∑k=1G(1−μθ(x,ψ)/Rmax⁡)kk,(20)J_G(\theta;x,\psi) = -\sum_{k=1}^{G}\frac{(1-\mu_\theta(x,\psi)/R_{\max})^k}{k}, \tag*{(20)}

which converges to log⁡μθ(x,ψ)\log\mu_\theta(x,\psi) (up to an additive constant log⁡Rmax⁡\log R_{\max}) as G→∞G \to\infty and satisfies ∇θJG=∇θJMaxRL+O(1/G)\nabla_\theta J_G = \nabla_\theta J_{\mathrm{MaxRL}} + O(1/G).

Proof. Since pZ=μθ(x,ψ)/Rmax⁡p_Z = \mu_\theta(x,\psi)/R_{\max}, log⁡μθ=log⁡Rmax⁡+log⁡pZ\log\mu_\theta= \log R_{\max} + \log p_Z. Truncating ∑k=1∞(1−pZ)k/k=log⁡(1/pZ)\sum_{k=1}^{\infty}(1-p_Z)^k/k = \log(1/p_Z) at k=Gk=G yields the finite-GG MaxRL objective of Tajwar et al. [47], whose gradient is ∑k=1G(1−pZ)k−1∇pZ=(1−(1−pZ)G)∇log⁡pZ→∇log⁡pZ\sum_{k=1}^{G}(1-p_Z)^{k-1}\nabla p_Z = (1-(1-p_Z)^G)\nabla\log p_Z \to\nabla\log p_Z as G→∞G \to\infty. One can substitute the conditional expectations under Z∣RZ \mid R into the numerator and denominator of the lifted advantage Ai=(Zi−Zˉ)/ZˉA_i=(Z_i-\bar{Z})/\bar{Z} (or taking G→∞G \to\infty) recovers the continuous-reward estimator. □

Sensitivity to reward offset

Proposition B.3. For a shifted reward R′=R+aR' = R+a with constant a>0a>0, JMaxRL(θ,R)=Ex,ψlog⁡(μθ(x,ψ)+a)J_{\mathrm{MaxRL}}(\theta,R) = \mathbb{E}_{x,\psi}\log(\mu_\theta(x,\psi)+a), and for each (x,ψ)(x,\psi)

∇log⁡(μθ+a)=∇μθμθ+a=μθμθ+a∇log⁡μθ.(21)\nabla\log(\mu_\theta+a) = \frac{\nabla\mu_\theta}{\mu_\theta+a} = \frac{\mu_\theta}{\mu_\theta+a}\nabla\log\mu_\theta. \tag*{(21)}

As a→∞a\to\infty the gradient approaches (1/a)Ex,ψ[μθ](1/a)\mathbb{E}_{x,\psi}[\mu_\theta] (standard expected-reward RL). For any a>0a>0, the per-(x,ψ)(x,\psi) weight becomes 1/(μθ+a)1/(\mu_\theta+a) rather than 1/μθ1/\mu_\theta, strictly attenuating the MaxRL emphasis on hard inputs.

Proof. ∇log⁡(μθ+a)=∇μθ/(μθ+a)\nabla\log(\mu_\theta+a)=\nabla\mu_\theta/(\mu_\theta+a). By the score-function identity, ∇μθ=Eθ[RS]\nabla\mu_\theta=\mathbb{E}_\theta[RS], so

∇log⁡(μθ+a)=Eθ[RS]μθ+a=μθμθ+a⋅Eθ[RS]μθ.\nabla\log(\mu_\theta+a)=\frac{\mathbb{E}_\theta[RS]}{\mu_\theta+a}=\frac{\mu_\theta}{\mu_\theta+a}\cdot\frac{\mathbb{E}_\theta[RS]}{\mu_\theta}.

The coefficient μθ/(μθ+a)∈(0,1)\mu_\theta/(\mu_\theta+a)\in(0,1) shrinks the MaxRL gradient toward the standard RL gradient, which corresponds to a→∞a\to\infty (where ∇log⁡(μθ+a)≈∇μθ/a\nabla\log(\mu_\theta+a)\approx\nabla\mu_\theta/a). □

Implication for reward design. Theorem B.3 shows why the reward Eq. (12) assigns failures a small positive value rather than zero or a large negative value. If failures score zero, a group of all-failures gives Ai=0A_i=0 and the policy receives no gradient. If failures score a large constant, MaxRL degrades toward standard RL. The failure scale s=0.2s=0.2 provides a fidelity-proportional gradient on hard inputs without washing out the MaxRL weighting. GRPO is insensitive to additive shifts (the group mean cancels), so this constraint applies only to MaxRL and Hybrid.

Hybrid Advantage Estimator: Analysis {#sec:C}

Fix an input xx and shared verifier state ∣ψ⟩|\psi\rangle with pass probability p=pθ(x,ψ)>0p=p_\theta(x,\psi)>0, and let EG\mathcal{E}_G denote the event that all GG sampled candidates pass on ψ\psi, which occurs with probability pGp^G. Conditioned on EG\mathcal{E}_G, the GG candidates are drawn i.i.d. from the conditional valid policy πθ+(y∣x,ψ)=πθ(y∣x)1[y passes]/p\pi_\theta^+(y\mid x,\psi)=\pi_\theta(y\mid x)\mathbf{1}[y\text{ passes}]/p. Because ri=b+gir_i=b+g_i on EG\mathcal{E}_G, the bonus bb cancels in AiGRPO=(gi−gˉ)/(σg+ϵ)A_i^{\mathrm{GRPO}}=(g_i-\bar{g})/(\sigma_g+\epsilon). Moreover, ∇θlog⁡πθ+(y∣x,ψ)=∇θlog⁡πθ(y∣x)−∇θlog⁡p\nabla_\theta\log\pi_\theta^+(y\mid x,\psi)=\nabla_\theta\log\pi_\theta(y\mid x)-\nabla_\theta\log p, and the constant ∇θlog⁡p\nabla_\theta\log p cancels against the zero-sum weights ∑i=1G(gi−gˉ)=0\sum_{i=1}^G(g_i-\bar{g})=0. As GG grows, (gˉ,σg)(\bar{g},\sigma_g) concentrates around the conditional mean μg+(x,ψ)=Eθ[g(y)∣y passes]\mu_g^+(x,\psi)=\mathbb{E}_\theta[g(y)\mid y\text{ passes}] and standard deviation σg+(x,ψ)\sigma_g^+(x,\psi), so the single-group GRPO gradient gGRPO=1G∑i=1GAiGRPO∇θlog⁡πθ(yi∣x)g^{\mathrm{GRPO}}=\frac{1}{G}\sum_{i=1}^G A_i^{\mathrm{GRPO}}\nabla_\theta\log\pi_\theta(y_i\mid x) converges in conditional expectation to the normalized gate-reduction gradient ∇θμg+(x,ψ)/(σg+(x,ψ)+ϵ)\nabla_\theta\mu_g^+(x,\psi)/(\sigma_g^+(x,\psi)+\epsilon) (with the threshold σg≤σmin⁡\sigma_g\le\sigma_{\min} zeroing out updates once gate scores saturate).

Across both branches of Eq. (17), total expectation decomposes the single-group Hybrid gradient as

Eθ[g^Hybrid∣x,ψ]=(1−pG)Eθ[g^MaxRL∣EGc,x,ψ]+pGEθ[g^GRPO∣EG,x,ψ].(22)\mathbb{E}_{\theta}\left[\hat{g}^{\mathrm{Hybrid}}\mid x,\psi\right]=(1-p^{G})\mathbb{E}_{\theta}\left[\hat{g}^{\mathrm{MaxRL}}\mid\mathcal{E}^{c}_{G},x,\psi\right]+p^{G}\mathbb{E}_{\theta}\left[\hat{g}^{\mathrm{GRPO}}\mid\mathcal{E}_{G},x,\psi\right]. \tag*{(22)}

When an input is not yet reliably solved (pG≪1p^{G}\ll1; e.g., p≤0.8p\leq0.8 gives p32<10−3p^{32}<10^{-3}), Pr⁡(EGc∣x,ψ)=1−pG≈1\Pr(\mathcal{E}^{c}_{G}\mid x,\psi)=1-p^{G}\approx1 and the first term matches the unconditional continuous MaxRL gradient of Appendix B up to O(pG)O(p^{G}), prioritizing equivalence. As p→1p\to1 (pG→1p^{G}\to1), the second term dominates and updates transition smoothly to GRPO gate-count optimization without additional schedule hyperparameters.

Theoretical Basis of Random-State Verification

This appendix gives the theoretical basis of the verifier of § 3.4. Throughout, nn is the number of qubits, d=2nd=2^{n}, and W=U(Cref)†U^(C^)W=U(C_{\mathrm{ref}})^{\dagger}\hat{U}(\hat{C}). For a state ∣ψ⟩\lvert\psi\rangle, writing F(ψ)≡F(C^;ψ)F(\psi)\equiv F(\hat{C};\psi), we define

F(ψ)=∣⟨ψ∣W∣ψ⟩∣2,X(ψ)=1−F(ψ)∈[0,1],(23)F(\psi)=\left|\langle\psi|W|\psi\rangle\right|^{2},\qquad X(\psi)=1-F(\psi)\in[0,1], \tag*{(23)}

and we compare the two circuits through the process fidelity

Fp=∣Tr⁡W∣2d2,rp=1−Fp.(24)F_{p}=\frac{|\operatorname{Tr}W|^{2}}{d^{2}},\qquad r_{p}=1-F_{p}. \tag*{(24)}

Since ∣Tr⁡W∣≤d|\operatorname{Tr}W|\leq d, with equality if and only if all eigenvalues of WW coincide, the two circuits are equivalent up to a global phase exactly when Fp=1F_{p}=1.

Single-state fidelity estimates average state fidelity

The verifier draws ∣ψ⟩\lvert\psi\rangle from the Haar measure. The second moment of this measure is Eψ[(∣ψ⟩⟨ψ∣)⊗2]=(I+S)/(d(d+1))\mathbb{E}_{\psi}[(\lvert\psi\rangle\langle\psi\rvert)^{\otimes2}]=(I+S)/(d(d+1)), where SS swaps the two tensor factors [71]. With Tr⁡[(A⊗B)S]=Tr⁡(AB)\operatorname{Tr}[(A\otimes B)S]=\operatorname{Tr}(AB), the average fidelity is

Fˉ=Eψ[F(ψ)]=Tr⁡(WW†)+∣Tr⁡W∣2d(d+1)=d+∣Tr⁡W∣2d(d+1).(25)\bar{F}=\mathbb{E}_{\psi}[F(\psi)]=\frac{\operatorname{Tr}(WW^{\dagger})+|\operatorname{Tr}W|^{2}}{d(d+1)}=\frac{d+|\operatorname{Tr}W|^{2}}{d(d+1)}. \tag*{(25)}

Substituting ∣Tr⁡W∣2=d2Fp|\operatorname{Tr}W|^{2}=d^{2}F_{p} gives

Fˉ=dFp+1d+1,ravg=1−Fˉ=dd+1rp.(26)\bar{F}=\frac{dF_{p}+1}{d+1},\qquad r_{\mathrm{avg}}=1-\bar{F}=\frac{d}{d+1}r_{p}. \tag*{(26)}

For any candidate fixed prior to drawing ∣ψ⟩\lvert\psi\rangle, the fidelity on one Haar-random state is therefore an unbiased estimate of the average state fidelity Fˉ\bar{F}, and its infidelity X(ψ)X(\psi) is an unbiased estimate of ravgr_{\mathrm{avg}}, which equals the process infidelity up to the factor d/(d+1)∈[32/33,1)d/(d+1)\in[32/33,1) for n≥5n\geq5. Errors in the two quantities are tied directly: a candidate is close to the reference on average over input states if and only if its process fidelity is close to one.

Statistical guarantee of multi-state re-verification

Consider a multi-state test that draws kk independent Haar-random test states and accepts a fixed candidate only if it passes on all kk states. We bound the probability of accepting a fixed candidate whose average infidelity is non-negligible. Diagonalize WW with eigenvalues λ1,…,λd\lambda_{1},\ldots,\lambda_{d}, ∣λi∣=1|\lambda_{i}|=1. By unitary invariance of the Haar measure, the weights pi=∣⟨i∣ψ⟩∣2p_{i}=|\langle i|\psi\rangle|^{2} in the eigenbasis are uniformly distributed on the simplex, (p1,…,pd)∼Dirichlet⁡(1,…,1)(p_{1},\ldots,p_{d})\sim\operatorname{Dirichlet}(1,\ldots,1). With aij=∣λi−λj∣2≥0a_{ij}=|\lambda_{i}-\lambda_{j}|^{2}\geq0,

X=1−∣∑ipiλi∣2=∑i<jaijpipj.(27)X=1-\left|\sum_{i}p_{i}\lambda_{i}\right|^{2}=\sum_{i<j}a_{ij}p_{i}p_{j}. \tag*{(27)}

The Dirichlet moments E[pipj]=1/(d(d+1))\mathbb{E}[p_{i}p_{j}]=1/(d(d+1)) for i≠ji\ne j give ravg=∑i<jaij/(d(d+1))r_{\mathrm{avg}}=\sum_{i<j}a_{ij}/(d(d+1)). For i<ji<j and u<vu<v, each fourth moment E[pipjpupv]\mathbb{E}[p_{i}p_{j}p_{u}p_{v}] appearing in X2X^{2} is at most 4/(d(d+1)(d+2)(d+3))4/(d(d+1)(d+2)(d+3)), so

E[X2]≤κdravg2,κd=4d(d+1)(d+2)(d+3)<4.(28)\mathbb{E}[X^{2}]\leq\kappa_{d}r_{\mathrm{avg}}^{2},\qquad\kappa_{d}=\frac{4d(d+1)}{(d+2)(d+3)}<4. \tag*{(28)}

Since X≥0X\geq0, the Paley–Zygmund inequality gives, for 0<τ<ravg0<\tau<r_{\mathrm{avg}},

Pr⁡ψ[X>τ]≥(1−τ/ravg)2ravg2E[X2]≥(1−τ/ravg)2κd.(29)\Pr_{\psi}[X>\tau]\geq\frac{(1-\tau/r_{\mathrm{avg}})^{2}r_{\mathrm{avg}}^{2}}{\mathbb{E}[X^{2}]}\geq\frac{(1-\tau/r_{\mathrm{avg}})^{2}}{\kappa_{d}}. \tag*{(29)}

A single random-state test accepts a candidate when X≤τFX\leq\tau_{F}. If ravg≥2τFr_{\mathrm{avg}}\geq2\tau_{F}, each test therefore rejects with probability at least (1/2)2/4=1/16(1/2)^{2}/4=1/16. Across kk independent random states, all of which must pass,

Pr⁡[accept]≤(15/16)kwhenever ravg≥2τF.(30)\Pr[\mathrm{accept}]\leq(15/16)^{k}\qquad\text{whenever }r_{\mathrm{avg}}\geq2\tau_{F}. \tag*{(30)}

This worst-case bound holds for any fixed candidate unitarily satisfying ravg≥2τFr_{\mathrm{avg}}\geq2\tau_{F} at every nn, so k≥ln⁡δ/ln⁡(15/16)k\geq\ln\delta/\ln(15/16) states suffice to drive the bound below δ\delta (e.g., k=108k=108 for δ=10−3\delta=10^{-3} and k=215k=215 for δ=10−6\delta=10^{-6}). By Eq. (26), any fixed candidate whose process infidelity is at least 2τF(d+1)/d2\tau_{F}(d+1)/d is rejected by kk independent random states with probability at least 1−(15/16)k1-(15/16)^{k}.

Infidelity of discrete Clifford+T errors

To contextualize the empirical process-infidelity distribution observed across the 32,000 candidates in § 6.1, we distinguish single-gate edits from multi-gate errors over G\mathcal{G}:

  1. Exact lower bound for single-gate edits. Suppose C^\hat{C} differs from CrefC_{\mathrm{ref}} by inserting, deleting, or substituting a single gate at an arbitrary position in the circuit, Cref=(Cbefore,G1,Cafter)C_{\mathrm{ref}}=(C_{\mathrm{before}},G_{1},C_{\mathrm{after}}) and C^=(Cbefore,G2,Cafter)\hat{C}=(C_{\mathrm{before}},G_{2},C_{\mathrm{after}}) for inequivalent G1,G2∈G∪{I}G_{1},G_{2}\in\mathcal{G}\cup\{I\}. Writing A=U(Cafter)A=U(C_{\mathrm{after}}) and B=U(Cbefore)B=U(C_{\mathrm{before}}), we have U(Cref)=A U(G1) BU(C_{\mathrm{ref}})=A\,U(G_{1})\,B, U(C^)=A U(G2) BU(\hat{C})=A\,U(G_{2})\,B, and W=B†U(G1)†A†AU(G2)B=B†U(G1)†U(G2)BW=B^{\dagger}U(G_{1})^{\dagger}A^{\dagger}AU(G_{2})B=B^{\dagger}U(G_{1})^{\dagger}U(G_{2})B. Both the shared suffix CafterC_{\mathrm{after}} and, by cyclic invariance of the trace, the shared prefix CbeforeC_{\mathrm{before}} cancel in Fp=∣Tr⁡(U(G1)†U(G2))∣2/d2F_{p}=|\operatorname{Tr}(U(G_{1})^{\dagger}U(G_{2}))|^{2}/d^{2}, regardless of circuit depth, entanglement, or whether CafterC_{\mathrm{after}} commutes with the edited gate. Because any pair (G1,G2)(G_{1},G_{2}) acts on at most four qubits and identity factors on untouched qubits cancel, finite enumeration gives the exact minimum non-zero process infidelity

rp,min⁡(1)=1−∣1+eiπ/4∣24=sin⁡2(π8)≈0.1464.(31)r_{p,\min}^{(1)}=1-\frac{|1+e^{i\pi/4}|^{2}}{4}=\sin^{2}\left(\frac{\pi}{8}\right)\approx0.1464. \tag*{(31)}

attained by an uncancelled ±π/4\pm\pi/4 (TT or T†T^{\dagger}) phase difference on one qubit (followed by 0.2714, 0.5000 for a single SS edit, 0.7500 for an inserted/deleted CNOT or CZ, and 1.0 for HH, XX, or ZZ).

  1. Multi-gate errors and empirical distribution. Because Clifford+T generates a dense subgroup of PU⁡(2n)\operatorname{PU}(2^{n}), rp,min⁡(1)r_{p,\min}^{(1)} is not a universal lower bound when multiple gates differ: for instance, reversing two non-commuting π/4\pi/4 rotations on one qubit

(W=T†(HT†H)T(HTH))(W = T^{\dagger}(HT^{\dagger}H)T(HTH)) yields rp=1−(1−2sin⁡4(π/8))2≈0.0839r_p = 1 - (1 - 2\sin^{4}(\pi/8))^{2} \approx0.0839; an mm-qubit controlled-ZZ discrepancy Cm−1ZC^{m-1}Z yields rp=1−(1−21−m)2≈22−mr_p = 1 - (1 - 2^{1-m})^{2} \approx2^{2-m} (0.12110.1211 at m=5m = 5, falling below 2τF=2×10−42\tau_F = 2 \times10^{-4} only for m≥15m \ge15); and long Solovay–Kitaev sequences can approach zero arbitrarily closely. Conversely, when an early erroneous token causes an autoregressive policy to generate a divergent continuation (Cafter′≠CafterC'_{\mathrm{after}} \ne C_{\mathrm{after}}), multiple gates differ without symmetric cancellation, explaining why no inequivalent candidate in § 6.1 falls below 0.14640.1464 (89.4%89.4\% have rp≥0.9r_p \ge0.9).

Use in training and evaluation

Training and fast decoding use a single random input state per group (k=1k = 1) with τF=10−4\tau_F = 10^{-4}; all GG candidates in a group share this state, evaluating candidates on a common input while reusing a single evolution of CrefC_{\mathrm{ref}}, and each candidate fixed prior to drawing ∣ψ⟩|\psi\rangle retains Fˉ\bar{F} as its marginal expected fidelity. For final evaluation (§ 6.1), all 80,674 selected best candidates across all reported model–bucket evaluations are deterministically certified against CrefC_{\mathrm{ref}} via exact unitary comparison for n≤10n \le10 (∣Tr⁡(U(Cref)†U(C^))∣/d≥1−10−8|\operatorname{Tr}(U(C_{\mathrm{ref}})^{\dagger}U(\hat{C}))|/d \ge1 - 10^{-8}; 24,910 candidates) and symbolic ZX-calculus equivalence verification (pyzx.Circuit.verify_equality) across all 5≤n≤205 \le n \le20.

Additional Experimental Results

Figure 8 to Figure 10 present supplementary training trajectories, test-time scaling curves on longer buckets, and per-qubit gate-reduction breakdowns complementing § 6.

Figure 8. Stage-0 and stage-1 training trajectories. (a) Stage-0 SFT validation cross-entropy loss, marking the step-248,000 checkpoint used to initialize RL. (b) Stage-1 mean rollout reward (exponential moving average, α=0.92\alpha= 0.92). (c) Stage-1 pre-clip gradient ℓ2\ell_2 norm (EMA, α=0.95\alpha= 0.95).

Figure 10. Stage-1 per-qubit gate reductions relative to CsrcC_{\mathrm{src}} on the common success set (ncom=5,443n_{\mathrm{com}} = 5{,}443, 20–100-gate test split, K=32K = 32, T=0.2\mathcal{T} = 0.2). (a) Total gates reduced. (b) Two-qubit gates reduced. (c) Non-Clifford TT gates reduced.

Figure 8 shows the stage-0 supervised validation loss alongside stage-1 rollout rewards and pre-clip gradient norms; across GRPO, MaxRL, and Hybrid, pre-clip gradient norms remain within a comparable bounded range (15–35) prior to unit norm clipping (which effectively normalizes step sizes across estimators). Figure 9(a,Figure 9b) plots validation accuracy and reward across the full 262,144-step stage-2 curriculum, showing the immediate inflection on 201–300 and unseen 301–400 gates at the Stage-2a→2b transition (step 116,736), while Figure 9(c) reports K∈{1,…,64}K \in\{1, \ldots, 64\} budget scaling of S2b-Hybrid on the 992-circuit stratified subsets of 201–300 and 301–400 gates. Finally, Figure 10 gives the per-qubit breakdown (5≤n≤205 \le n \le20) of total, two-qubit, and TT-gate reductions across all stage-1 policies on the common success set of Table 4.

References

  1. [1]Peter W. Shor. 1997. Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. SIAM J. Comput. 26, 5 (1997), 1484–1509. https://doi.org/10.1137/S0097539795293172
  2. [2]Lov K. Grover. 1996. A fast quantum mechanical algorithm for database search. In Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing (STOC ’96). ACM, New York, NY, USA, 212–219. https://doi.org/10.1145/237814.237866
  3. [3]Michael A. Nielsen and Isaac L. Chuang. 2010. Quantum Computation and Quantum Information (10th anniversary ed.). Cambridge University Press, Cambridge, UK. https://doi.org/10.1017/CBO9780511976667
  4. [4]Google Quantum AI and Collaborators. 2025. Quantum error correction below the surface code threshold. Nature 638, 8052 (2025), 920–926. https://doi.org/10.1038/s41586-024-08449-y
  5. [5]Dolev Bluvstein, Simon J. Evered, Alexandra A. Geim, Sophie H. Li, Hengyun Zhou, Tom Manovitz, Sepehr Ebadi, Madelyn Cain, Marcin Kalinowski, Dominik Hangleiter, J. Pablo Bonilla Ataides, Nishad Maskara, Iris Cong, Xun Gao, Pedro Sales Rodriguez, Thomas Karolyshyn, Giulia Semeghini, Michael J. Gullans, Markus Greiner, Vladan Vuletić, and Mikhail D. Lukin. 2024. Logical quantum processor based on reconfigurable atom arrays. Nature 626, 7997 (2024), 58–65. https://doi.org/10.1038/s41586-023-06927-3
  6. [6]Craig Gidney and Martin Ekerå. 2021. How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits. Quantum 5 (2021), 433. https://doi.org/10.22331/q-2021-04-15-433
  7. [7]Craig Gidney. 2025. How to factor 2048 bit RSA integers with less than a million noisy qubits. arXiv:2505.15917 [quant-ph]. https://arxiv.org/abs/2505.15917
  8. [8]John Preskill. 2018. Quantum Computing in the NISQ era and beyond. Quantum 2 (2018), 79. https://doi.org/10.22331/q-2018-08-06-79
  9. [9]Gushu Li, Yunfan Yao, and Yuan Xie. 2019. Tackling the Qubit Mapping Problem for NISQ-Era Quantum Devices. In Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’19). ACM, New York, NY, USA, 1001–1014. https://doi.org/10.1145/3297859.3304023
  10. [10]Alwin Zulehner, Alexandru Paler, and Robert Wille. 2019. An Efficient Methodology for Mapping Quantum Circuits to the IBM QX Architectures. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 38, 7 (2019), 1226–1236. https://doi.org/10.1109/TCAD.2018.2846658
  11. [11]Ali Javad-Abadi, Matthew Treinish, Kevin Krishulic, Christopher J. Wood, Jake Lishman, Julien Gacon, Simon Martiel, Paul D. Nation, Lev S. Bishop, Andrew W. Cross, Blake R. Johnson, and Jay M. Gambetta. 2024. Quantum computing with Qiskit. arXiv:2405.08810 [quant-ph]. https://arxiv.org/abs/2405.08810
  12. [12]Seyon Sivarajah, Silas Dilles, Alexander Cowtan, Will Simmons, Alec Edgington, and Ross Duncan. 2021. 1 ket>: a retargetable compiler for NISQ devices. Quantum Science and Technology 6, 1 (2021), 014003. https://doi.org/10.1088/2058-9565/ab8e92
  13. [13]Aleks Kissinger and John van de Wetering. 2020. PyZX: Large Scale Automated Diagrammatic Reasoning. Electronic Proceedings in Theoretical Computer Science 318 (2020), 229–241. https://doi.org/10.4204/EPTCS.318.14
  14. [14]Kesha Hietala, Robert Rand, Shih-Hun Hung, Xiaodi Wu, and Michael Hicks. 2021. A Verified Optimizer for Quantum Circuits. Proceedings of the ACM on Programming Languages 5, POPL (2021), 1–29. https://doi.org/10.1145/3434318
  15. [15]Bryan Eastin and Emanuel Knill. 2009. Restrictions on Transversal Encoded Quantum Gate Sets. Physical Review Letters 102 (2009), 110502. https://doi.org/10.1103/PhysRevLett.102.110502
  16. [16]Jonas T. Anderson, Guillaume Duclos-Cianci, and David Poulin. 2014. Fault-Tolerant Conversion between the Steane and Reed-Muller Quantum Codes. Physical Review Letters 113 (2014), 080501. https://doi.org/10.1103/PhysRevLett.113.080501
  17. [17]Sergey Bravyi and Alexei Kitaev. 2005. Universal quantum computation with ideal Clifford gates and noisy ancillas. Physical Review A 71, 2 (2005), 022316. https://doi.org/10.1103/PhysRevA.71.022316
  18. [18]Daniel Litinski. 2019. Magic State Distillation: Not as Costly as You Think. Quantum 3 (2019), 205. https://doi.org/10.22331/q-2019-12-02-205
  19. [19]Craig Gidney, Noah Shutty, and Cody Jones. 2024. Magic State Cultivation: Growing T States as Cheap as CNOT Gates. arXiv:2409.17595 [quant-ph] https://arxiv.org/abs/2409.17595
  20. [20]John van de Wetering and Matt Amy. 2024. Optimising quantum circuits is generally hard. arXiv:2310.05958 [quant-ph] https://arxiv.org/abs/2310.05958
  21. [21]Matthew Amy, Dmitri Maslov, and Michele Mosca. 2014. Polynomial-Time T-Depth Optimization of Clifford+T Circuits Via Matroid Partitioning. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 33, 10 (2014), 1476–1489. https://doi.org/10.1109/TCAD.2014.2341953
  22. [22]Yunseong Nam, Neil J. Ross, and Dmitri Maslov. 2018. Automated optimization of large quantum circuits with continuous parameters. npj Quantum Information 4, 1 (2018), 23. https://doi.org/10.1038/s41534-018-0072-4
  23. [23]Mingxuan Xu, Zikun Li, Oded Padon, Sina Lin, Jessica Pointing, Auguste Hirth, Henry Ma, Jens Palsberg, Alex Aiken, Umut A. Acar, and Zhaohua Jia. 2022. Quartz: Superoptimization of Quantum Circuits. In Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI ’22). ACM, New York, NY, USA, 625–640. https://doi.org/10.1145/3519939.3513433
  24. [24]Amanda Xu, Abtin Molavi, Lauren Pick, Swamit Tannu, and Aws Albarghouthi. 2023. Synthesizing Quantum-Circuit Optimizers. Proceedings of the ACM on Programming Languages 7, PLDI (2023), 835–859. https://doi.org/10.1145/3591254
  25. [25]Jessica Pointing, Oded Padon, Zhhiao Jia, Henry Ma, Auguste Hirth, Jens Palsberg, and Alex Aiken. 2024. Quanto: optimizing quantum circuits with automatic generation of circuit identities. Quantum Science and Technology 9, 4 (2024), 045009. https://doi.org/10.1088/2058-9565/ad5b16
  26. [26]Amanda Xu, Abtin Molavi, Swamit Tannu, and Aws Albarghouthi. 2025. Optimizing Quantum Circuits, Fast and Slow. In Proceedings of the 30th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1 (ASPLOS ’25). ACM, New York, NY, USA, 777–793. https://doi.org/10.1145/3669940.3707240
  27. [27]Bob Coecke and Ross Duncan. 2011. Interacting quantum observables: categorical algebra and diagrammatics. New Journal of Physics 13, 4 (2011), 043016. https://doi.org/10.1088/1367-2630/13/4/043016
  28. [28]Ross Duncan, Aleks Kissinger, Simon Perdrix, and John van de Wetering. 2020. Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus. Quantum 4 (2020), 279. https://doi.org/10.22331/q-2020-06-04-279
  29. [29]Aleks Kissinger and John van de Wetering. 2020. Reducing the number of non-Clifford gates in quantum circuits. Physical Review A 102, 2 (2020), 022406. https://doi.org/10.1103/PhysRevA.102.022406
  30. [30]John van de Wetering. 2020. ZX-calculus for the working quantum computer scientist. arXiv:2012.13966 [quant-ph] https://arxiv.org/abs/2012.13966
  31. [31]Thomas Fösel, Murphy Yuezhen Niu, Florian Marquardt, and Li Li. 2021. Quantum circuit optimization with deep reinforcement learning. arXiv:2103.07585 [quant-ph] https://arxiv.org/abs/2103.07585
  32. [32]Zikun Li, Jinjun Peng, Yixuan Mei, Sina Lin, Yi Wu, Oded Padon, and Zhihao Jia. 2024. Quarl: A Learning-Based Quantum Circuit Optimizer. Proceedings of the ACM on Programming Languages 8, OOPSLA1 (2024), 555–582. https://doi.org/10.1145/3649831
  33. [33]David Kremer, Victor Villar, Hanhee Paik, Ivan Duran, Ismael Faro, and Juan Cruz-Benito. 2024. Practical and efficient quantum circuit synthesis and transpiling with Reinforcement Learning. arXiv:2405.13196 [quant-ph] https://arxiv.org/abs/2405.13196
  34. [34]Maximilian Nägele and Florian Marquardt. 2024. Optimizing ZX-diagrams with deep reinforcement learning. Machine Learning: Science and Technology 5, 3 (2024), 035077. https://doi.org/10.1088/2632-2153/ad76f7
  35. [35]Jordi Riu, Jan Nogué, Gerard Vilaplana, Artur Garcia-Saez, and Marta P. Estarellas. 2025. Reinforcement Learning Based Quantum Circuit Optimization via ZX-Calculus. Quantum 9 (2025), 1758. https://doi.org/10.22331/q-2025-05-28-1758
  36. [36]Alexander Mattick, Maninarman Periyasamy, Christian Ufrecht, Abhishek Y. Dubey, Christopher Mutschler, Axel Plinge, and Daniel D. Scherer. 2025. Optimizing Quantum Circuits via ZX Diagrams using Reinforcement Learning and Graph Neural Networks. arXiv:2504.03429 [cs.LG] https://arxiv.org/abs/2504.03429
  37. [37]Francisco J. R. Ruiz, Tuomas Laakkonen, Johannes Bausch, Matej Balog, Mohammadamin Barekatain, Francisco J. H. Heras, Alexander Novikov, Nathan Fitzpatrick, Bernardino Romera-Paredes, John van de Wetering, Alhussein Fawzi, Konstantinos Meichanetzidis, and Pushmeet Kohli. 2025. Quantum circuit optimization with AlphaTensor. Nature Machine Intelligence 7, 3 (2025), 374–385. https://doi.org/10.1038/s42256-025-01001-1
  38. [38]Florian Furrütter, Gorka Muñoz-Gil, and Hans J. Briegel. 2024. Quantum circuit synthesis with diffusion models. Nature Machine Intelligence 6, 5 (2024), 515–524. https://doi.org/10.1038/s42256-024-00831-9
  39. [39]Lino S. Hofstetter, Lia Yeh, and Prakash Murali. 2026. Bridge of Ψ’s: Quantum Circuit Optimization with Schrödinger Bridges. arXiv:2609.25947 [quant-ph] https://arxiv.org/abs/2609.25947
  40. [40]Linus Jern, Valter Uotila, Cong Yu, and Bo Zhao. 2025. Agent-Q: Fine-Tuning Large Language Models for Quantum Circuit Generation and Optimization. In 2025 IEEE International Conference on Quantum Computing and Engineering (QCE). IEEE, 1621–1632. https://doi.org/10.1109/QCE65121.2025.00179
  41. [41]Mehdi Saeedi, Eddie Richter, and Paul Hartke. 2026. When Close Enough Is Not Enough: Autoregressive Drift in Quantum Circuit Synthesis. arXiv:2607.12780 [quant-ph] https://arxiv.org/abs/2607.12780
  42. [42]Andrew W. Cross, Lev S. Bishop, John A. Smolin, and Jay M. Gambetta. 2017. Open Quantum Assembly Language. arXiv:1707.03429 [quant-ph] https://arxiv.org/abs/1707.03429
  43. [43]Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven Chu Hong Hoi. 2022. CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning. In Advances in Neural Information Processing Systems, Vol. 35. 21314–21328. https://doi.org/10.52202/068431-1549
  44. [44]Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchen Zheng, Y. K. Li, Y. Wu, and Daya Guo. 2024. DeepSeek-Math: Pushing the Limits of Mathematical Reasoning in Open Language Models. arXiv:2402.03300 [cs.CL] https://arxiv.org/abs/2402.03300
  45. [45]Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Peiyu Wang, Qihao Zhu, Runxin Xu, Ruoyu Zhang, et al. 2025. DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning. Nature 645, 8081 (2025), 633–638. https://doi.org/10.1038/s41586-025-09422-9
  46. [46]Long Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida, Carroll Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, John Schulman, Jacob Hilton, Fraser Kelton, Luke Miller, Maddie Simens, Amanda Askell, Peter Welinder, Paul F. Christiano, Jan Leike, and Ryan Lowe. 2022. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems, Vol. 35. 27730–27744. https://doi.org/10.52202/068431-2011
  47. [47]Fahim Tajwar, Guanning Zeng, Yueer Zhou, Yuda Song, Daman Arora, Yiding Jiang, Jeff Schneider, Ruslan Salakhutdinov, Haiwen Feng, and Andrea Zanette. 2026. Maximum Likelihood Reinforcement Learning. In Proceedings of the 43rd International Conference on Machine Learning (ICML) (Proceedings of Machine Learning Research, Vol. 306). PMLR, 118190–118245. arXiv:2602.02710 [cs.LG] https://proceedings.mlr.press/v306/tajwar26a.htmlarxiv.org/abs/2602.02710
  48. [48]Dominik Janzing, Pawel Wocjan, and Thomas Beth. 2005. “Non-Identity-Check” is OMA-complete. International Journal of Quantum Information 3, 3 (2005), 463–473. https://doi.org/10.1142/S0219749905001067
  49. [49]Miriam Backens, Hector Miller-Bakewell, Giovanni de Felice, Leo Lobski, and John van de Wetering. 2021. There and back again: A circuit extraction tale. Quantum 5 (2021), 421. https://doi.org/10.22331/q-2021-03-25-421
  50. [50]Niel de Beaudrap, Aleks Kissinger, and John van de Wetering. 2022. Circuit Extraction for ZX-Diagrams Can Be #P-Hard. In 49th International Colloquium on Automata, Languages, and Programming (ICALP 2022) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 229), Mikołaj Bojańczyk, Emanuela Merelli, and David P. Woodruff (Eds.). Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany, 119:1–119:19. https://doi.org/10.4230/LIPIcs.ICALP.2022.119
  51. [51]Korbinian Staudacher, Tobias Guggemos, Sophia Grundner-Culemann, and Wolfgang Gehrke. 2023. Reducing 2-Qubit Gate Count for ZX-Calculus based Quantum Circuit Optimization. Electronic Proceedings in Theoretical Computer Science 394 (2023), 29–45. https://doi.org/10.4204/EPTCS.394.3 Proceedings of Quantum Physics and Logic (QPL 2022).
  52. [52]John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. 2017. Proximal Policy Optimization Algorithms. arXiv:1707.06347 [cs.LG] https://arxiv.org/abs/1707.06347
  53. [53]François Chardon, Alexandre Krajenbrink, Konstantinos Meichanetzidis, and Richie Yeung. 2023. Teaching small transformers to rewrite ZX diagrams. In The 3rd Workshop on Mathematical Reasoning and AI (MATH-AI) at NeurIPS 2023. https://openreview.net/forum?id=btQ7Bt1NLF
  54. [54]Nicolas Dupuis, Luca Buratti, Sanjay Vishwakarma, Aitana Viudes Forrat, David Kremer, Ismael Faro, Ruchir Puri, and Juan Cruz-Benito. 2024. Qiskit Code Assistant: Training LLMs for Generating Quantum Computing Code. In 2024 IEEE LLM Aided Design Workshop (LAD). IEEE, 1–4. https://doi.org/10.1109/LAD62341.2024.10691762
  55. [55]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention Is All You Need. In Advances in Neural Information Processing Systems, Vol. 30. 5998–6008. https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1ba37c6-Abstract.htmlarxiv.org/abs/1706.03762
  56. [56]Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katherine Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zheitao Gong, Sina Samangooei, Marianne Monteiro, Jacob L. Menick, Sebastian Borgeaud, Andy Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karén Simonyan. 2022. Flamingo: a Visual Language Model for Few-Shot Learning. In Advances in Neural Information Processing Systems, Vol. 35. 23716–23736. https://doi.org/10.52202/068431-1723
  57. [57]Thomas N. Kipf and Max Welling. 2017. Semi-Supervised Classification with Graph Convolutional Networks. In International Conference on Learning Representations (ICLR). arXiv:1609.02907 [cs.LG] https://arxiv.org/abs/1609.02907
  58. [58]Ruibin Xiong, Yunchang Li, Weiran Zhang, Di He, Kaixuan Sheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, and Tie-Yan Liu. 2020. On Layer Normalization in the Transformer Architecture. In Proceedings of the 37th International Conference on Machine Learning (ICML) (Proceedings of Machine Learning Research, Vol. 119). PMLR, 10524–10533. https://proceedings.mlr.press/v119/xiong20b.htmlarxiv.org/abs/2002.04745
  59. [59]Jianlin Su, Murtadha Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. 2024. RoFormer: Enhanced Transformer with Rotary Position Embedding. Neurocomputing 568 (2024), 127063. https://doi.org/10.1016/j.neucom.2023.127063
  60. [60]Yasunari Suzuki, Yoshiaki Kawase, Yuya Masumura, Yuria Hiraga, Masahiro Nakadai, Jiebao Chen, Ken M. Nakanishi, Kosuke Mitarai, Ryosuke Imai, Shiro Tamiya, Takahiro Yamamoto, Tennin Yan, Toru Kawakubo, Yuya O. Nakagawa, Yohei Ibe, Youyuan Zhang, Hirotsugu Yamashita, Hikaru Yoshimura, Akihiro Hayashi, and Keisuke Fujii. 2021. Qulacs: a fast and versatile quantum circuit simulator for research purpose. Quantum 5 (2021), 559. https://doi.org/10.22331/q-2021-10-06-559
  61. [61]Michał Horodecki, Paweł Horodecki, and Ryszard Horodecki. 1999. General teleportation channel, singlet fraction, and quasidistillation. Physical Review A 60, 3 (1999), 1888–1898. https://doi.org/10.1103/PhysRevA.60.1888
  62. [62]Michael A. Nielsen. 2002. A simple formula for the average gate fidelity of a quantum dynamical operation. Physics Letters A 303, 4 (2002), 249–252. https://doi.org/10.1016/S0375-9601(02)01272-0
  63. [63]Calum Holker. 2023. Causal Flow Preserving Optimisation of Quantum Circuits in the ZX-calculus. arXiv:2312.02793 [quant-ph] https://arxiv.org/abs/2312.02793
  64. [64]Ilya Loshchilov and Frank Hutter. 2019. Decoupled Weight Decay Regularization. In International Conference on Learning Representations (ICLR). arXiv:1711.05101 [cs.LG] https://arxiv.org/abs/1711.05101
  65. [65]Yoshua Bengio, Jérôme Louradour, Ronan Collobert, and Jason Weston. 2009. Curriculum learning. In Proceedings of the 26th Annual International Conference on Machine Learning (ICML ’09). ACM, New York, NY, USA, 41–48. https://doi.org/10.1145/1553374.1553380
  66. [66]Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. 2021. Evaluating Large Language Models Trained on Code. arXiv:2107.03374 [cs.LG] https://arxiv.org/abs/2107.03374
  67. [67]Tom Peham, Lukas Burgholzer, and Robert Wille. 2022. Equivalence Checking of Quantum Circuits with the ZX-Calculus. IEEE Journal on Emerging and Selected Topics in Circuits and Systems 12, 3 (2022), 662–675. https://doi.org/10.1109/JETCAS.2022.3204204
  68. [68]Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Riedel, Martin Raison, Alykhane Tejani, Sachan Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. 2019. PyTorch: An Imperative Style, High-Performance Deep Learning Library. In Advances in Neural Information Processing Systems, Vol. 32. 8024–8035. https://proceedings.neurips.cc/paper/2019/hash/bdcca28f8eef792f2bfa9f701277740-Abstr act.htmlarxiv.org/abs/1912.01703
  69. [69]Matthias Fey and Jan Eric Lenssen. 2019. Fast Graph Representation Learning with PyTorch Geometric. In ICLR Workshop on Representation Learning on Graphs and Manifolds (RLGM). arXiv:1903.02428 [cs.LG] https://arxiv.org/abs/1903.02428
  70. [70]doubleAI. 2026. ArgMaxRL: Generalizing MaxRL to Continuous Rewards. Blog post. https://www.doubleai.com/research/argmaxrl-generalizing-maxrl-to-continuous-rewards Accessed 2026-11-11.
  71. [71]Antonio Anna Mele. 2024. Introduction to Haar Measure Tools in Quantum Information: A Beginner’s Tutorial. Quantum 8 (2024), 1340. https://doi.org/10.22331/q-2024-05-08-1340

Paper details

vlnc:W_j7bvv9vt
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 6

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents