WorksPhysics and Astronomy
Agentic AI for Discovering Fault-Tolerant Quantum Circuits
Abstract
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.
Introduction
Quantum error correction (QEC) codes protect quantum systems and algorithms from noise and decoherence by encoding quantum information in redundant and entangled noisy physical qubits [1]. While recent experiments have demonstrated key ingredients of universal fault-tolerant quantum computing [2, 3, 4, 5], scaling them to the circuit sizes required for practical quantum advantage will require substantial advances in fault-tolerant circuit design. This typically involves a stack of three tasks, in increasing level of complexity: preparing logical states, implementing logical gates, and composing them to realize some logical routine. For each of these tasks, fault tolerance is a necessity, as a single fault anywhere in these circuits can spread into an error larger than what the code can correct, causing a logical error. Codes of larger distance tolerate more faults, but their circuits require more gates, which increases the possibility of faults. Designing a circuit therefore entails simultaneous control over the circuit’s objective and fault tolerance. These design problems have so far been solved mostly by hand, separately for each task, QEC code, etc., which rapidly becomes intractable for large circuits. Automated discovery has, quite recently, started making progress. Satisfiability solving yields gate- or depth-optimal circuits preparing logical states of small CSS codes together with the verification circuits for fault tolerance [6]. Reinforcement learning (RL) approaches train a neural network to build circuits by placing gates, or suitably transforming them, getting rewarded as the circuit approaches its target [7, 8, 9, 10, 11, 12]. Reference [13] extends it to fault-tolerant logical state preparation using flag qubits. So far, these methods have been limited to distance-five codes, and have not been applied to logical gates or higher-level routines.
Additionally, RL requires orders of magnitude more circuit simulations than our large-language-model (LLM) based method introduced below. Next up on the stack, logical gates constitute a seemingly harder problem as the gate circuit must map each codeword to its image under the desired gate operation. Existing works [14, 15, 16, 17, 18, 19] have been mostly limited to small codes, with fault tolerance either imposed under restrictions of transversalilty, or added separately afterwards, if at all. Finally, at the last level of the stack, these two fundamental tasks, logical state preparation and logical gate design, must be orchestrated to realize logical routines. At the level of physical qubits, there are only limited studies in this direction [20].
To this end, we harness the capabilities of modern frontier LLMs for automated generation of fault-tolerant circircuits at the level of physical qubits for this entire stack of tasks, logical state preparation, logical gate design, as well as logical routines such as code-switching, code growth, etc., while offering the tunability for any code and connectivity. LLMs have already been applied to quantum circuit generation, with mixed success, either following supervised [21] or RL-based fine-tuning [22], or without any domain specific fine-tuning [23, 24, 25]. Notably, they have so far not been successful at fault tolerance. All of these primarily use the LLM for one-shot generation. Outside quantum computing, a different paradigm was introduced with FunSearch [26], and its successor AlphaEvolve [27], which use an LLM as a mutation operator over functions/programs, coupled to an evaluator, iteratively refining programs in an evolutionary search. They have produced advances over human-designed benchmarks across a range of problems. More recently, Refs. [28, 29] have used this approach for the discovery of quantum low-density parity-check codes. We use this as a starting point, developing a hybrid agentic FunSearch approach to search over programs representing circuits. Our approach rests on the premise that modern frontier LLMs, armed with suitable tools, already possess the necessary competence for generic physics tasks [30]. As depicted in Figure 1, starting with the physical setting (QEC code, qubit layout) and the task specification in the prompt, an LLM generates quantum circuits within an evolutionary search using a verification tool to check for circuit validity and fault tolerance. Each circuit is specified as a Python function through a simple, custom-made API. We focus on dynamic Clifford circuits, which are Clifford circuits with mid-circuit measurements and Pauli feedforward gates conditioned on their outcomes. This lets the LLM discover the corrections when faults are detected instead of discarding the faulty state. This is particularly crucial for tasks such as logical gates, where discarding a shot from a gate midway through a long protocol would force one to restart the entire protocol from scratch.

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.
The remainder of this manuscript is organized as follows. Section II introduces our hybrid agentic FunSearch and its key components: the prompt, which specifies the task and the physical setting of the circuit; the verifier, which checks the validity of the circuit and provides the metrics quantifying fault tolerance; and finally the evolutionary search. Sections III A, III B and III C present the results for logical state preparation, logical gates, and some applications involving higher-level logical routines such as code-switching and code growth, respectively. We conclude in Sec. IV.
Agentic FunSearch for Quantum Circuits
In this section, we describe our “agentic FunSearch” for the automated design of quantum circuits. As in the original FunSearch, we perform an evolutionary search over programs, in which a pretrained LLM acts as the mutation operator and a verifier scores each program [26]. In our case, each program is a Python function representing a quantum circuit, and the verifier checks if the circuit reaches its target and quantifies its fault tolerance. We transcend the original FunSearch by harnessing the agentic capabilities of frontier LLMs. Rather than merely returning a new program, the LLM can call the verifier as a tool, so that it may test and amend its proposals before submitting its solution. Our implementation, illustrated in Figure 2, consists of three parts: the LLM writes a program defining a circuit following the task specification in its prompt (employing the agentic loop just mentioned), a verifier checks the validity of the circuit and provides metrics characterizing the fault tolerance of the circuit, and a database stores the best programs and feeds them back to the LLM. We introduce each part below, and then explain the agentic FunSearch loop. We provide a concise pseudocode of our workflow in Appendix D.
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 § 2 B). 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.
The prompt provides the physical setting of the problem, a detailed specification of the task and circuit constraints, and a description of what the LLM must generate. We focus on stabilizer circuits [31] [1], so the task is presented in the stabilizer formalism. An -qubit stabilizer state is the unique joint eigenstate of independent, commuting Pauli operators, known as stabilizers. Each stabilizer is stored as a sign and two binary vectors that denote the qubits on which it acts with or , respectively. These stabilizers are thus represented as an stabilizer tableau. As the stabilizers of a state are not unique, we use the canonical tableau. A Clifford gate updates the tableau by binary operations on its columns and signs. The target is a stabilizer state , whose stabilizers are listed in the prompt. We primarily focus on targets encoded in a QEC code, denoted , with physical qubits, logical qubits and distance . We also define as the maximum weight of a Pauli error that the code can correct. For logical state preparation, the target stabilizers are the code stabilizers and the logical operators that fix the state, e.g., the logical , , for , where the bar denotes a logical operator. These are provided by the user as part of the prompt to the LLM. For preparing a logical gate, , we must ensure that it implements the desired logical operation on every codeword. While this is a seemingly harder task than logical state preparation, the channel-state duality [32, 33] reduces this to a state preparation problem. Specifically, we introduce reference qubits such that each logical qubit is coupled with a reference qubit in a Bell state. The target becomes the logical Choi state of [34, 35, 36], generated by the code stabilizers, along with the generators of the Bell pair between the logical qubits and the reference qubits, and (Appendix A). In this case the code stabilizers, and all the logical operators and are provided by the user, along with . The Bell-pair stabilizers are mapped by by a function, before being appended to the prompt. Besides the target, the prompt specifies the qubit layout, i.e., the positions of the data and ancilla qubits, and the qubit pairs on which two-qubit gates are permitted. It also specifies the gate set, a short primer on how gates and measurements alter the stabilizer tableau, and states the fault tolerance requirement as described below.
The evolved artifact is a Python function that takes the number of data and ancilla qubits, , and returns a circuit. It is intended to work for general sizes specified by its arguments rather than with hardcoded qubit numbers, so that one program can cover a whole family of codes in a single search, wherever applicable. E.g. the surface code at several distances. The program builds the circuit by calling a small custom-made circuit class, whose API is described to the LLM in its prompt. This class is initialized with the qubit layout chosen by us. This is accessible to the program via the API. We describe the layouts as they arise in later sections. The circuit class provides the Clifford gates, Z-basis measurement of ancillae, as well as conditional X or Z gates where the condition can be the parity/XOR of any number of measurement outcomes. It records these operations as a circuit when the Python function is executed, and the verifier uses it to verify the circuit. This involves two steps: First, it checks that the circuit is valid, i.e., the circuit leaves the data qubits in the target state (logical Choi state in the case of a gate, and other applications such as code-switching), and disentangled from the ancillae, for every combination of random measurement outcomes [37]. Second, the verifier checks for fault tolerance. We implement flag fault tolerance, wherein some ancilla qubits serve as flag qubits which detect faults [38, 39]. Specifically, the ancillae whose measurements are deterministic serve as flags, or detectors, as their outcomes are fixed in the fault-free circuit, so any deviation reveals a fault. Note that the faults cannot change whether a measurement is deterministic or random. This is because this classification depends only on the symplectic ( and ) part of the stabilizer tableau, specifically, a measurement is deterministic if the measured operator belongs to the stabilizer group up to some signs, and random otherwise. Since the faults are modeled as Paulis inserted after the failing gates (discussed below), which do not alter the symplectic part of the tableau, they cannot change the classification of the measurements. We briefly describe the fault tolerance criterion below, and provide additional details in Appendix § 2.1.
The verifier enumerates the faults of a valid circuit, similar to the standard circuit-level depolarizing noise model, accounting for gate failures, input errors, and measurement errors, each happening with a physical error rate . A fault is a single non-identity Pauli inserted after a non-Pauli gate or on the input qubits, or a flipped measurement outcome. Pauli gates are omitted as they are typically tracked in software [40]. We call simultaneous faults an event of order , which occurs with probability . A single fault is a first-order event, and events of order are higher-order events. For a code of distance , we only enumerate events of order . Events of order greater than occur with probability , and therefore they do not alter the exponent of the logical error rate of the code, . Each fault is propagated to the end of the circuit, leaving behind a residual Pauli on the data qubits, and flipping some detectors, and we call this set of flipped detectors its pattern. The residual and pattern of a higher-order event are the product of its faults’ residuals, and the XOR of their patterns, respectively (Appendix § 2.1). Two residuals, possibly with different weights, act identically on the target if they differ by a Pauli on the data qubits that stabilizes the target. These Paulis form a group . Hence, a residual is judged by its reduced weight , which only depends on how the residual acts on the target. For logical state preparation, is the stabilizer group of the target state, which is generated by the code checks and logical operators that together identify the target state. For logical gate design, code-switching, code growth, etc., is the group generated by the output code checks alone, as these circuits must implement a fixed logical operation on the input logical state and any logical operator acting on a residual would alter that operation for some inputs. The circuit is fault-tolerant when every event of order either fires a detector or leaves a residual with [39, 41] [1]
A residual which exceeds this bound is denoted “heavy”, and “light” otherwise. We note that for () of a CSS code, only the () part of each residual needs to satisfy the bound in Eq. (1). For logical gates and code growth on CSS codes, neither part can be ignored, but we check and parts of each residual separately against the bound as they are corrected independently (Appendix § 2.1). Since we consider flag fault tolerance with ancilla measurements as fault detectors, each event is judged not only by its residual’s weight using Eq. (1), but also by its detector pattern and, for logical gates, the syndrome measurements from the subsequent QEC rounds as well. We adopt two distinct ways to classify the events, depending on the task.
We start with logical state preparation. Since it typically constitutes the starting point of QEC protocols, it is affordable to discard a faulty shot and rerun the circuit until a shot is accepted. Thus, we simply discard any shot where ancilla measurements indicate a heavy event, which implies we only require an event’s residual weight and its detector pattern to classify it. Accordingly, each event is classified as “correctable” if its residual satisfies the bound in Eq. (1), “silent” if it exceeds the bound but no detector is triggered, “heralded” if it exceeds the bound but at least one detector is triggered resulting in a non-trivial pattern, and “waste” if it is correctable but it still triggers a pattern that is shared with a heralded event, so post-selection discards it as well. The primary goal of our search is to drive the number of silent events down to zero as they compromise fault tolerance. Idling faults, which are Pauli faults on a qubit while it is waiting between two consecutive operations, are not enumerated separately, as every idling fault coincides with one of the faults already enumerated by the verifier. They only increase the prefactor of the logical error rate [1]. Since the number of idling faults is commensurate with the depth of the circuit, reducing the depth constitutes the secondary goal of our search. The heralded and wasted events only impact the acceptance rate, and since discarding a shot is acceptable for state preparation, they constitute the tertiary and quaternary goals, respectively. Hence, we adopt the following lexicographic score to rank the logical state preparation circuits:
where silent-cost . Here, denotes the number of silent events of order , is the total number of qubits, and is an arbitrary constant. The factor compensates for the combinatorial growth in the number of possible events of order , preventing higher-order event contributions from dominating the score solely due to their multiplicity. The depth is obtained by compressing the circuit to maximize parallel utilization of qubits. The calculation of herald and waste is elaborated in Appendix § 2.1. They are both obtained only for first-order events. This is because we never obtain zero heralded and wasted events in practice, and the corresponding counts from higher-order events cannot vanish as long as those for the single faults are non-zero. Moreover, since , all heavy events raise a pattern, thereby ensuring fault tolerance under post-selection. The match is for every valid circuit and otherwise grows with the fraction of measurement branches that reach the target (Appendix § 2.1.1), so it matters only for invalid circuits. While this discussion was for a search run for a single target, in some cases, we also perform a simultaneous search over multiple targets, typically involving the same task but over a family of QEC codes, e.g., logical state preparation over several code distances for the rotated surface code. In this case, a program is valid only if its circuits are valid at every distance. Using , , and to denote the silent-cost, depth, herald and waste at the -th largest target distance, respectively, the programs are ranked by the lexicographic score . This ordering is motivated by the fact that the largest distance is the most difficult target, so its full score takes precedence. The smaller distances are intended to encourage a size-general program, but not to outrank the largest distance.
Now, for logical gates, code-switching, code growth and other mid-circuit gadgets, which reside in the middle of long protocols, discarding a shot would force the entire protocol up to that point to repeat. If such a strategy were adopted, in a long protocol with several such mid-circuit gadgets, the probability of successfully completing the protocol would vanish exponentially with their number [40, 42, 43]. Moreover, a discard caused by an event of order , comprising simultaneous faults, occurs with probability , which is parametrically greater than the logical error rate of the QEC code. As such, the discards would become the dominant factor restricting the length of the protocol, negating the benefit of the QEC code [42]. Therefore, to overcome this challenge, we adopt a different approach, without post-selection. This requires a change in how we classify the events based on their residuals and their flag detector patterns. Instead of discarding a shot after detecting the presence of heavy events, we correct them. The code check syndrome alone cannot achieve this, as a heavy residual can share its syndrome with a light one while differing from it by a logical operator. As in flag error correction, the detector pattern supplies the missing information [38, 39]. We therefore assume that in the subsequent QEC round, the decoder uses both the detector pattern and the code check syndrome together, henceforth called a bin. If no detector is triggered (empty pattern), the decoder decodes the syndrome alone as in a standard QEC round, and each event is then judged as silent or correctable, using Eq. (1). If some detector is triggered, the decoder uses the bin to determine a correction. Note that residuals belonging to a bin can come from events of any order . Since they share the same syndrome, they may differ only by an element of (product of some code checks), or by some logical operator times an element of . If all residuals in this bin differ only by elements of , they are unambiguous and a single correction repairs all of them, including heavy residuals. Otherwise, when the residuals of at least a pair of events in the bin differ by some logical operator, the bin is ambiguous, as no single correction can correct both. Such an ambiguous bin must contain at least one heavy residual. This is because a logical operator has , and when a light residual of an event of order with is multiplied by , the product must be heavy with . Each event in such an ambiguous bin must be discarded, hence such a case fails our goal of forgoing post-selection. We call such a discarded event “undecodable” if its residual is heavy, or “forfeited” otherwise. Thus, unlike for state preparation, we discard a detected event with a heavy residual not based on its pattern, but only when its bin is ambiguous and cannot be corrected. Moreover, since every ambiguous bin must contain an undecodable event, having zero undecodable events implies zero forfeited events. We evaluate both at every order , with each event weighted by the product of its constituent faults’ weights, so that undecodable and forfeited are approximately the probabilities, in units of at order , of discarding a shot. These are combined into the weighted sums undecodable-cost and forfeit-cost, respectively, in the same way as the silent cost. We then rank the gate circuits by the lexicographic score
Now that we have gone over the prompt and the verifier, we describe the agentic FunSearch. The FunSearch loop runs on several islands, each storing its own programs, partitioned into clusters based on their scores. The search proceeds in generations, and in each generation, every island prompts the LLM with a few programs from its own archive, which includes its best program, one with a different number of measurements and a third drawn at random, with the last two present for diversity. Each program carries its fault tolerance metrics, its packed circuit (packed to maximize parallel qubit utilization), and the events it fails to correct. The prompt also states the best score found so far across all islands as the frontier to beat. The LLM returns one new program, which is verified, scored, and added to that island. Additionally, the LLM returns scratchpad notes, which are shown to the LLM in the island’s next prompt, allowing it to note down and persist positive ideas to reinforce, negative results to avoid, instructions for future generations, etc. The best programs periodically migrate between islands. To keep the discovery fully automated, every search starts cold with no seed programs. We arm the LLM with two tools: one verifies a circuit proposal and returns the same report the parents carry, and the other is a general Python tool with the circuit class, the targets and the verifier in scope, so that several proposals may be evaluated, ablated, and compared in one call. We have implemented three LLM tiers, base, strong and elite, with OpenAI GPT-6-luna with reasoning effort “max” as the base model, and GPT-6.1-sol with reasoning “high” and “xhigh” as the strong and elite models, respectively. We find that GPT-6.1-sol performs significantly better than GPT-6-luna, particularly for targets involving non-CSS codes, certain gate tasks, and the logical routines in Sec. III C. As such, almost all of the circuits are generated by the strong tier. In all cases, the strong tier performs the cold start by generating the circuits for the first couple of generations.
| code | circuit | connectivity | anc. (used) | det. | silent | depth | herald | waste | 2q |
| Ref. [13], | all-to-all | 2 (2) | 2 | 0/–/–/– | 12 | 2.47 | 14.67 | 12 | |
| this work, | all-to-all | 2 (2) | 2 | 0/–/–/– | 8 | 1.73 | 11.33 | 12 | |
| Ref. [44], ME | native | 8 (4) | 0 | 16/–/–/– | 7 | – | – | 12 | |
| this work, multi-size | native | 8 (8) | 4 | 0/–/–/– | 6 | 1.07 | 9.20 | 27 | |
| this work, multi-size | hex | 8 (6) | 2 | 0/–/–/– | 6 | 3.47 | 5.20 | 18 | |
| Ref. [13], 25_0_1 | all-to-all | 4 (4) | 4 | 0/0/–/– | 16 | 10.93 | 8.53 | 54 | |
| this work, shallow | all-to-all | 4 (4) | 4 | 0/0/–/– | 9 | 4.27 | 3.60 | 50 | |
| this work, zero waste | all-to-all | 4 (4) | 12 | 0/0/–/– | 16 | 4.27 | 0.00 | 68 | |
| Ref. [44], ME | native | 24 (12) | 0 | 64/19936/–/– | 7 | – | – | 40 | |
| Ref. [44], UEA | native | 24 (12) | 0 | 64/24864/–/– | 18 | – | – | 52 | |
| this work, multi-size | native | 24 (24) | 12 | 0/0/–/– | 7 | 4.27 | 51.47 | 78 | |
| this work, multi-size | hex | 24 (20) | 20 | 0/0/–/– | 10 | 4.27 | 19.73 | 72 | |
| Ref. [44], ME | native | 48 (24) | 0 | 144/107904/–/– | 7 | – | – | 84 | |
| Ref. [44], UEA | native | 48 (24) | 0 | 144/132864/–/– | 26 | – | – | 108 | |
| this work, multi-size | native | 48 (48) | 24 | 0/0/0/– | 7 | 9.60 | 112.40 | 165 | |
| this work, multi-size | hex | 48 (42) | 48 | 0/0/0/– | 10 | 9.60 | 59.20 | 162 | |
| Ref. [44], ME | native | 80 (40) | 0 | 256/345312/–/– | 7 | – | – | 144 | |
| Ref. [44], UEA | native | 80 (40) | 0 | 256/422560/–/– | 34 | – | – | 184 | |
| this work, multi-size | native | 80 (80) | 40 | 0/0/0/0 | 7 | 17.07 | 196.00 | 284 | |
| this work, multi-size | hex | 80 (72) | 88 | 0/0/0/0 | 10 | 17.07 | 118.40 | 288 | |
| Ref. [45], Fig. 1c | all-to-all | 1 (1) | 1 | 0/–/–/– | 7 | 2.53 | 7.00 | 11 | |
| Ref. [13], 7-3 | all-to-all | 1 (1) | 1 | 0/–/–/– | 8 | 1.33 | 7.00 | 11 | |
| this work, multi-size | all-to-all | 3 (3) | 6 | 0/–/–/– | 7 | 1.33 | 7.20 | 17 | |
| this work, multi-size | all-to-all | 3 (3) | 3 | 0/–/–/– | 6 | 1.60 | 10.87 | 15 | |
| Ref. [13], 19-4-0 | all-to-all | 4 (4) | 4 | 0/0/–/– | 18 | 12.53 | 8.87 | 49 | |
| this work, single-size | all-to-all | 4 (4) | 6 | 0/0/–/– | 8 | 6.40 | 14.40 | 50 | |
| this work, multi-size | all-to-all | 4 (4) | 10 | 0/0/–/– | 17 | 8.27 | 0.00 | 77 | |
| this work, single-size | all-to-all | 7 (7) | 14 | 0/0/0/– | 18 | 18.40 | 0.00 | 148 | |
| this work, multi-size | all-to-all | 7 (7) | 25 | 0/0/0/– | 23 | 32.00 | 2.53 | 189 | |
| this work, single-size | all-to-all | 11 (11) | 41 | 0/0/0/0 | 32 | 31.73 | 0.00 | 334 | |
| this work, multi-size | all-to-all | 11 (11) | 31 | 0/0/0/0 | 28 | 61.60 | 0.00 | 361 |
Table 1. Logical-state preparation tasks. All cases prepare , except for the code which prepares . Gate set: H, S, X, Z, CNOT, CZ, ancilla measurement, and conditional X, Z. For the CSS codes, we use the simplification of the fault tolerance criterion (Appendix § 2.1). “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 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 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 code with all-to-all connectivity, we show the shallowest circuit, and a zero waste circuit, both extracted from the program 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 . For the code, “multi-size” is the circuit of a separate multi-size search. The circuits of Ref. [44] have no detectors, so they have no heralded or wasted events.
Results
Logical states
In this section, we use our agentic FunSearch for the preparation of several logical states spanning several QEC codes, showcasing the capabilities of our approach. Tab. I collects all results, on all-to-all connectivity, and for the surface code, also on its native and hex layouts.
Perfect code:– The code [48] is non-CSS, which makes it a harder target than the CSS codes. Since its generators mix X and Z Paulis, none of them is automatically satisfied by the initial product state. Consequently, the simplification for CSS codes mentioned previously (detailed in Appendix § 2.1), where the Z-type residuals can be ignored, no longer applies. We therefore score the full residual for every event. On all-to-all connectivity, our search obtains a notably shallower circuit than the RL agent in Ref. [13], using the same number of two-qubit gates.
Rotated surface code:– The rotated surface code is a topological CSS code that, for code distance , encodes a single logical qubit in data qubits on a square lattice [49, 50]. It has particular significance due to its favourable hardware layout, and high noise threshold [50], with several experimental demonstrations [2, 3]. Here we consider it on all-to-all connectivity, the native layout where alternate sites on a nearest-neighbour square lattice are data and ancilla qubits, and lastly the hex connectivity [47] which matches the native layout except that each ancilla’s coupling to the data qubit below it is removed.
First, on all-to-all connectivity, we obtain a significantly shallower circuit than Ref. [13]. Besides this final circuit returned by our search, we also look into the program database and extract a depth-waste Pareto front. We show an additional circuit that sacrifices shallowness to achieve zero waste.
Next, on the native layout, we run the search simultaneously (“multi-size”) on distances , which is possible as the layout is scalable. Already in the first generation, the search obtains circuits that are valid and fault-tolerant with zero silent events at all distances. Five additional generations were spent on reducing the depth. The final program branches on distance, providing one circuit for , and another for all other distances. The former has depth 6, while the latter has depth 7 on all tested distances (up to ). For , the circuit is similar to the standard measurement-based encoding (“ME” in Ref. [44] and Tab. I); it measures the checks, and applies conditional gates to correct the checks whose outcomes yielded . At , the circuit prepares the checks unitarily, similar to “UEA” in Ref. [44]. However, at every distance, our circuit also measures the checks in parallel, serving as fault detectors to catch the hook errors. For ME and UEA, our verifier shows silent events starting already at order one, i.e., from single faults, which is a result of our stricter fault tolerance criterion. These circuits align the hook errors perpendicular to the logical operator , and thus, a decoder that can account for these hook errors in the subsequent QEC round could correct them. Our circuit, instead, uses its detectors to herald these events.
Lastly, we consider the hex layout [47]. On running our search simultaneously for , we obtain fault-tolerant circuits with depth 10 in the first generation.
In the subsequent generations, the circuit shaved depth, while for the circuits stayed at depth 10 and lowered the herald and waste. An ancilla that builds an check cannot reach all of its four data qubits directly as in the native layout above, so it uses a neighbouring check ancilla. The program branches on distance, providing a separate circuit for .
Colour codes:– Colour codes [3, 52] are also topological CSS codes that, in two dimensions, support a transversal implementation of the entire Clifford group. We consider the two-dimensional triangular colour code family, spanning distances three through nine. The version, known as the Steane code, is the smallest distance-three CSS code. It constitutes a simple test of our search, as fault-tolerant state preparation on it has long been manually obtained.
With all-to-all connectivity, we perform our search separately for each distance (“single-size”), and similar to the rotated surface code, also simultaneously for all distances (“multi-size”). The search progressed more slowly than that of the rotated surface code. In the multi-size search, fault-tolerant circuits were obtained already in the first generation for , but only in generation 11 at . The search did not find a general program for all distances. It took around 15 generations for the depths to get to within 20% of their final values. The last drop in depth came in generation 43 for . In the single-size runs, fault tolerance was achieved already in the first generation, and the depths converged to their final values sooner. At and 7, our single-size search obtained notably shallower circuits, whereas at , the multi-size search is shallower. For the Steane code, the multi-size search matches the depth 7 of Ref. [45], while another multi-size search (“multi-size†”) arrived at a shallower depth-6 circuit.
Logical gates
In this section, we run our agentic FunSearch to obtain physical circuits that implement logical gates on encoded qubits. The desirable scenario is that of a transversal gate, wherein the gate circuit acts separately on the constituent physical qubits of the code, thereby precluding the spread of faults. Unfortunately, no code admits a transversal implementation of a universal gate set [53], which calls for efficient and fault-tolerant circuit constructions for the non-transversal gates. We go over a few illustrative examples to show the strength of our approach. Tab. II collects all results.
CNOT on the perfect code:– Unlike CSS codes, non-CSS codes do not permit a transversal CNOT, making its efficient and fault-tolerant implementation challenging. We use the perfect code, the smallest distance-3 non-CSS code, as a simple example. Since we have two logical qubit blocks, the fault tolerance criterion given by Eq. (1) is applied separately to each encoded block. Reference [51] implements a logical CNOT between two perfect code blocks, representing two encoded logical qubits, with all-to-all connectivity. Their implementation comes in three variants, with all variants sharing a common backbone involving several single-qubit rotations and nine physical CNOTs between the blocks. The variant named “CNOT3f”, containing flagged checks, satisfies our fault tolerance criterion, and thus we use it for our benchmark. Reference [51] uses piecewise fault tolerance [54], where a non-fault-tolerant gate is decomposed into small fault-tolerant pieces, interleaved with QEC cycles. Our circuits are fault-tolerant, and much shallower than CNOT3f (Tab. II). Our circuits measure only a total of four checks, two per logical block. In the two-ancilla circuit, the two ancillae flag each other’s faults. In the first five-ancilla circuit each check has its own ancilla, two of these ancillae also flag each other, and the fifth ancilla simultaneously flags the remaining two ancillae. In the other one, the fifth ancilla is unused, and the four check ancillae split into two pairs whose members flag each other, reducing the two-qubit gate count.
| code | gate | circuit | connectivity | anc. (used) | det. | silent | undecodable-cost | depth | 2q |
| [[5, 1, 3]] | CNOT | Ref. [51], CNOT3f | all-to-all | 2 (2) | 16 | 0/–/– | – | 84 | 65 |
| this work | all-to-all | 2 (2) | 4 | 0/–/– | 0.00 | 16 | 29 | ||
| this work, (A) | all-to-all | 5 (5) | 5 | 0/–/– | 0.00 | 9 | 31 | ||
| this work, (B) | all-to-all | 5 (4) | 4 | 0/–/– | 0.00 | 9 | 29 | ||
| [[9, 1, 3]] | this work, single-size | native (, centre) | 48 (19) | 9 | 0/–/– | 0.00 | 9 | 61 | |
| this work, multi-size | native | 8 (5) | 12 | 0/–/– | 0.00 | 41 | 62 | ||
| [[25, 1, 5]] | this work, single-size | native (, centre) | 80 (22) | 67 | 0/0/– | 0.00 | 51 | 236 | |
| this work, multi-size | native | 24 (14) | 100 | 0/0/– | 0.02 | 191 | 344 | ||
| [[15, 1, 3]] | this work | all-to-all | 2 (2) | 3 | 0/–/– | 0.00 | 37 | 46 | |
| this work | all-to-all | 6 (6) | 3 | 0/–/– | 0.00 | 14 | 48 | ||
| this work | all-to-all | 9 (9) | 3 | 0/–/– | 0.00 | 10 | 48 | ||
| [[8, 3, 2]] | Ref. [15], Fig. 3(a) | cube | 1 (1) | 1 | 0/–/– | 32.33 | 19 | 13 | |
| this work | cube | 1 (1) | 1 | 0/–/– | 29.13 | 9 | 11 | ||
| Ref. [15], Fig. 3(b) | cube | 1 (1) | 1 | 0/–/– | 42.93 | 15 | 16 | ||
| this work | cube | 1 (1) | 1 | 0/–/– | 36.13 | 10 | 16 | ||
| Ref. [15], Fig. 3(c) | cube | 1 (1) | 1 | 0/–/– | 54.47 | 18 | 19 | ||
| this work | cube | 1 (1) | 1 | 0/–/– | 49.80 | 14 | 28 |
Table 2. Logical gate design tasks. The columns are as in Tab. I. The gate set is that of Tab. I, extended by , Y, CY for the perfect-code CNOT, and by , CY for the [[8, 3, 2]] code. For the surface-code , 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 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 § 2.1). 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.
Our search achieves zero silent and undecodable events in the first generation itself, and achieves its final depth within three generations.
Hadamards on the [[8, 3, 2]] code:— The [[8, 3, 2]] code is a distance-2 error-detecting 3D colour code. It encodes three logical qubits in eight data qubits located at the vertices of a cube. It supports a transversal non-Clifford gate, the CCZ, in a weak sense [3], but it lacks a transversal Hadamard [15]. However, Ref. [15] obtains logical Hadamard gates acting on up to three logical qubits simultaneously for this code, on its native cube connectivity with one flag qubit at its centre. We adopt this setting, and obtain shallower fault-tolerant circuits for these logical Hadamards, as shown in Tab. II. Since this is an error-detecting code, fault tolerance is enforced only by post-selection. In this case, the undecodable cost counts the ambiguous and heavy single faults.
Hadamard on the [[15, 1, 3]] Reed-Muller code:— The [[15, 1, 3]] quantum Reed-Muller code is a 3D topological colour code. As explained in the next section, it does not have a transversal logical Hadamard. Reference [55] implements it via code switching (described in the next section) to the Steane code, which admits a transversal Hadamard, and then switching back. Our circuits, with all-to-all connectivity, transversally apply to all data qubits and subsequently restore the Reed-Muller code by measuring stabilizers and applying Pauli corrections conditioned on their outcomes. Three further measurements, whose outcomes are fixed by the earlier ones, act as detectors.
Phase gate on the rotated surface code:— The phase gate lacks a transversal implementation on the rotated surface code. Previous implementations on the native layout temporarily use additional qubits beyond the logical qubit patch [56, 57], or require the injection of a resource state [50]. We first attempted to find an “in-place” circuit with zero undecodable and forfeited events, using only the data qubits and ancillae of the logical patch. For this, we ran a simultaneous multi-size search for and . Within the allocated budget of 60 generations, it succeeded in obtaining a circuit with no undecodable events at , but failed at . Subsequently, the search succeeded for both distances when provided access to additional qubits by embedding the distance- logical patch at the centre of a larger distance- patch, both with the same native layout. In this case, we ran a separate search for each distance.
Further Applications
In this section, we tackle a curated list of tasks going beyond the state and gate preparation objectives from the previous sections. Tab. III collects all results.
Logical Bell pair in the perfect code:— Logical Bell pairs may be used as resource states for teleporting a logical qubit between two blocks, applying logical gates via gate teleportation [35], for Knill-style error correction [40, 58], etc. Here we prepare the logical Bell state in two logical qubits encoded in the perfect code. As the perfect code is non-CSS, it lacks a transversal CNOT, which rules out the standard construction of a Bell state using a Hadamard followed by a CNOT. This is technically a state preparation task, with the target state being fixed by the code generators of both blocks, followed by and , which are the usual generators of the Bell state elevated to the logical level. We enforce fault tolerance with the criterion in Eq. (1), with per block.
Code switching between the Steane and the Reed-Muller code:— Since no code has a transversal universal gate set, code switching switches the encoding of a logical qubit between two codes with a complementary set of transversal gates. This provides access to a universal set of transversal gates, at the cost of the switching circuit. E.g., 3D colour codes admit transversal T and CNOT gates, while 2D colour codes admit transversal Hadamard and CNOT gates. Since the Hadamard, T, and CNOT together constitute a universal gate set, the logical Hadamard cannot be transversal in the former, while the T cannot be transversal in the latter. This is particularly relevant as a T magic state can be prepared in the Reed-Muller code, and then switched to the Steane code where the Clifford gates are transversal. Reference [55] proposes fault-tolerant code switching between the quantum Reed-Muller code and the Steane code, which are 3D and 2D colour codes, respectively. They perform the code switching in-place in both directions, with the logical qubit staying in the same set of physical qubits throughout. References [59, 60] present a switch in a single direction, from the Reed-Muller code to the Steane code, where the logical qubit is teleported to a separate Steane block outside the initial Reed-Muller block. We consider both settings, switching from Steane to Reed-Muller in-place, and from Reed-Muller to Steane
| code | task | connectivity | anc. (used) | det. | silent₁/₂/₃ | herald | waste | depth | 2q |
| [[5, 1, 3]] | Bell pair | all-to-all | 4 (4) | 9 | 0/–/– | 9.33 | 34.47 | 12 | 42 |
| code | task | connectivity | anc. (used) | det. | silent₁/₂/₃ | undecodable-cost | depth | 2q |
| [[7, 1, 3]], [[15, 1, 3]] | switch S → RM | all-to-all | 2 (2) | 4 | 0/–/– | 0.00 | 20 | 40 |
| [[7, 1, 3]], [[15, 1, 3]] | switch RM → S | all-to-all | 16 (8) | 1 | 0/–/– | 0.00 | 4 | 22 |
| [[9, 1, 3]] → [[25, 1, 5]] | grow | native | 24 (23) | 70 | 0/0/– | 4.65 | 26 | 153 |
| [[25, 1, 5]] → [[49, 1, 7]] | grow | native | 48 (48) | 181 | 0/0/0 | 0.12 | 32 | 465 |
caption: TABLE III: Further applications: a logical Bell pair, code switching, and code growth. The gate set is as in Tab. I. The Bell pair is a state preparation task, so its columns are as in Tab. I. The code switches and growths are scored like logical gates by Eq. (3), so their columns mirror Tab. II. The Bell pair is the logical 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 to , as well as to , 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 § 2 C.
:::
by transporting the logical qubit to a fresh Steane block. In both cases, the target is the Choi state of the logical identity from the initial code to the final code, defined suitably on the physical qubits. For the fault tolerance criterion, we choose to coincide with that of the final code. This happens to be in our case, but in general, the final code may have a different distance than the initial code. The results are shown in Tab. III. Both circuits have zero silent, undecodable and forfeit costs. The Steane to Reed-Muller circuit (Figure 3) uses its ancilla measurements only as detectors. The Reed-Muller to Steane circuit reads the qubits outside the Steane face in the basis, moves the Steane face to the fresh block with two CNOTs per qubit, and restores the signs of the Steane checks with conditional gates. We present the program and circuit for the Steane to Reed-Muller switch in Appendix D 4, along with three representative scratchpad notes left by all three LLM tiers (GPT-6-luna [xhigh], GPT-6-luna [max], and GPT-6.1-sol [high]) during the search.

