Discovering state-of-the-art quantum circuits with large language models
Abstract: Significant efforts are currently being directed toward the implementation of large-scale quantum information processors, but realizing useful quantum advantage also requires the development of efficient quantum algorithms. While for many practical problems the dominant resource costs are associated with a small set of computational primitives, optimizing them in the quantum setting presents unique challenges, including a reversibility constraint absent from ordinary classical computation. Here we introduce an evolutionary framework in which LLMs propose circuit designs and an independent evaluator verifies and scores them. We apply this framework to tasks spanning numerical computation, chemistry, optimization, quantum simulation, and number theory. In seven of the eight tasks, the discovered circuits significantly reduce both Toffoli and qubit counts relative to the state of the art. In the eighth, the search discovers a new reversible architecture for prime-field modular inversion. By handling reversibility differently, the architecture makes divsteps -- a classical algorithm previously impractical for reversible integer arithmetic -- viable and substantially improves the Toffoli-qubit trade-off for modular inversion. These results open the door for evaluator-guided LLM co-design of new algorithmic structures for quantum computation.
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper explores whether LLMs—the technology behind chatbots—can help invent better quantum computer circuits.
Quantum computers use special circuits made from quantum gates. These circuits must do calculations in a way that can be undone, or reversed. This makes quantum programming much harder than ordinary programming.
The researchers created a system in which:
- An LLM suggests a possible quantum circuit.
- A separate computer program checks whether the circuit is correct.
- The program measures how many gates and qubits the circuit uses.
- The LLM receives this feedback and tries to improve its design.
The goal was to discover quantum circuits that are smaller, cheaper, and more practical than existing designs.
2. What questions did the researchers ask?
The main research questions were:
- Can an LLM invent new quantum algorithms instead of merely making small changes to known circuits?
- Can the LLM find ways to reduce both:
- the number of expensive operations, and
- the number of qubits needed?
- Can this method solve different kinds of problems, such as:
- error correction,
- chemistry,
- optimization,
- physics simulations, and
- number theory?
- Can the LLM discover completely new ways to make ordinary algorithms reversible?
A particularly important challenge was reversibility. In a normal computer, temporary information can simply be erased. In a quantum computer, information cannot be thrown away carelessly. Temporary results must be cleaned up without disturbing the rest of the calculation.
3. How did the researchers conduct the study?
The LLM-and-evaluator system
The researchers gave the LLM a description of a task, but not instructions for how to solve it. The LLM then proposed a circuit written using a high-level Python-like programming interface.
An independent evaluator tested each proposal. It checked:
- whether the circuit gave the correct answer,
- whether temporary qubits were properly cleared,
- how many important gates it used, and
- how many qubits were needed at the same time.
This is similar to asking a student to invent a solution, then using a strict teacher and stopwatch to check both correctness and efficiency.
The researchers used an evolutionary search. This means they created many different ideas, improved promising ones, and allowed useful ideas from one group of solutions to be shared with another group.
How circuit cost was measured
Two main resources were counted:
- Toffoli gates: Important quantum gates that are expensive to perform. Fewer Toffoli gates usually means less work and a faster or simpler computation.
- Qubits: The quantum version of computer bits. Fewer qubits means the computer needs less physical space and hardware.
The researchers combined these numbers into a score called the -cost:
This score rewards circuits that use fewer gates and fewer qubits.
The eight test problems
The system was tested on eight different tasks, including:
- Reed–Solomon error decoding,
- quantum chemistry calculations,
- quantum simulations,
- numerical functions, and
- modular inversion, which means finding a number that behaves like a division result under a certain mathematical rule.
Because directly simulating large quantum systems can be extremely difficult, the evaluator tested the circuits on ordinary input patterns and tracked how the circuit changed them. This worked because the circuits studied were designed to transform basic bit patterns without creating complicated mixtures of possibilities during testing.
4. What were the main findings?
The circuits were usually much more efficient
In seven out of eight tasks, the discovered circuits used fewer Toffoli gates and fewer qubits than the previous designs.
Some improvements were especially large:
| Task | Approximate improvement in combined -cost |
|---|---|
| Reed–Solomon decoding | 12 times better |
| HHL rotation-angle calculation | 32 times better |
| Fixed-point Gaussian calculation | 39 times better |
| Coulomb potential calculation | 9.9 times better |
| Molecular simulation task | 4.1 times better |
| Lattice-gauge simulation | 7.7 times better |
These results suggest that the LLM was doing more than rearranging gates. It was finding better overall strategies for carrying out the calculations.
Finding 1: Route data instead of controlling many calculations
Suppose a program must choose between two calculations. A simple quantum version might build two separate controlled calculations—one for each choice.
The discovered circuits often used a smarter method:
- Move the needed data into the correct position.
- Perform one shared calculation.
- Move the data back.
This is like using one expensive machine and sending different materials through it, instead of buying two machines and switching between them.
This approach can greatly reduce the number of expensive gates.
Finding 2: Recover information instead of storing everything
Quantum calculations must often be undone. A straightforward method is to save every decision made during the calculation, like keeping a complete diary.
However, that diary can require many extra qubits.
The discovered circuits found ways to reconstruct past decisions from the current data. For example, certain bits or patterns in the current registers revealed which path the calculation had taken.
This is similar to figuring out which route someone took by looking at footprints, rather than having them write down every step.
This idea was especially useful for modular inversion, where the researchers used a version of the Euclidean algorithm called divsteps. The new design could recover many earlier choices from the current state instead of storing them all.
Finding 3: Ignore extremely rare difficult cases
Quantum algorithms often allow a very small chance of failure. The researchers used this small “failure budget” to avoid designing the circuit for unusually difficult inputs that almost never occur.
For example:
- A Reed–Solomon decoder might normally need space for up to 35 stored decisions.
- But under the expected input distribution, needing more than one stored decision was extremely rare.
- The researchers therefore designed the circuit for the common cases and accepted a tiny failure probability for rare cases.
In the modular inversion circuit, the design allowed failure for only about:
- of inputs because of history-stack overflow, and
- about of inputs because of unusual stopping times.
This saved many qubits while keeping the failure chance very small.
A new approach to modular inversion
One of the most important results was a new reversible design for prime-field modular inversion.
The researchers made the classical divsteps algorithm practical for a quantum computer. Their complete benchmark circuit used approximately:
- 4.0 million Toffoli gates, and
- 935 qubits.
The important achievement was not only improving an existing circuit. The LLM helped discover a new architecture for making the algorithm reversible.
5. Why are these results important?
Quantum computers are still difficult to build. Every extra gate can increase the chance of errors, and every additional qubit requires more hardware and error correction.
Therefore, reducing the number of gates and qubits can make quantum algorithms:
- more reliable,
- faster,
- less expensive to run, and
- easier to implement on real quantum hardware.
The paper also shows that improving a quantum algorithm is not always about simplifying individual gates. Sometimes the best improvement comes from changing:
- how information is stored,
- how different cases are handled,
- how temporary information is erased, and
- which rare situations the circuit needs to support.
In other words, the best quantum circuit may require redesigning the whole algorithm, not just polishing its parts.
6. What could this research lead to?
This research suggests that LLMs could become useful partners for discovering new quantum algorithms. They may be able to explore many possible designs faster than human researchers working alone.
In the future, similar systems might help design:
- quantum error-correction methods,
- better quantum computer hardware,
- more efficient chemistry and materials simulations,
- improved methods for optimization, and
- complete quantum computing systems that are designed together from the algorithm level down to the hardware level.
However, the method has limits. Its success depends on having:
- a clear description of the task,
- a reliable way to test correctness,
- a useful way to measure cost, and
- assumptions about which inputs and errors matter.
The researchers also used the product of gate count and qubit count as their main score. A real quantum computer might care more about other factors, such as circuit depth, communication between qubits, or the difficulty of correcting errors.
Overall, the paper shows that LLMs guided by strict computer testing can discover genuinely new and more efficient quantum circuit designs. This could help turn future quantum computers from experimental machines into useful tools.
Practical Applications
Immediate Applications
- Quantum software compilation and optimization (software, quantum computing): Integrate the evaluator-guided LLM workflow into quantum-compilation pipelines to generate and compare reversible implementations of arithmetic, decoding, simulation, and optimization subroutines. The reported reductions—up to roughly in cost for some benchmarks—could reduce logical-gate workloads and qubit footprints for near-term fault-tolerant designs. Dependencies: The task must have a precise reversible specification, candidates must be cheaply simulable or verifiable, and the objective should reflect the target hardware rather than relying exclusively on .
- Resource estimation for fault-tolerant quantum algorithms (quantum hardware and architecture): Use the discovered circuits as lower-cost resource-estimation components for algorithms involving Reed–Solomon decoding, HHL-style rotations, Coulomb potentials, Gaussian functions, chemistry, lattice-gauge simulation, and modular inversion. More realistic estimates of Toffoli counts and logical qubits can improve decisions about processor size, execution time, magic-state factories, and error-correction overhead. Dependencies: Toffoli count and peak qubits are proxies; actual performance also depends on circuit depth, connectivity, routing, measurement latency, error-correction code, and non-Clifford-state production.
- Reversible Reed–Solomon decoding for quantum optimization (optimization, coding, quantum algorithms): Deploy the Berlekamp–Massey-based reversible decoder in decoded quantum interferometry (DQI) and related quantum optimization workflows. The design reduces the reported Reed–Solomon decoder cost from approximately to in Toffolis and qubits, respectively. Dependencies: The improvement is tied to the specified syndrome structure, field representation, input distribution, and the permitted failure probability. Applications requiring worst-case correctness may need the full history stack and therefore incur higher qubit costs.
- Lower-cost coherent modular inversion (cryptography, number theory, quantum algorithms): Use the reversible divstep construction as a modular-inversion primitive in quantum algorithms involving finite-field arithmetic, quantum walks, hidden-structure problems, Gauss-sum calculations, and cryptographic analysis. The benchmark circuit uses approximately 4 million Toffolis and 935 qubits while avoiding a large explicit branch-history stack. Dependencies: The circuit assumes prime-field inversion, bounded failure probability, and a particular stopping-time window and history-stack capacity. It must be revalidated for different modulus sizes, input distributions, and worst-case requirements.
- Hardware-aware quantum circuit search (quantum-computing industry): Replace the paper’s objective with hardware-specific scoring functions that include logical depth, two-qubit error rates, connectivity, routing overhead, measurement cost, parallelism, and magic-state consumption. This would allow quantum-computing companies to use the LLM/evaluator loop as an automated co-design tool for processor-specific arithmetic libraries. Dependencies: The evaluator must accurately model the target architecture; optimizing an abstract gate metric may produce circuits that perform poorly after hardware mapping.
- Automated verification of reversible subroutines (formal methods, quantum software): Use the paper’s basis-state evaluator to test candidate circuits for correct input/output behavior, ancilla cleanup, phase correctness, and measurement-record independence. This can support regression testing for quantum libraries and provide a practical screening layer before expensive formal verification or hardware execution. Dependencies: Basis-state testing is especially effective for the paper’s restricted circuit model, where operations preserve computational-basis states up to phase. General quantum circuits that create broad superpositions may require different verification methods.
- Design-pattern library for reversible algorithms (academia and industry): Convert the three recurring principles into reusable engineering patterns:
- replace multiple controlled arithmetic blocks with conditional routing around one shared kernel;
- recover branch history from state invariants during uncomputation;
- localize expensive rare cases and use a declared failure budget.
These patterns can guide manual design of arithmetic, decoders, quantum-read-only memory routines, and simulation kernels. Dependencies: Conditional routing is useful only when branch outputs can be represented through a common canonical form; history decoding requires provable invariants; bounded-error methods require an application-level error budget.
- Teaching and research infrastructure for quantum algorithm design (academia): Adopt the framework as a laboratory platform in courses and research groups studying reversible computation, quantum compilation, formal verification, or LLM-assisted scientific discovery. Students and researchers could specify a function, implement an evaluator, generate algorithm families, and analyze the resulting trade-offs. Dependencies: Reproducibility requires access to the model, prompts, evaluator, circuit interface, random seeds, and complete benchmark specifications. LLM-generated mathematical reasoning still requires independent proof and testing.
- Bounded-error resource allocation in quantum workflows (quantum applications): Apply the paper’s statistical approach to allocate ancillas and iteration budgets according to an input distribution rather than the absolute worst case. For example, the modular-inversion circuit reserves resources for typical divstep paths and accepts failure probabilities on rare stopping times or stack overflows. Dependencies: The input distribution must be known or defensible, failures must be detectable or safely incorporated into the larger algorithm, and accumulated failure across repeated subroutine calls must remain below the algorithm’s total error budget.
Long-Term Applications
- End-to-end fault-tolerant quantum co-design (quantum architecture): Extend the evaluator-guided search across the algorithm, reversible circuit, quantum error-correcting code, logical-gate set, magic-state supply, and physical execution architecture. Instead of optimizing a circuit in isolation, the system could search for designs that minimize total runtime, physical-qubit count, logical error, or energy consumption. Dependencies: This requires scalable simulators and evaluators capable of propagating logical errors, scheduling constraints, decoding costs, and hardware resource demands across abstraction layers.
- New quantum algorithms rather than circuit-level optimizations (quantum algorithms and theory): Use LLM search to discover alternative classical algorithms, data representations, and reversible architectures jointly. The paper suggests that efficient classical algorithms can become impractical when naively made reversible; future searches could identify algorithms whose structure is inherently favorable for coherent execution. Dependencies: Candidate correctness may be difficult to evaluate for algorithms involving superpositions, interference, amplitude estimation, or non-basis-preserving operations. The framework will need stronger symbolic, numerical, and formal validation.
- Quantum chemistry and materials simulation (chemistry, materials science): Apply the discovered co-design principles to arithmetic for molecular Hamiltonians, Coulomb potentials, Gaussian basis functions, alias sampling, and lattice-gauge models. Lower-cost function evaluation could reduce the logical resources required for electronic-structure and materials calculations. Dependencies: Practical benefit depends on the cost of the complete simulation algorithm, not only an individual primitive. State-preparation, amplitude amplification, Hamiltonian encoding, fault tolerance, and precision requirements may dominate.
- Quantum-assisted optimization and decoding at scale (optimization, communications, coding): Generalize the reversible Reed–Solomon decoder to other error-correcting codes, constraint decoders, and algebraic optimization routines. This could support quantum versions of polynomial fitting, combinatorial search, signal reconstruction, and structured inference. Dependencies: The quantum speedup of the surrounding algorithm must be established, and the decoder’s failure probability must compose acceptably with interference-based computation. Code parameters and field sizes may substantially change the resource advantage.
- Automated discovery of quantum memory and data-movement architectures (quantum memory, systems engineering): The conditional-routing principle could lead to new QROM, QRAM-like, and data-movement architectures in which data are routed through shared arithmetic or lookup kernels rather than duplicating controlled computation. Dependencies: Routing savings may be offset by swap networks, connectivity constraints, coherence time, and the physical difficulty of implementing quantum memory. The paper does not demonstrate a scalable hardware implementation of this idea.
- Adaptive, distribution-aware quantum circuits (quantum control and applications): Develop circuits that dynamically balance computation, storage, and tolerated failure based on empirically characterized input distributions. The divstep cutoff illustrates a broader design space in which more Toffolis can reduce qubits, while a larger failure budget can reduce both. Dependencies: Adaptive behavior must preserve coherence and avoid leaking branch information. Distribution estimates must remain valid during deployment, and failure events may need detection, mitigation, or restart mechanisms.
- LLM-generated formal proofs and certified circuit synthesis (formal verification): Combine LLM proposals with proof assistants, symbolic invariant discovery, exhaustive small-instance checks, and certificate-producing synthesis. The divstep example indicates that LLMs can help identify invariants, but certified workflows could turn these insights into machine-checkable correctness guarantees. Dependencies: A trusted proof kernel and complete specification are essential. Empirical testing alone cannot establish correctness for all input sizes, phase behavior, ancilla states, or measurement records.
- General-purpose scientific algorithm discovery beyond quantum computing (academia and research software): The evaluator-guided pattern can be transferred to domains where candidates are easy to score: numerical kernels, combinatorial algorithms, compiler transformations, coding theory, and hardware scheduling. The central requirement is an automated evaluator that measures both correctness and practical cost. Dependencies: Search quality depends heavily on the expressiveness of the programming interface, diversity of initial algorithm families, evaluator reliability, and the ability to avoid reward hacking or overfitting to benchmark instances.
- Fault-tolerant cryptographic and algebraic primitives (cryptography): Further develop the modular-inversion architecture for larger prime fields and integrate it with reversible multiplication, modular reduction, elliptic-curve arithmetic, and quantum cryptanalysis workflows. Similar invariant-based history recovery may reduce the overhead of other algebraic primitives. Dependencies: Security-sensitive applications require worst-case correctness, rigorous side-channel and fault analyses, and parameter-specific proofs. The paper’s bounded-error assumptions may not be acceptable for cryptographic computation without additional safeguards.
- Quantum processors optimized for algorithmically discovered circuits (quantum hardware): Future processors could be designed around recurring structures found by automated search, such as efficient controlled swaps, measurement-based uncomputation, specialized arithmetic blocks, and low-cost routing. This would create a feedback loop between algorithm discovery and hardware architecture. Dependencies: Such specialization risks reducing hardware flexibility. It is worthwhile only if discovered circuit patterns remain stable across workloads and provide benefits after physical noise, calibration, routing, and manufacturing constraints are included.
Glossary
- Ancilla: An auxiliary qubit used temporarily during a quantum computation. “A circuit may use ancilla qubits, but must return them to zero”
- Berlekamp–Massey algorithm: An algorithm that finds the shortest linear recurrence generating a sequence, used here for decoding error-correcting codes. “Our search framework discovered a circuit that replaces their synchronized Euclidean solve with the Berlekamp--Massey (BM) recurrence.”
- Basis-state trajectory: The evolution of a particular computational-basis input under a fixed sequence of measurement outcomes. “For a fixed computational-basis input and a particular sequence of measurement outcomes , we call the resulting evolution a computational-basis trajectory.”
- Bounded error: A computational model in which failure is permitted for a limited fraction or probability of inputs. “At the same time, when bounded error is permitted, machinery needed only for rare or atypical inputs can sometimes be omitted”
- Bucket-brigade QRAM: A quantum random-access memory architecture that routes data through a tree of controlled switches. “The idea resembles bucket-brigade quantum random-access memory (QRAM)”
- Canonicalization: Transforming different representations into a common standard form so that the same computation can process them. “More generally, conditional routing requires canonicalizing branch-dependent states into a representation on which the same expensive computation applies.”
- Computational-basis state: A quantum state corresponding to a definite classical bit string rather than a superposition. “By linearity, this coherent action is correct if the circuit performs the required map on every computational-basis input”
- Conditional routing: Replacing multiple controlled computations with data movement that directs values through one shared computation. “One recurring principle in the circuits discovered by the search is to replace conditional arithmetic with conditional routing.”
- Convolution: An operation combining two sequences by summing products of corresponding shifted elements. “BM solves for the lowest-degree nonzero polynomial whose convolution (see \cref{fig:rs-shared-update}(d)) with the syndrome sequence vanishes”
- Decoded quantum interferometry (DQI): A quantum algorithm that uses error-correcting-code decoding and quantum interference to address optimization problems. “Decoded quantum interferometry (DQI) is a quantum algorithm that turns certain optimization problems into decoding problems for classical error-correcting codes”
- Destructive -basis measurement: A measurement in the basis that consumes or releases the measured qubit. “MBU, introduced by \citet{gidney2018halving}, replaces the second Toffoli with a destructive -basis measurement and a cheap phase correction.”
- Divstep: A division-free step in an extended Euclidean algorithm using conditional additions, subtractions, and halving. “Divsteps is a variant of the Euclidean algorithm that replaces division with conditional additions, subtractions, and halving”
- Extended Euclidean algorithm: An algorithm that computes greatest common divisors while also finding coefficients expressing the divisor as a combination of the inputs. “A standard way to compute the inverse is through the extended Euclidean algorithm.”
- Failure budget: The permitted probability or fraction of inputs on which a circuit may fail. “We separately allow some circuits to fail on a bounded fraction of inputs drawn from a stated distribution; this fraction is the failure budget.”
- Fault-tolerant computation: Quantum computation designed to operate reliably despite physical errors through error correction and error-resistant logical operations. “These observations suggest that evaluator-guided LLM search can go beyond refining a fixed circuit to uncover new reversible algorithms and representations.”
- Finite field: A set with finitely many elements supporting addition, subtraction, multiplication, and division by nonzero elements. “A central application is optimal polynomial intersection (OPI), a form of polynomial fitting over finite fields”
- Global invariant: A property that remains true throughout an algorithm and can link current state information to earlier computation. “This recovery relies on a global invariant ensuring that earlier branch history cannot contaminate the deciding bit.”
- History stack: Storage that records intermediate values or branch decisions so that a reversible computation can later be undone. “A na\"ive reversible implementation stores these displaced values so that the update can later be undone.”
- Kickback: The transfer of a phase effect onto retained quantum data when an auxiliary qubit is measured or manipulated. “The operations apply phase kickback while mixing basis states, giving \kickmix{} its name.”
- Locator polynomial: A polynomial whose roots identify the positions of errors in a Reed–Solomon codeword. “The error positions are encoded in a locator polynomial , whose roots identify those positions.”
- Measurement-based uncomputation (MBU): A method that clears temporary quantum data through measurement and phase correction instead of applying an inverse computation. “This allows candidate circuits to be tested for their action on coherent quantum superpositions, providing the reliable correctness signal needed for evolutionary search.”
- Modular inversion: Finding the multiplicative inverse of a number within modular arithmetic. “Modular inversion is the task of finding such that , given a nonzero input and a prime .”
- Non-Clifford resource: A quantum-computing resource associated with gates outside the efficiently classically simulable Clifford group. “Toffoli gates require expensive non-Clifford resources”
- Prime field: A finite field whose number of elements is prime. “In the eighth, the search discovers a new reversible architecture for prime-field modular inversion.”
- Quantum random-access memory (QRAM): A memory system that allows quantum-controlled access to classically specified data. “quantum read-only memory (QROM), which coherently loads classically specified data into quantum registers”
- Quantum read-only memory (QROM): A quantum circuit or memory structure that loads classical data coherently into quantum registers. “quantum read-only memory (QROM), which coherently loads classically specified data into quantum registers”
- Reed–Solomon code: An error-correcting code based on evaluations of polynomials over finite fields. “DQI requires this decoding to run coherently on a superposition of inputs, making the reversible decoder a dominant resource cost.”
- Reversibility: The requirement that a computation preserve enough information to reconstruct its input and therefore be implemented by a reversible transformation. “Second, the computation must be reversible: intermediate information cannot simply be overwritten or discarded.”
- Syndrome: An algebraic error-detection value derived from a received codeword. “The decoder identifies the positions and values of errors from a collection of algebraic checks called syndromes.”
- Toffoli count: The number of Toffoli gates used by a quantum circuit, serving as a measure of computational cost. “Resource accounting is also simple: we use the Toffoli count and the peak qubit count ”
- Uncomputation: Reversing temporary calculations to restore ancillary qubits and remove intermediate information. “During uncomputation, the circuit can simply read this bit to recover .”
- Superposition: A quantum state that simultaneously represents a linear combination of multiple basis states. “because the input may be in superposition, the circuit cannot inspect an intermediate value and select an ordinary classical control-flow path.”
- -cost: A circuit-cost metric obtained by multiplying Toffoli count by peak qubit count. “Together, these properties let us build an efficient, programmatic evaluator that checks the correctness and resource cost of any candidate circuit design.”
- Trajectory: The state evolution associated with one input and one sequence of measurement outcomes. “Every measurement record therefore induces the same basis permutation”
- Truth table: A tabular representation of a Boolean function’s outputs for every possible input combination. “we treat the decoding rule as a truth table mapping $2j$ input bits to a single bit ”
- Uncompute: To reverse a temporary calculation and restore its workspace to its initial state. “Temporary values must eventually be uncomputed, returning their qubits to their initial state”
- Unitary: A reversible quantum operation that preserves inner products and total probability. “Every ancilla must return to because quantum operations must be unitary, and thus reversible.”





