Agentic AI for Discovering Fault-Tolerant Quantum Circuits
Authors: Aritra Lahiri, Florian Marquardt
Organizations: Max Planck Institute for the Science of Light, 91058 Erlangen, Germany · Department of Physics, Friedrich-Alexander University Erlangen-Nürnberg, 91058 Erlangen, Germany
Scaling quantum computing toward practical quantum advantage is currently limited by the efficiency of circuits that operate on information encoded by quantum error-correcting codes. The full stack of quantum computing encompasses several tasks: preparation of logical code states, implementation of logical gates, logical routines on encoded qubits, etc. Yet, these circuits are largely designed by hand for individual cases, with some recent works incorporating machine learning for certain aspects. We formulate this problem as agentic evolutionary program synthesis, wherein a large language model, leveraging its pretraining knowledge and tool-use proficiency, and guided by a circuit verifier, evolves a program that defines a Clifford circuit for a wide range of curated tasks such as logical state preparation, logical gate design, and logical routines such as code-switching, code growth, etc. Our approach consistently finds fault-tolerant circuits for all of these tasks, each verified by an exhaustive check over faults.
Figures & tables
Figure 1: Starting with some stabilizer codes (top left), followed by a task specification (top right) that includes logical state preparation, logical gate design, or further applications such as code-switching, etc., a large language model (LLM) discovers fault-tolerant circuits. The LLM is a part of an agentic loop (bottom right), with access to a circuit verification tool to check for fault tolerance. This is incorporated in an evolutionary search (bottom left), where the LLM’s proposals are refined iteratively.
Figure 2: Overview of the agentic FunSearch method applied to quantum circuits. Left: the prompt, illustrated for a logical CNOT ( CNOT ) between two logical qubits encoded by the [[5,1,3]] perfect code (see Sec. III.2 ). It starts with a natural-language description of the task, followed by a list of the target stabilizers, here the Choi state generators on all physical and reference qubits. These include the code stabilizers, labeled “checks”, and the stabilizers of the Bell pair between the logical and the reference qubits after applying the desired logical operation (here, CNOT ), labeled “after CNOT ”. Additionally, the prompt also specifies the qubit layout, including the locations of the data and ancilla qubits, the allowed couplings for two-qubit gates, the gate set, and a primer on the relevant physics and the fault tolerance requirement. Right: the hybrid agentic FunSearch loop. The LLM writes a Python program defining a circuit following our custom API. The verifier checks if the circuit achieves the target, and obtains the fault tolerance metrics. These metrics, along with the packed (maximizing parallel qubit utilization) circuit, are attached to each program as feedback. The program is then added to the island database, and ranked by these metrics (see Eq. ( 2 )). The best programs from the islands, along with their feedback, are included in the prompt to the LLM in the subsequent generation. In each generation, we instruct the LLM to write scratchpad notes, which serve as memory and are appended to the next generation’s prompt. The best programs from each island migrate to the neighbouring islands periodically. The LLM also calls the verifier directly through tool calls, which lets it test its proposals before submitting its program in each generation. After some generations, we select the best program as the solution.
Table 1: Logical-state preparation tasks. All cases prepare ∣0L⟩ , except for the [[5,1,3]] code which prepares ∣1L⟩ . Gate set: H, S, X, Z, CNOT, CZ, ancilla measurement, and conditional X, Z. For the CSS codes, we use the ∣0L⟩ simplification of the fault tolerance criterion (Appendix B ). “anc.” counts the ancillae available in the layout, and “used” those that the circuit actually uses. “det.” counts deterministic measurements and “2q” two-qubit gates. silent 1/2/3/4 lists the silent events of order 1 , 2 , 3 and 4 , comprising as many simultaneous faults. “–” denotes an order that is not enumerated, either because the code distance does not require it, or for silent 3,4 the lower orders are already non-zero. Bold numbers mark the best entry for a given code and connectivity. Labels such as 19_4_0 are the file names in the repository [ 46 ] of Ref. [ 13 ] , and ME (measurement encoding) and UEA (unitary encoding with ancilla) follow Ref. [ 44 ] . For the [[25,1,5]] code with all-to-all connectivity, we show the shallowest circuit, and a zero waste circuit, both extracted from the programs generated over a single search. The hex layout is similar to the native layout, but with each ancilla’s coupling to the data qubit below it removed [ 47 ] . “multi-size” refers to a single program evolved simultaneously for all d∈{3,5,7,9} . For the [[7,1,3]] code, “multi-size † ” is the [[7,1,3]] circuit of a separate multi-size search. The circuits of Ref. [ 44 ] have no detectors, so they have no heralded or wasted events.
Table 2: Logical gate design tasks. The columns are as in Tab. 1 . The gate set is that of Tab. 1 , extended by S † , Y, CY for the perfect-code CNOT , and by X , CY for the [[8,3,2]] code. For the surface-code S , the patch is placed either on its native layout (“native”), or at the centre of a larger one corresponding to the native patch of a higher-distance code, as specified. The embedded circuits come from a separate search per distance (“single-size”), the others from a simultaneous search over both distances (“multi-size”). The multi-size program branches on distance instead of being size-general. The [[8,3,2]] code uses the cube layout of Ref. [ 15 ] , where the data qubits are coupled along the edges of a cube and a single ancilla at its centre is coupled to all of them. The subscripts of Hˉ label the logical qubits it acts on. All circuits show undecodable events as it is an error-detecting code. For the [[15,1,3]] Reed-Muller and surface codes, the X and Z parts of event residuals are checked separately against Eq. ( 1 ) (Appendix B ). The undecodable cost of the CNOT3f from Ref. [ 51 ] is left blank as we do not replicate the classical decoding and correction using the syndrome and flags as mentioned in their work. Our results for this logical CNOT on [[5,1,3]] code come from two separate searches, using two and five ancillae. For the latter, (A) and (B) are two results with the same score, but different two-qubit gate counts. Bold numbers mark the best entry for a given code, gate, and layout.
Figure 3: Steane to Reed-Muller code switch with all-to-all connectivity, and 2 ancillae (Tab. 3 ): (a) Depth and discards (undecodable- and forfeit-cost, cf. Eq. ( 3 )) of the best program up to each generation. There are no silent events already in the first generation. Since the ranking is lexicographic, a lower-priority metric can worsen while a higher-priority one improves, e.g., between generations 2 and 3 , the undecodable-cost drops while the depth rises. (b) The best circuit, switching the Steane code on qubits q0 - q6 to the Reed-Muller code on q0 - q14 , using two ancillae q15 - q16 . The green boxes denote the detectors. Their outcomes are used by a QEC round to correct the faults (see Sec. II ). We shade alternate layers grey and white.
Table 3: Further applications: a logical Bell pair, code switching, and code growth. The gate set is as in Tab. 1 . The Bell pair is a state preparation task, so its columns are as in Tab. 1 . The code switches and growths are scored like logical gates by Eq. ( 3 ), so their columns mirror Tab. 2 . The Bell pair is the logical (∣0L0L⟩+∣1L1L⟩)/2 on two perfect-code encoded logical qubits. The Steane (S) → Reed-Muller (RM) switch moves a logical qubit in place from the S code to the RM code, and the RM → S switch switches and moves it from an RM block to a fresh S block. The growth takes the rotated surface code from d=3 to d=5 , as well as d=5 to d=7 , on its native layout, and the other tasks use all-to-all connectivity. We use the fault tolerance criterion of the final code. For the growth, the X and Z parts of event residuals are checked separately against Eq. ( 1 ) (see Appendix B ). The growth results inevitably have non-zero undecodable-costs, as explained in Sec. III.3 .
Figure 4: (a) The record rate of each LLM tier, i.e., the percentage of its programs that improve the best score found so far by any tier (tiers mentioned above the panels). All panels consider all programs up to the generation of the best program, excluding the seeding generations, which do not call the base tier. Next to each bar, we show the number of records / generated programs. We show three targets, each from a single search: the logical Hadamard on qubits 0,1,2 , and 0,1 on the [[8,3,2]] code, and the Steane to Reed-Muller code switch. Except for the Steane to Reed-Muller switch, the rest were obtained separately from those in Tabs. 2 and 3 by allocating more proposals to GPT-6-luna. The elite tier achieves a significantly higher record rate. (b) Mean word count (error bars represent ±1 standard deviation) per scratchpad note for all programs (not just record candidates). For the cases shown here, increasing GPT-6-luna’s reasoning effort from high to max raises word count by ≈25% . Switching to a better LLM, GPT-6.1-sol, at the same high reasoning effort, increases the word count by ⪆125% . The higher word count suggests a greater number of hypotheses tested, and ideas left behind. We present the notes for the Reed-Muller to Steane switch in Fig. 6 , showing this trend.
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: The circuit for the Reed-Muller (RM) to Steane (S) switch, with all-to-all connectivity, and 16 ancillae. The dark-green boxes show random measurements, and the light-green box is a detector. The orange boxes show conditional Paulis, with their conditions beside them. We shade alternate layers grey and white. It reads q7 - q14 of the RM block q0 - q14 in the X basis, and moves the face q0 - q6 to the fresh S block q15 - q21 . q22 - q37 are ancillae.
Figure 6: Scratchpad notes from the Steane to Reed-Muller switch search of Fig. 4 , by (a) the base, (b) the strong and (c) the elite tier. All three notes come from island 0 and accompany a new record. The record changes the signature (silent-cost, herald, waste, depth) from (0,0,0,21) to (0,0,0,20) in (a), from (0,0,0,41) to (0,0,0,38) in (b), and from (0,0,0,31) to (0,0,0,26) in (c). Their lengths, 173, 206 and 445 words, are close to the means of their tiers, 169, 221 and 452 words.
The timeline by which quantum computers can solve breakthrough problems in science depends on improved quantum algorithms as much as on better hardware. Such algorithmic advances are typically achieved through many years of expert human collaboration. In mathematics and computer science, large language models have accelerated progress through automated discovery loops. However, quantum algorithms can only be evaluated by classical computers on restricted or small instances. Here we demonstrate automated discovery of quantum programs beyond these regimes including order-of-magnitude improvements on scientific applications. To achieve this, we build a quantum program library in the Lean theorem prover in which Gemini 4 agents synthesize novel programs against formal problem specifications and verify their correctness and cost. Agent teams collaborate, sharing results and knowledge through wikis and discussing ideas at organized conferences. Our results improve on prior baselines for parallel search (up to 2.55x), quantum arithmetic (290x), and simulations relevant to fusion, photochemistry and drug-metabolism by 11x, 8x and 2.5x respectively. Combining human and artificial intelligence at scale, under the rigor of mathematical proof, lets researchers design algorithms that today's classical and quantum computers cannot test, shortening the path to practical quantum computation.
Sergey Shirobokov, Ben Jaderberg, Katerina Hristova +22
Scientific code generation can produce executable programs that fail to compute the intended scientific object. We study this problem in language-model synthesis of Clifford circuits, which prepare the stabilizer states used in quantum error correction and admit exact classical verification. In our target-conditioned framework, each target is given as compact signed stabilizer generators, and an exact verifier checks the generated OpenQASM circuits. We supervise models with Aaronson-Gottesman chain-of-thought (AG-CoT) traces checked by the verifier, and continue training on model generations that the verifier accepts. Across two independently trained model families (3B and 7B), AG-CoT supervision multiplies greedy-decode state-equivalence accuracy by four to six times over circuit-only baselines, and verifier-filtered continuation training adds a further consistent gain atop both. A complementary 32B study shows that supervised models achieve near-perfect syntax and Clifford validity while the strongest direct model reaches 6.14% state equivalence per target, rising to over 10% under verifier-guided selection with multiple candidates. These results show that algorithmic trace supervision gives a large, statistically significant gain in both model families and that verifier-filtered continuation adds a further repeated gain. The persistent gap between Clifford validity and state equivalence confirms that exact verification is necessary: a circuit can be syntactically and physically valid yet prepare the wrong quantum state.
Lu Wei, Yufeng Wang, Chenfeng Cao +2
Data Science Department, Stony Brook University · Department of Computer Science, Stony Brook University · Dahlem Center for Complex Quantum Systems, Freie Universität Berlin +1
We review thirteen generative systems and five supporting datasets for quantum circuit and quantum code generation, identified through a structured scoping review of Hugging Face, arXiv, and provenance tracing (January-February 2026). We organize the field along two axes: artifact type (Qiskit code, OpenQASM programs, circuit graphs); crossed with training regime (supervised fine-tuning, verifier-in-the-loop RL, diffusion/graph generation, agentic optimization); and systematically apply a three-layer evaluation framework covering syntactic validity, semantic correctness, and hardware executability. The central finding is that while all reviewed systems address syntax and most address semantics to some degree, none reports end-to-end evaluation on quantum hardware (Layer 3b), leaving a significant gap between generated circuits and practical deployment. Scope note: quantum code refers throughout to quantum program artifacts (QASM, Qiskit); we do not cover generation of quantum error-correcting codes (QEC).