Figure 3. Steane to Reed-Muller code switch with all-to-all connectivity, and 2 ancillae (Tab. III): (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 - to the Reed-Muller code on -, using two ancillae -. The green boxes denote the detectors. Their outcomes are used by a QEC round to correct the faults (see § 1.1). We shade alternate layers grey and white.
Rotated surface code growth.— Growing the code distance of an encoded logical qubit forms a key component of magic state cultivation [5, 61, 62] and modular quantum computing [63]. In both cases, a resource state such as a magic state or a Bell pair is injected into a small-distance code and then the code is grown to the desired distance. In our implementation, as in the code-switching task above, the target is the Choi state of the logical identity. Fault tolerance is verified by using the criterion for the final code. We note that code growths are inherently fault-tolerant only under post-selection. Unlike a logical gate or a code switch at a fixed distance, in a growth from distance to , an undetected logical error at the input can have a weight , which is lower than the distance used for the fault tolerance criterion. With , zero silent events then require , to avoid getting enumerated. Even then, assuming odd distances, since , the weight input logical error can split into two events of at most simultaneous faults each, both of which are enumerated. As their combination is undetected with trivial syndrome and detector pattern, and the syndrome and pattern of an event are the XOR of those of its constituent faults (see App. B), they have the same detector pattern and syndrome, yet their residuals differ by a logical operator. Their bin is thus ambiguous, and both are discarded. The smaller event has as many as faults, when the other has . Thus, a growth is fault-tolerant only under post-selection, with the discards starting at events of order or lower. Nevertheless, we use the event classification and scoring of the logical gates, rather than those of state preparation. This is because the latter discards indiscriminately on encountering the pattern of any heavy event residual. Instead, the former discards a shot only if its bin is ambiguous, i.e., only if it cannot be corrected, reducing the wastage of discarded shots.
We consider the growths and . Both circuits in Tab. III have zero silent events, and their first discards occur at order mentioned above, 1 and 2, respectively. The search was not fully converged within its allocated budget, and it was still improving in its final (34th) generation. For the case, the search was almost stalled by the final (33rd) generation. Both circuits repeatedly measure the checks of the larger code, apply Pauli gates conditioned on the outcomes, and use the deterministic outcomes as detectors.
Discussion and Conclusions
We have presented an agentic evolutionary search, in which an LLM writes and evolves Python programs corresponding to dynamic Clifford circuits for various quantum tum computing tasks. All discovered circuits satisfy our fault tolerance criterion, matching or improving upon existing benchmarks in several cases. The key result is that modern frontier LLMs, armed with tool use and appropriate feedback reflecting our objectives, validity and fault tolerance metrics of the circuit, are more than capable of independently obtaining performant circuits. To this end, we have considered a curated set of examples spanning logical state and gate preparation, as well as logical routines such as code switching and code growth. In fact, our search presently works for any target that can be specified as a Clifford map on the qubits by using the Choi state. Despite our present focus being restricted to a particular hierarchy for the fault metrics to be optimized, with minor modifications to the scoring and prompt, one may realize any desired objective, e.g., different kinds of noise and fault tolerance criteria, measurement-free unitary circuits, explicit optimization of two-qubit gate counts, etc.
We recall that the standard FunSearch approach relied on relatively weak LLM calls over many generations. This hinged upon the premise that several mutations of an evolving artifact will eventually introduce high-performing features, even when the individual proposals are of limited quality. We transcended this approach, finding that a few generations driven by frontier LLMs can be substantially more effective at rapidly and reliably finding performant circuits within a limited budget. We believe that this follows from the improved proposal quality of modern frontier LLMs and their proficiency in agentic tool use, allowing the search to escape local minima in the fitness landscape. This is illustrated in Figure 4(a), where we find that the elite LLM, which is the strongest model we use (GPT-6.1-sol), is far more likely to produce new records in the scored metrics. Associated with these observations, as shown in Figure 4(b), we also note that the elite LLM consistently leaves longer and more elaborate scratchpad notes, despite being provided the same prompt as the remaining tiers.
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. II and III 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 Figure 6, showing this trend.
Note. During the final stage of writing this manuscript, two related works appeared on the arXiv [64, 65] applying LLM-based search for quantum circuits. Their circuits, however, compute certain functions on logical qubits and optimize for Toffoli and qubit counts, with fault tolerance left for future extensions. We instead search for Clifford circuits at the level of physical qubits, acting on encoded logical qubits for generic logical states, gates, and practical logical routines, with fault tolerance verified exactly.
Acknowledgments
This research is part of the Munich Quantum Valley, which is supported by the Bavarian state government with funds from the Hightech Agenda Bayern Plus.
Logical gate target: logical Choi state
We briefly review the Choi state construction for the representation of logical gates. A logical gate must map every input codeword to its image under the logical gate operation. However, the channel-state duality [32, 33], which represents a gate by its Choi state [34, 35, 36], converts this into a single target state in an enlarged Hilbert space. Hence, the logical gate design task inherits the technical machinery already used for state preparation. To illustrate the idea, we first consider a single physical qubit. We pair it with a reference qubit in the Bell state , where the first qubit is the physical qubit and the second one is the reference qubit. We apply a map to the physical qubit, giving . The reference qubit is purely a bookkeeping device, i.e., it does not need to be present in the actual physical device where the unitary is to be implemented. Since it is entangled with the initial physical qubit, it provides a memory of the initial state. As such, any map that produces this Choi state agrees with . In the stabilizer formalism, the Bell state is fixed by and , so is fixed by and . For a Clifford , each image is again a Pauli operator up to a sign, and . The unsigned operators and become the new rows of the symplectic part , and the two signs enter the corresponding sign bits. Moving now to several logical qubits, each is paired with its own reference qubit and the same argument applies, with logical unitaries in place of the original physical unitaries. We add reference qubits, each forming a Bell pair with a logical qubit of the code. In the stabilizer formalism, this amounts to elevating the stabilizers representing the Bell state, and , to the logical level for the code qubits, and , where denote the logical qubits and denote the corresponding entangled reference qubits. In addition, we append the code stabilizers. The reference qubits serve as a bookkeeping device and remain isolated from the physical qubits, with no gates permitted between them. The target state is the state reached when acts on the code block alone. It is stabilized by the code stabilizers together with and . Because the reference is entangled with every logical state at once, reaching this single stabilizer state certifies the gate on all possible codewords.
Fault tolerance
Here we describe our fault tolerance criterion and its implementation in detail.
As mentioned in § 1.1, each fault is propagated from its birth location to the end of the circuit to obtain its residual , which is a Pauli on the data qubits. While the faults are tracked and propagated on all qubits, including the ancillae, at the end the residual is read only on the data qubits. The residual of higher order events, comprising simultaneous faults, is obtained from that of its constituent single faults as described later in this section. Each event is judged by its residual using the reduced weight . This involves two objects which we first introduce here, and obtain in more detail below: (a) The group of Paulis on the data qubits that stabilizes the target. For any , the residuals and act identically on the target, even though their weights, and , may differ. The reduced weight provides an unambiguous answer. (b) A set of Paulis , against which we compute the syndrome of the residual, for efficiently checking the reduced weight bound in Eq. (1) without enumerating all elements of . We recall that the syndrome of a Pauli against another set of Paulis is a binary vector of length such that . That is, if commutes with , and if it anticommutes. It satisfies two properties: (1) when , i.e., for all . (2) If , then and hence, , where . As such, identifies modulo the Paulis that commute with every element of . The usual syndrome is calculated against the code checks. We use the syndrome of the residual against , calling it the extended syndrome, and choose such that if up to phases (henceforth, a “syndrome” refers to the usual syndrome against the code checks). Hence, following Eq. (1), iff matches that of some Pauli of weight at most . Therefore, it is sufficient to list the extended syndromes of all Paulis of weight at most , and check if belongs to that list. Below we describe the choice of and for the various tasks considered in this work.
First, we consider logical state preparation. In this case , the stabilizer group of the target state, since any element of acts trivially on the target state. contains the code checks as well as the logical operators that pin the target logical state. The extended syndrome is computed against containing these generators, as iff . Hence, the extended syndrome uniquely identifies the residual up to an element of [[66, 67]]. The QEC round measures the code checks, and using standard minimum-weight decoding, it applies the lightest correction that has the same syndrome as . Since every commutes with the code checks, has the same syndrome as , and thus . Furthermore, since has the same syndrome as , has zero syndrome, so it must either be the product of some code checks, or a logical operator. As per the bound in Eq. (1), in the case where , we can conclude that . While any logical operator has , the reduced weight of those within is zero as . However, for a logical operator outside , i.e., a logical error, we have where is again a logical operator outside . Hence, . Therefore, cannot be a logical error and must belong to , i.e., it is a product of code checks, possibly times logical operators that pin the state, and acts trivially on the target state.
Now, we consider logical gate design. For a logical gate , the target is its Choi state. A residual Pauli on the data qubits should preserve the code space and also act trivially on the logical space. Hence, we use , the group generated by the code checks (henceforth denoted as where ). While the Bell generators stabilize the Choi state, they are not included as they act on the reference qubits, and they contain logical operators which, when multiplied with the data qubits, alter the action of the gate. Now, as in the case of logical state preparation, a natural starting point for is the code checks , as all of has zero syndrome against them. But this is not sufficient as there are other Paulis which have zero syndrome against the code checks as well. Specifically, a residual has zero syndrome against when it commutes with every , i.e., it lies in the normalizer . This contains not only itself, but also all the logical Pauli operators, each of and . This is an issue as a syndrome against alone would let logical errors pass through. E.g., for a Pauli with , the residuals and have the same syndrome against , and our verifier would then judge them similarly. However, on encountering , the QEC round would apply the lightest correction with this syndrome, so . Then has zero syndrome with weight at most , so it must lie in . Hence, we are left with , which is a logical error that would alter the gate action. Therefore, we calculate the extended syndrome against the code checks , along with the logical operators
where the last two terms are the logical operators of the output code, mapped by the target gate. This extended syndrome is a length- binary vector. As is a logical Clifford, the mapped rows are still logical Pauli operators. We use these mapped rows instead of and because they already constitute a part of the logical Bell generators of the target Choi state (Appendix § 2.0.1). , as constructed here, is such that a residual with zero extended syndrome against it must be a code check, and not a logical operator. This is because commuting with the means that the residual is not detected by the following QEC round, so it is a product of any number of code checks and logical operators. Commuting with all logical operators means that it acts as an identity on the logical qubits. Hence, it can only be a code check. Hence, the syndrome against fixes a residual up to a code check. In the example above, the two residuals differing by are now distinguished by their commutator with the last rows of containing the logical operators.
Two cases need a small adaptation. For a code switch, the residual is judged on the output code’s qubits, and is built from the output code. For a gate on several code blocks, such as a logical CNOT between two blocks, each block is followed by its own QEC round, so Eq. (1) is applied to each block separately.
For an error-detecting code with distance two, such as the code used in § 2 B, we have . Hence, the fault tolerance criterion concerns only detection, as nothing can be corrected. A single fault is then fine only if its residual is a stabilizer. If the residual has a non-zero syndrome, the following QEC round detects it, and the fault is undecodable. If the syndrome is zero, the residual may be a stabilizer, in which case a non-trivial pattern makes it forfeited, or the residual may be a logical error, in which case it is silent when the pattern is trivial, and undecodable when the pattern is non-trivial.
We remark that for CSS codes, there are a couple of simplifications. The first one concerns the preparation of or . To this end, write each event residual as , ignoring phases. Since the stabilizer generators are either of purely or purely -type, commutes with the -type stabilizers and likewise commutes with the -type stabilizers, so the syndrome of comes only from the -type stabilizers. Hence, we assume a CSS decoder in the QEC round, which uses the syndrome against the - and -type stabilizers to obtain the corrections and for and , respectively, and then applies . The residual and its correction have the same syndrome, and thus the products and have zero syndrome and commute with all stabilizers. Now, noting that the logical operators and can be chosen as pure - and -type Pauli strings, respectively, we can ignore the -type event residuals for preparing [13, 44, 45]. This is because, even with wrong -type decoding, in the sector the final state differs from the target state by which, by virtue of commuting with all stabilizers as mentioned above, can only be a stabilizer, possibly times , which leaves unchanged. A similar argument applies to the preparation of , where we can ignore the -type event residuals.
The second simplification concerns logical gates and applications using CSS codes, providing a relaxed version of Eq. (1). This assumes that the QEC round following the circuit uses the CSS decoder mentioned above. Since it decodes and independently, and are purely -type, and of weight at least , and can each be corrected independently up to weight . Hence, the argument above holds separately for and . An event of order is therefore correctable when has the same syndrome against (cf. Eq. (4)) as some -type Pauli of weight at most , and as some -type Pauli of weight at most . Note that also contains the logical operators, which ensure that the residual is not a logical error. Even with them, it is sufficient to check and independently. Let () be the minimum-weight ()-type correction that the CSS decoder obtains from the syndrome of () against the code generators. The correction succeeds when is a stabilizer, i.e., has zero syndrome against . For a CSS code, every stabilizer is a product of a pure -type and a pure -type stabilizer. is a stabilizer iff and are stabilizers themselves. The correction thus succeeds when it succeeds on each part, so the logical rows do not couple and , and the separate checks above suffice.
Now, we briefly go over our argument for how the idling faults are indirectly captured by our approach. Consider a qubit waiting between two consecutive operations that act on it. Nothing acts on that qubit in between, so a Pauli inserted anywhere inside the window is conjugated by precisely the same gates as one inserted immediately after the earlier operation. Whenever either end of the idling window is a gate, the idling fault therefore reproduces one of the fault Paulis already enumerated there, and our earlier discussion applies. As a result, idling faults cannot invalidate the fault tolerance. Since the idle time of the qubits, and consequently the possibility of idling faults, is commensurate with the depth of the circuit, we explicitly minimize the depth. Reducing depth is also beneficial for reducing the runtime of the circuit.
The fault tolerance criterion given by Eq. (1) considers events of every order up to , i.e., all sets of up to simultaneous faults, the number of which increases combinatorially with increasing order and circuit size. We efficiently enumerate all the events and their patterns as follows: (a) A fault is a Pauli inserted immediately after a non-Pauli gate or at the input of a qubit, or a flipped measurement outcome. The Pauli gates are tracked in software and carry no faults [40]. Ignoring phases, which do not affect a residual’s weight or syndrome, a Pauli is specified by two bit vectors and marking the qubits where it has an or a component. The product of two Paulis and has the bit vectors and . All faults are propagated to the end of the circuit, and we accumulate the two things required to quantify fault tolerance: the residual that a fault leaves on the data qubits, and its pattern (set of flipped detectors). Faults are propagated by using the fact that a fault Pauli preceding a Clifford gate is equivalent to the Pauli following the gate. This operation acts on ’s bits -linearly by XOR and swap, e.g., and for a CNOT from qubit to qubit , for on qubit , etc. A measurement of qubit flips its outcome iff , i.e., iff anticommutes with . It keeps but resets to , since it leaves in an eigenstate of . The measurement step is thus linear in ’s bits. Whether a fault flips a given outcome, in this way or by a readout error, is thus linear in the fault. Its pattern is linear in the faults as well, as each detector is a fixed XOR of outcomes. Lastly, a conditional Pauli fires on the XOR of some outcomes, making it linear in the faults. If a fault flips an odd number of them, whether is applied or not changes relative to the fault-free circuit. This multiplies the propagated fault by . Since every step is -linear, the residual and pattern of a higher-order event composed of several faults are simply the XOR of those of its constituent faults. The syndrome of a higher-order event composes similarly. Since the product of two Paulis anticommutes with a row of iff exactly one of and does, i.e., . This bypasses an explicit multi-fault propagation. (b) For state preparation, the heralded and wasted events are counted only at order one (cf. § 1.1). Since we assume that each gate failure, input error, and measurement error occurs with a similar physical probability , each fault of a two-qubit gate weighs , while those of a one-qubit gate or input error weigh , and each measurement error weighs . The herald and waste are calculated by performing a weighted sum of the faults, using these weights. Thus they approximately equal the probability, in units of the physical error rate , of discarding the shot under post-selection. (c) For logical gates, the decoder discards a shot only when the pattern is non-empty and the bin is ambiguous (cf. § 1.1), so we evaluate the undecodable and forfeited events at every order . The bin of an event is again the XOR of the bins of its constituent faults. We collect the bins of all events of order at most , and a bin is ambiguous when two of its events have residuals that differ by a logical operator. Each event with a non-empty pattern in an ambiguous bin is then undecodable if its residual is heavy, and forfeited otherwise.
Lastly, we consider the classification of measurements as deterministic or random for the gate design and applications. The classification is based on the Choi state, whereas the actual circuit acts on codewords. We need to show that the classification on the Choi state matches that on every codeword. We consider the deterministic and random cases separately. A measurement is deterministic when the measured operator belongs, up to a sign, to the stabilizer group of the circuit at the time of measurement. At any point in the circuit, the stabilizers of the Choi state contain the code checks, the of each ancilla, and the Bell generators and , each evolved by the preceding operations. Since nothing acts on the reference qubits, the latter become and , where primes denote evolved logical operators. Since the measured operator does not act on the reference qubits, it cannot contain any Bell generators, and is a product of the evolved code checks and ancilla s only. These stabilize the evolved state of every codeword, so the outcome is deterministic on every codeword. For a random measurement, the measured operator anticommutes with some stabilizer of the Choi state. If this is an evolved check or ancilla , which stabilizes every codeword, the outcome is then random on every codeword as well. Otherwise it commutes with all the evolved checks and ancilla s and anticommutes only with some Bell generator. As it does not act on the reference qubit, it must then anticommute with the logical operator in the Bell generator. So it must be some logical operator itself. Measuring it would collapse the encoded state, so this cannot happen in a valid circuit.
Verification of dynamic Clifford circuits
Here we use the results of Ref. [37] to check the validity of our dynamic Clifford circuits. This is not trivial as they contain measurements, as well as conditional Paulis accepting these measurement outcomes as their condition, and validity must be checked for all possible combinations of measurement outcomes.
Symplectic part:– We start with the verification of the symplectic part. A circuit contains both random and deterministic measurements, in general. Deterministic measurements have definite and known outcomes, and thus contribute only a single branch. However, random measurements have branches corresponding to all possible outcomes. To verify validity, we must ensure that on each of these exponentially many branches, the data qubits reach the desired target state (Choi state for gates) and the ancillae are disentangled from them. This rules out brute-force enumeration. However, on restricting the conditions of the conditional Paulis to XOR/parity of outcomes, we can verify validity with only validity checks instead of . We show this below:
(a) A measurement of some Pauli is random if anticommutes with some generator of the current state, and deterministic otherwise, as then belongs to the state’s stabilizer group. Thus, whether a given measurement is random or deterministic is decided solely by the symplectic part (the and bits) of the stabilizer tableau. This is a property of the circuit, independent of the measurement outcomes. This is because the branches differ only in the signs introduced by random measurements, and which conditional Paulis are applied, and Paulis alter only the signs of the tableau. In either case, the symplectic part is unchanged.
(b) We restrict to the class of stabilizer circuits considered by Ref. [37], containing Clifford gates, Pauli (here, ) measurements, and Pauli gates conditioned on the parity of measurement outcomes. We define as the outcome of the th random measurement, so that a branch is labeled by , with the reference branch. Our circuits start from a fixed stabilizer state , which is for state preparation, and the input Choi state for gate design (Appendix A). On branch , the circuit acts as a linear map , where the dependence arises from the random outcomes and the conditional Paulis conditioned on them. Since Ref. [37] starts from , we write our as , where is a Clifford, which is always possible [31]. We then apply their results to . Now, according to Ref. [37], there exist a Clifford and binary matrices and , such that the final state and the outcome of the th deterministic measurement satisfy
where the row of specifies how depends on the random outcomes. If a measurement of is deterministic, then belongs to the stabilizer group (see (a)), and its outcome is given by this sign. However, this may depend on earlier random outcomes. For example, measuring on gives a random and leaves the state stabilized by . Measuring again is then deterministic with outcome . Also, for some bit vector , applies to every qubit for which , so . At , (5) gives the reference state , which is produced by a single simulation. We now express every branch in terms of this reference. Using , with the th column of , we obtain
where each is a Pauli, since is Clifford.
(c) Finally, we show that only checks, the reference branch with all random outcomes set to zero , and branches with a single outcome flipped , determine all branches. Note that in (7) is the state defined on all qubits, which includes the data, reference, as well as ancilla qubits. The target is defined on the set containing the data qubits, and for gates also the reference qubits. The ancillae may end up in any state, as long as they are disentangled from . We start by checking that the reference branch reaches the target, i.e., , for some ancilla state . Every other branch differs from the reference only by the Pauli . Since is Pauli for each , it factorizes as , with Pauli strings acting on and on , so that
with and . Thus, the data and ancilla remain disentangled on every branch, with the ancillae in some irrelevant state . So we only need to check that the state on reaches the target. The branch with the th outcome flipped reaches the target iff , which implies as , i.e., either or belongs to the target’s stabilizer group. Provided for all , it is clear that on every branch . Hence, it is sufficient to check the reference branch, and the branches each with a single outcome flipped.
Signs: If the symplectic part matches, the branches may differ from the target only in the signs of the generators. This is the situation when the conditional Pauli corrections can repair the circuit and ensure that the signs match in every branch.
Before proceeding, we show a result that the signs combine GF(2)-linearly. To obtain the signs, we simply operate on the state with the generator. Consider an unsigned generator , and start with the reference branch. Applying to the reference state yields , implying that the signed generator should have the sign in the reference branch. To establish the signs of the other branches, use the branch specific state obtained above in (7),
where is the symplectic product of two Pauli strings, defined by . In terms of their and bits, , which is linear in each argument, so .
Now, we get the sign
Here is simply the sign flip, relative to the reference branch’s sign , introduced in the branch . Now, the signs in each branch must match that of the target for that generator (), which yields
Considering all the generators, we obtain the GF(2)-linear system
Now we look at a quantity that gives the fraction of branches whose signs match the target’s signs
Match: An invalid circuit must still be scored, as the search benefits from a “gradient” towards valid circuits. This involves quantifying how close the symplectic part of the tableau, and the signs, are to those of the target state. For the latter, we already have Eq. (13). For the former, we calculate the similarity of the tableaux of the final state and the target. Let and be the flattened bit strings formed by the , and sign bits of the canonical tableaux of a branch and of the target. We define tableau similarity as their Jaccard similarity , where counts the ones, averaged over the simulated branches. The match (cf. Eq. (2)) is
It is 1 for a valid circuit and is smaller otherwise.
Pseudocode
In this section we provide pseudocode for a concise description of our workflow.
Agentic FunSearch loop
tools ← Test, Python // see below
for generation = 1, …, N_gen
for island = 1, …, N_islands
parents ← best of island and K − 1 of its other programs
prompt ← task, circuit class API, parents with
feedback, scratchpad notes of island
(program, notes) ← LLM(prompt, tools)
for every size in grid
circuit ← program(size)
σ_size ← score of Verify(circuit)
insert program into island, in the cluster of
σ_size at the largest size
every migrate generations copy the best program
of every island to island+1
return the best program, ranked by σ_size at all sizes
The agentic FunSearch loop, as described in § 1.1. The run takes place on independent islands, and covers generations. Each island maintains its own database of programs clustered by their score, Eq. (2). The LLM can call two tools before returning a program: Test accepts only a program, scores it on grid as below, and returns the verifier report that a parent carries in the prompt. Python runs any Python code with the circuit class, the targets and the verifier in scope, and returns what the code prints, so that, e.g., many variants can be compared in one call, or single faults traced by hand. Along with the program, the LLM returns scratchpad notes, shown in the island’s next prompt. grid denotes the set of layout sizes at which the program is scored, which can be a single layout, or multiple, e.g., the layouts for the surface code. The clusters are keyed by the score at the largest size, and the programs within a cluster are ranked by the scores at the smaller sizes, which gives the lexicographic order of § 1.1. Every migrate generations, the best program of each island is copied to the next island.
Verifier
TableauSimulate(circuit, force_rand):
run circuit on the input tableau with the j-th random
outcome set to force_rand_j
return final tableau τ, outcomes o, number k
of random outcomes
ScoreFT(circuit, detectors):
initialize faults
propagate faults to get their residual E_f on data qubits
and its pattern p_f of flipped detectors
H ← {f ∈ faults : wt_s(E_f) > min(1,t)} // heavy
silent_1 ← |{f ∈ H : p_f = ∅}|
herald ← weight of {f ∈ H : p_f ≠ ∅}
waste ← weight of f ∉ H with p_f ∈ {p_h : h ∈ H, p_h ≠ ∅}
for i = 2, …, t do
silent_i ← number of sets of i faults with
⊕ p_f = ∅ and wt_s(⋂ E_f) > i
return silent_1,…,silent_t, herald, waste
Here we show the two subroutines used by the verifier below. TableauSimulate runs the circuit circuit on the input stabilizer tableau, with the -th random measurement outcome forced to force_rand. ScoreFT obtains the fault tolerance metrics of a valid circuit with detectors detectors (Appendix § 2.1), shown here for state preparation. Each single fault in faults is propagated to the end of the circuit to obtain its residual on the data qubits. The faults are subsequently classified as mentioned in Appendix § 2.1. For gates, the faults are instead binned by their detector pattern and code-check syndrome, and the undecodable and forfeited events of (3) are counted. This follows similarly and is not shown here for brevity. With the CSS simplification, is evaluated separately on the and parts.
Verify(circuit):
(τ₀, o⁽⁰⁾, k) ← TableauSimulate(circuit, 0)
for j = 1, . . . , k
(τⱼ, o⁽ʲ⁾) ← TableauSimulate(circuit, eⱼ)
detectors ← (1) deterministic outcomes,
(2) fixed XORs of outcomes, e.g., a random outcome and its
repeat
if τⱼ = τ⋆ ∀j = 0, . . . , k // valid
return match 1 and ScoreFT(circuit, detectors)
Vᵢ,ⱼ ← r(τⱼ) ⊕ r(τ₀), v ← r(τ₀) ⊕ r⋆
if V s = v is solvable
branch_frac ← 2⁻ʳᵃⁿᵏ V
else
branch_frac ← 0
sim ← mean Jaccard similarity of τⱼ to τ⋆
return match (branch_frac + sim)/2
The verification process, as described in Appendix § 2.1.1: First, the tableau simulations with TableauSimulate identify the detectors. If the final tableau matches the target tableau for all these branches, then the circuit is valid and we obtain the fault tolerance metrics with ScoreFT. Otherwise, we return the match, computed from the branch fraction and the tableau similarity as described in Appendix § 2.1.1.
Prompt
Prompt(island, generation):
// fixed
role: write a program returning a fault-tolerant Clifford circuit
target: the task in words, the initial and target generators
primer: the Choi construction, how gates and measurements
act on the tableau, the fault locations and the repair criterion
layout: data and ancilla qubits, couplings, evaluated sizes, t
signature build_circuit(n_data, n_anc) with a CONCEPT
docstring
design protocol: first validity, then silent, depth, herald, waste
circuit API with the gate set, and the program rules
how to read the verifier report
tool budgets, and the answer format: scratchpad notes, then
the program
// changes every generation
K parent programs from island, each with its program, σ and
verifier report
recent errors, the scratchpad notes of island, the search
progress
task: write an improved program that differs from every parent
Here we outline the contents of the prompt. The fixed part comes first to allow effective caching.
LLM-generated circuit
Here, we present the LLM-generated program for the Reed-Muller (RM) to Steane (S) switch (see Tab. III).
def build_circuit(n_data, n_anc):
"""CONCEPT: Change the gate body to parallel X-basis
puncturing: measure Reed-Muller data 7--14 while
retaining their known even outcome parity as a detector.
Transfer the remaining Steane block into data 15--21
with two CNOTs per wire, then restore its X-check signs
with even-weight Z feedforward. Implement each H readout
by rotating the discarded data, saving a layer over
ancilla-controlled readout. The parity detector and
output check syndrome distinguish readout faults without
postselection.
"""
qc = Circuit(n_data, n_anc)
outcomes = []
for j in range(8):
qc.h(qc.data[7 + j])
qc.cnot(qc.data[7 + j], qc.anc[j])
outcomes.append(qc.measure(qc.anc[j]))
for j in range(7):
qc.cnot(qc.data[j], qc.data[15 + j])
qc.cnot(qc.data[15 + j], qc.data[j])
corrections = (
(16, (1, 3, 5, 7)),
(17, (1, 2, 5, 6)),
(15, (2, 3, 4, 5)),
(19, (4, 5, 6, 7)),
)
for q, bits in corrections:
qc.z(qc.data[q], cond=[outcomes[j] for j in bits])
return qc
The circuit is presented in Figure 5. We also show three scratchpad notes from this search in Figure 6.
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 – of the RM block – in the basis, and moves the face – to the fresh S block –. – are ancillae.

Figure 6. Scratchpad notes from the Steane to Reed–Muller switch search of Figure 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.
(a) GPT-6-luna [high], generation 27, island 0
SCRATCHPAD
Scope: Exact verification at ‘n_data=15’, ‘n_anc=2’, residual tolerance ‘t=1’; the certificate is for single faults.
KEPT -- new depth-20 body: In the compressed first Z-check parity, use the opposite temporary-data orientation: ‘d6->d7; d7->s; d6->d7‘, followed by ‘d9->s‘. Keep the deterministic four-probe schedule and the remaining conversion body.
Exact test result: Valid on every branch; ‘silent1=0‘, ‘herald1=0‘, ‘waste1=0‘, depth 20, 49 operations, 4 measurements, 670 single faults. All measurements are deterministic zero; no feedforward or postselection. The tested circuit is the one submitted below.
FAILED orientation: ‘d7->d6; d6->s; d7->d6; d9->s‘ is valid at depth 20 but leaves one silent fault, born at ‘CNOT d6->a0‘, with residual ‘X{6} Z{9}‘. Reversing the temporary-data orientation removes it in the exact test.
Reference point: The prior depth-21 construction is also fully fault tolerant. The newly tested circuit changes the gate body, so it differs from the listed parents.
Deferred: Search for a depth below 20 while retaining zero silent, herald, and waste costs. No claim of improvement beyond the tested single-fault certificate.
(b) GPT-6-luna [max], generation 10, island 0
SCRATCHPAD
Kept -- shortened flagged-probe construction. The tested circuit removes the early ‘CNOT(s,f)‘ echo pair, reads the four flagged parity probes in ascending order, omits the readout after the first probe, and cancels the adjacent shared ‘d13 -> s‘ couplings across that unmeasured boundary. ‘test_build_circuit‘ verified it at the evaluated size: valid, ‘silent1=0‘, ‘herald1=0‘, ‘waste1=0‘, depth 38, 59 operations, 5 deterministic measurements, and branch fraction 1. No claim about fault orders above 1.
Sweep evidence. With the early echo pair removed, a sweep of probe orders and omitted-readout positions found 12 zero-cost variants; the best depth was 38. The selected ascending-order variant was then directly verified.
Ablations. Keeping the early echo pair gave a valid zero-cost depth-39 version; removing it yielded the verified depth-38 version. Removing either source-flag or individual probe-flag pairs introduced silent single faults. In one probe-0-flag ablation, the two silent faults were born at ‘CNOT d11->a0‘ and ‘CNOT d14->a0‘, with residual ‘Z{9,10}‘; restoring the flag pair eliminated them.
Design change. This differs from the listed parents in both the gate body (the echo pair is removed) and the detector schedule (ascending probe order and a combined first-probe boundary). Retain the flags; do not infer tolerance beyond the verified single-fault order.
(c) GPT-6.1-sol [high], generation 12, island 0
SCRATCHPAD
Kept -- parallel mutually flagged final probes, depth 26. Both final exact tests at ‘(4,2)‘ certify validity, ‘silent1=0‘, ‘herald1=0‘, ‘waste1=0‘, depth 26, 54 operations, 4 deterministic measurements, 721 faults, branch fraction 1. Certification covers single faults only.
Change from the depth-31 parent: retain the conversion body and merged first detector. Read the source flag immediately afterward, then reuse both ancillae for two parallel Z-check probes.
Final probe construction: prepare ‘s‘ in the X basis; ‘f‘ remains in the Z basis after its readout. Open with ‘CNOT(s,f)‘. Interleave ‘CZ(data[a],s)‘ on ‘[12, 14, 10, 8]‘ with ‘CNOT(data[b],f)‘ on ‘[13, 11, 9, 7]‘. Close with ‘CNOT(s,f)‘, then measure ‘s‘ in X and ‘f‘ in Z. The shared CNOTs mutually flag the probes.
Kept scheduling details: retain root order ‘13,8,10,9,11,12‘, cat-check order ‘9,10,11,13,12,8,14,7‘, delayed ‘d5 -> d13‘, and source-flag closure after the first probe’s second flag interaction.
Verified intermediate -- symmetric CZ probes: separately reading the old flag, then using two X-basis ancillae and two mutual CZs, gave zero costs at depth 27. Changing one probe to a Z-basis CNOT target removes two Hadamards and gives depth 26.
Failed -- merge the old flag readout into the parallel probes: valid depth-26 variants had silent faults. The tested outermost mutual-CZ placement had 13 silent faults. Reading the old flag separately removed them.
Ablations: deleting any single operation from the final depth-26 circuit either invalidated it or introduced silent faults. Deleting the separate source-flag measurement introduced 13 silent faults. Deleting either shared final CNOT introduced 137 silent faults.
Mutual-flag placement: in the symmetric implementation, opening before all data couplings and closing after all data couplings gave zero costs. Every other tested pair of symmetric boundaries introduced silent faults.
Source-flag closure sweep: retained placement gives zero costs at depth 26. Moving it earlier within the first probe introduced discard costs or silent faults; other zero-cost tested placements reached depth 28 or tied depth 26.
Failed -- compress the cat checker through ‘d13 -> d14’: replacing its two endpoint couplings by an earlier single coupling introduced 9–10 silent faults in the serial-detector construction.
Failed -- compensated compressed branch: copying ‘d5‘ into both ‘d13‘ and ‘d14‘ permits a shorter checker algebraically, but tested schedules had 4–8 silent faults and nonzero herald cost.
Failed -- first parity includes d7 to absorb a flag interaction: sweep supports containing d7, their permutations, flag boundaries, and source-flag closing positions. Best tested variants still had 24 silent faults. Mixed-Pauli cancellations depend on the cat preparation and merged-check support.
Deferred: redesigning the conversion body and merged first check jointly may shorten the initial ten-layer checkpoint. No shorter zero-cost construction was verified here.
References
- [2]R. Acharya et al. (Google Quantum AI and Collaborators), Quantum error correction below the surface code threshold, Nature 638, 920 (2025).
- [3]D. Bluvstein, S. J. Evered, A. A. Geim, S. H. Li, H. Zhou, T. Manzivits, S. Ebadi, M. Cain, M. Kalinowski, D. Hangleiter et al., Logical quantum processor based on reconfigurable atom arrays, Nature 626, 58 (2024).
- [4]D. Bluvstein, A. A. Geim, S. H. Li, S. J. Evered, J. P. Bonilla Ataides, G. Baranes, A. Gu, T. Manovitz, M. Xu, M. Kalinowski et al., A fault-tolerant neutral-atom architecture for universal quantum computation, Nature 649, 39 (2026).DOI
- [5]E. Rosenfeld et al., Magic state cultivation on a superconducting quantum processor, Science (2026), 10.1126/science.aee7961.DOI
- [6]T. Peham, L. Schmid, L. Berent, M. Müller, and R. Wille, Automated synthesis of fault-tolerant state preparation circuits for quantum error-correction codes, PRX Quantum 6, 020330 (2025).
- [7]D. Kremer, V. Villar, H. Paik, I. Duran, I. Faro, and J. Cruz-Benito, Practical and efficient quantum circuit synthesis and transpiling with reinforcement learning, arXiv:2405.13196.
- [8]S. Rietsch, A. Y. Dubey, C. Ufrecht, M. Periyasamy, A. Plinge, C. Mutschler, and D. D. Scherer, Unitary synthesis of Clifford+T circuits with reinforcement learning, in 2024 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE, Piscataway, NJ, 2024), pp. 824–835.
- [9]M. Doherty, M. Puviani, J. Brewer, G. Matos, D. Amaro, B. Criger, and D. T. Stephen, Fast stabilizer state preparation via AI-optimized graph decimation, arXiv:2603.17743.
- [10]J. Olle, R. Zen, M. Puviani, and F. Marquardt, Simultaneous discovery of quantum error correction codes and encoders with a noise-aware reinforcement learning agent, npj Quantum Inf. 10, 126 (2024).
- [11]T. Fösel, P. Tighineanu, T. Weiss, and F. Marquardt, Reinforcement learning with neural networks for quantum feedback, Phys. Rev. X 8, 031084 (2018).
- [12]T. Fösel, M. Y. Niu, F. Marquardt, and L. Li, Quantum circuit optimization with deep reinforcement learning, arXiv:2103.07585.
- [13]R. Zen, J. Olle, L. Colmenarez, M. Puviani, M. Müller, and F. Marquardt, Quantum circuit discovery for fault-tolerant logical state preparation with reinforcement learning, Phys. Rev. X 15, 041012 (2025).
- [14]N. Rengaswamy, R. Calderbank, S. Kadhe, and H. D. Pfister, Logical Clifford synthesis for stabilizer codes, IEEE Trans. Quantum Eng. 1, 1 (2020).DOI
- [15]E. J. Kuehnke, K. Levi, J. Roffe, J. Eisert, and D. Miller, Hardware-tailored logical Clifford circuits for stabilizer codes, arXiv:2505.20261.arxiv.org/abs/2505.20261
- [16]H. Chen, M. Vasmer, N. P. Breuckmann, and E. Grant, Automated discovery of logical gates for quantum error correction, Quantum Inf. Comput. 22, 947 (2022).
- [17]N. Meyer, C. Mutschler, D. Seuß, A. Maier, and D. D. Scherer, Learning logical operations for arbitrary quantum error correction codes, Phys. Rev. A 114, 032424 (2026).
- [18]H. Sayginel, S. Koutsioumpas, M. Webster, A. Rajput, and D. E. Browne, Fault-tolerant logical Clifford gates from code automorphisms, PRX Quantum 6, 030343 (2025).arxiv.org/abs/2409.18175
- [19]A. Benhemou and N. Berthusen, Automated logical Clifford gadgets for heterogeneous architectures via chain maps, arXiv:2607.02482.
- [20]N. Shutty and C. Chamberland, Decoding merged color-surface codes and finding fault-tolerant Clifford circuits using solvers for satisfiability modulo theories, Phys. Rev. Appl. 18, 014072 (2022).
- [21]N. Dupuis, L. Buratti, S. Vishwakarma, A. Viudes Forrat, D. Kremer, I. Faro, R. Puri, and J. Cruz-Benito, Qiskit Code Assistant: Training LLMs for generating quantum computing code, in 2024 IEEE LLM Aided Design Workshop (LAD) (IEEE, Piscataway, NJ, 2024), pp. 1–4.
- [22]N. Dupuis, A. Tiwari, Y. Mroueh, D. Kremer, I. Faro, and J. Cruz-Benito, Quantum verifiable rewards for post-training Qiskit Code Assistant, arXiv:2508.20907.
- [23]X. Guo, M. Wang, and J. Zhao, QuanBench: Benchmarking quantum code generation with large language models, in 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE) (IEEE, Piscataway, NJ, 2025), pp. 2657–2669.
- [24]J. Cruz-Benito and I. Faro, Qiskit QuantumKatas: Adapting Microsoft’s quantum computing exercises for LLM evaluation, arXiv:2605.2710.
- [25]A. Paz, C. Tarta, C. Y. Li, M. Sun, S. Patel, and S. Lausier, StabilizerBench: A benchmark for AI-assisted quantum error correction circuit synthesis, arXiv:2604.21287.
- [26]B. Romera-Paredes, M. Barekatain, A. Novikov, M. Balog, M. P. Kumar, E. Dupont, F. J. R. Ruiz, S. J. Elnl enberg, P. Wang, O. Fawzi, P. Kohli, and A. Fawzi, Mathematical discoveries from program search with large language models, Nature 625, 468 (2024).
- [27]A. Novikov, N. Vũ, M. Eisenberger, E. Dupont, P.-S. Huang, A. Z. Wagner, S. Shirobokov, B. Kozlovskii, F. J. R. Ruiz, A. Mehrabian, M. P. Kumar, A. See, S. Chaudhuri, G. Holland, A. Davies, S. Nowozin, P. Kohli, and M. Balog, AlphaEvolve: A coding agent for scientific and algorithmic discovery, arXiv:2506.13131.
- [28]Z. Liu and F. Marquardt, Large-language-model discovery of quantum LDPC codes through structured concept evolution, arXiv:2606.24808.
- [29]J. Cruz-Benito, A. W. Cross, D. Kremer, and I. Faro, Evolutionary discovery of bivariate bicycle codes with LLM-guided search, arXiv:2606.02418.
- [30]M. Nägele and F. Marquardt, Agentic exploration of physics models, Phys. Rev. X 16, 031002 (2026).DOI
- [31]S. Aaronson and D. Gottesman, Improved simulation of stabilizer circuits, Phys. Rev. A 70, 052328 (2004).DOI
- [32]A. Jamiolkowski, Linear transformations which preserve trace and positive semidefiniteness of operators, Rep. Math. Phys. 3, 275 (1972).
- [33]M.-D. Choi, Completely positive linear maps on complex matrices, Linear Algebra Appl. 10, 285 (1975).
- [34]M. A. Nielsen and I. L. Chuang, Programmable quantum gate arrays, Phys. Rev. Lett. 79, 321 (1997).DOI
- [35]D. Gottesman and I. L. Chuang, Demonstrating the viability of universal quantum computation using teleportation and single-qubit operations, Nature 402, 390 (1999).
- [36]T. Peham, N. Brandl, R. Kueng, R. Wille, and L. Burgholzer, Depth-optimal synthesis of Clifford circuits with SAT solvers, in 2023 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE, Piscataway, NJ, 2023), pp. 802–813.arxiv.org/abs/2305.01674
- [37]V. Kliuchnikov, M. Beverland, and A. Paetznick, Stabilizer circuit verification, arXiv:2309.08676.
- [38]R. Chao and B. W. Reichardt, Quantum error correction with only two extra qubits, Phys. Rev. Lett. 121, 050502 (2018).DOI
- [39]C. Chamberland and M. E. Beverland, Flag fault-tolerant error correction with arbitrary distance codes, Quantum 2, 53 (2018).DOI
- [40]E. Knill, Quantum computing with realistically noisy devices, Nature 434, 39 (2005).pubmed.ncbi.nlm.nih.gov/15744292
- [41]P. Aliferis, D. Gottesman, and J. Preskill, Quantum accuracy threshold for concatenated distance-3 codes, Quantum Inf. Comput. 6, 97 (2006).DOI
- [42]B. W. Reichardt, D. Aasen, and R. Chao, Fire and ice: Partially fault-tolerant quantum computing with selective state filtering, arXiv:2605.15344.arxiv.org/abs/2605.15344
- [43]E. Knill, Fault-tolerant postselected quantum computation: Schemes, arXiv:quant-ph/0402171.
- [44]L. Colmenarez, R. Zen, J. Olle, F. Marquardt, and M. Müller, Unitary fault-tolerant encoding of Pauli states in surface codes, npj Quantum Inf. 12, 159 (2026).
- [45]H. Goto, Minimizing resource overheads for fault-tolerant preparation of encoded states of the Steane code, Sci. Rep. 6, 19578 (2016).DOI
- [46]R. Zen, rIftqc: Reinforcement learning for fault-tolerant quantum circuit discovery, 2023, https://github.com/remmzen/rIftqc.
- [47]M. McEwen, D. Bacon, and C. Gidney, Relaxing hardware requirements for surface code circuits using time-dynamics, Quantum 7, 1172 (2023).DOI
- [48]R. Laflamme, C. Miquel, J. P. Paz, and W. H. Zurek, Perfect quantum error correcting code, Phys. Rev. Lett. 77, 198 (1996).pubmed.ncbi.nlm.nih.gov/10061806
- [49]H. Bombín and M. A. Martin-Delgado, Optimal resources for topological two-dimensional stabilizer codes: Comparative study, Phys. Rev. A 76, 012305 (2007).DOI
- [50]A. G. Fowler, M. Mariantoni, J. M. Martinis, and A. N. Cleland, Surface codes: Towards practical large-scale quantum computation, Phys. Rev. A 86, 032324 (2012).DOI
- [51]C. Ryan-Anderson et al., Implementing fault-tolerant entangling gates on the five-qubit code and the color code, arXiv:2208.01863.
- [52]H. Bombín and M. A. Martin-Delgado, Topological quantum distillation, Phys. Rev. Lett. 97, 180501 (2006).DOI
- [53]B. Eastin and E. Knill, Restrictions on transversal encoded quantum gate sets, Phys. Rev. Lett. 102, 110502 (2009).pubmed.ncbi.nlm.nih.gov/19392181
- [54]T. J. Yoder, R. Takagi, and I. L. Chuang, Universal fault-tolerant gates on concatenated stabilizer codes, Phys. Rev. X 6, 031039 (2016).
- [55]F. Butt, S. Heussen, M. Rispler, and M. Müller, Fault-tolerant code-switching protocols for near-term quantum processors, PRX Quantum 5, 020345 (2024).
- [56]C. Gidney, Inplace access to the surface code Y basis, Quantum 8, 1310 (2024).DOI
- [57]Y. Hirai, S. Ikari, Y. Ueno, and Y. Suzuki, A 2d × d × d spacetime volume implementation of a logical S gate in the surface code, arXiv:2604.13632.
- [58]C. Ryan-Anderson et al., High-fidelity teleportation of a logical qubit using transversal gates and lattice surgery, Science 385, 1327 (2024).
- [59]L. Daguerre, R. Blume-Kohout, N. C. Brown, D. Hayes, and I. H. Kim, Experimental demonstration of high-fidelity logical magic states from code switching, Phys. Rev. X 15, 041008 (2025).DOI
- [60]L. Daguerre and I. H. Kim, Code switching revisited: Low-overhead magic state preparation using color codes, Phys. Rev. Res. 7, 023080 (2025).DOI
- [61]C. Gidney, N. Shutty, and C. Jones, Magic state cultivation: Growing T states as cheap as CNOT gates, arXiv:2409.17595.arxiv.org/abs/2409.17595
- [62]K. Sahay, P.-K. Tsai, K. Chang, Q. Su, T. B. Smith, S. Singh, and S. Puri, Fold-transversal surface code cultivation, PRX Quantum 7, 033006 (2026).DOI
- [63]F. K. Marqversen, G. Baranes, M. Sirotin, and J. Borregaard, Fault-tolerant interfaces for modular quantum computing on diverse qubit platforms, Phys. Rev. Res. 8, 023097 (2026).DOI
- [64]A. Gu, A. H. Kemeny, S. F. Yelin, and M. D. Lukin, Discovering state-of-the-art quantum circuits with large language models, arXiv:2610.22367.arxiv.org/abs/2610.22367
- [65]T. Khattar, N. C. Rubin, C. Gidney, M. Broughton, G. H. Low, and R. Babbush, Leveraging verifiable structure in quantum circuits to find more efficient compilations with agentic AI, arXiv:2610.23832.arxiv.org/abs/2610.23832
- [66]Y.-C. Zheng, C.-Y. Lai, and T. A. Brun, Efficient preparation of large-block-code ancilla states for fault-tolerant quantum computation, Phys. Rev. A 97, 032331 (2018).DOI
- [67]D. Gottesman, Surviving as a Quantum Computer in a Classical World (unpublished textbook draft, 2024).


