SwarmEvolve: Latent Agent Swarms for Evolutionary Discovery and Optimization
Abstract: LLM-guided evolutionary search uses AI agents to improve programs for mathematical and computational problems by iteratively refining solutions and combining high-scoring methods. However, the process is often slow because the LLM generates a long textual chain of thought for each round and must repeat this generation many times to maintain population diversity. We present SwarmEvolve, a framework in which hundreds of low-cost agents per round work in swarms, reason in latent space without decoding to text, and share information by passing KV caches. Each swarm studies the problem from a different angle. A novelty filter keeps the most distinct agent ideas by directly measuring the distances between the agents' hidden state vectors. Crossover of ideas happens naturally in latent space, as a summarizer agent receives the combined KV caches of all swarm members. On 21 problems in mathematical discovery and scientific computing, SwarmEvolve gets the highest average score and needs a median of only 3 to 8 minutes to reach the best scores that other state-of-the-art frameworks reach in 60 minutes. On several problems, SwarmEvolve with Qwen3 8B improves on the solutions that AlphaEvolve first found with frontier LLMs. Our work shows that agent swarms that communicate in latent space offer a fast, low-cost approach to program search for scientific problems.
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is the paper about?
The paper introduces SwarmEvolve, a way to use artificial intelligence to discover better computer programs for difficult mathematics and science problems.
The main idea is to create a large “swarm” of small AI agents. Each agent tries to improve a program in a slightly different way. The agents then share their ideas and combine them into new programs.
Unlike most AI systems, which explain their thoughts using written words, SwarmEvolve lets the agents “think” using internal numerical representations. This makes the process much faster and cheaper.
2. What questions does the research ask?
The main research question is:
Can many inexpensive AI agents working together make program discovery faster and better?
The authors especially wanted to find out:
- Can hundreds of AI agents explore more possible solutions than a small number of agents?
- Can agents share ideas without writing long messages?
- Can this method discover better programs in less time?
- Can a small, open-source AI model compete with much larger and more expensive AI systems?
The programs being searched for include mathematical constructions, algorithms, and scientific computing methods, such as programs for solving equations.
3. How does SwarmEvolve work?
Evolutionary search
SwarmEvolve uses a method called evolutionary search. This is similar to natural selection:
- Start with one or more basic programs.
- Create changed versions of those programs.
- Test how well each version works.
- Keep the best versions.
- Continue improving them over many rounds.
It is like breeding racing cars: build many different cars, test their speed, keep the fastest ones, and use their useful features to design the next generation.
AI agents in swarms
In each round, SwarmEvolve creates 10 swarms, with 45 agents in each swarm. This gives a total of 450 agents.
Different swarms have different jobs. For example:
- Some try to improve the best program.
- Some combine ideas from several good programs.
- Some explore unusual or less-tested approaches.
- One swarm starts from a basic program and tries to find a completely different solution.
This is like asking different teams of students to solve the same puzzle, with each team using a different strategy.
Latent reasoning
Usually, an AI reasons by writing text, such as:
“First, I will try this method. It might work because…”
SwarmEvolve uses latent reasoning instead. The AI works with hidden numerical patterns inside the model rather than turning every thought into words.
These hidden patterns are called hidden states. They can be thought of as the AI’s internal notes. The agents do not need to write out every thought, which saves time.
An analogy would be the difference between:
- Writing a long explanation of every idea, or
- Thinking quickly using private mental images and then sharing only the final useful answer.
Sharing information through KV caches
The agents communicate using something called a KV cache. This is a stored collection of the information an AI has already processed.
Instead of sending written messages to one another, the agents pass their internal information to a summarizer agent. The summarizer reads the combined information and writes a new program.
This is similar to several students solving different parts of a problem and giving their rough notes to one student, who combines the ideas into one final answer.
Choosing different ideas
Some agents may think in almost exactly the same way. Keeping all of them would waste time.
SwarmEvolve compares the agents’ hidden states and removes the most similar ones. It keeps the agents with the most different ideas. This is called a novelty filter.
The purpose is to make sure the swarm contains a variety of approaches rather than many copies of the same idea.
Testing the programs
After a new program is created, the system:
- Checks whether the program is written correctly.
- Runs it on the problem.
- Gives it a score.
- Stores the program and its score in an archive.
The best programs are then used in later rounds.
4. What experiments were performed?
The researchers tested SwarmEvolve on 21 problems from mathematics and scientific computing.
These included problems involving:
- Packing circles and shapes efficiently.
- Geometry.
- Number patterns and combinatorics.
- Statistical analysis.
- Sparse systems of equations.
- Eigenvalues.
- Differential equations used in science and engineering.
They compared SwarmEvolve with three other AI-based evolutionary systems:
- OpenEvolve
- ShinkaEvolve
- CodeEvolve
They used three versions of the Qwen3 LLM and gave each method 60 minutes on one GPU.
5. What did the researchers find?
SwarmEvolve found better solutions
SwarmEvolve achieved the highest average score with all three AI model sizes.
It often produced the best result on individual problems as well. In some scientific computing tests, the largest version of SwarmEvolve solved problems with full accuracy, while the comparison systems did not.
It was much faster
SwarmEvolve tested 5 to 13 times more programs per hour than the other systems.
The comparison systems spent much of their time writing long chains of thought. SwarmEvolve avoided this costly step by using latent reasoning.
The researchers found that SwarmEvolve often reached, in only 3 to 8 minutes, the score that other systems reached after a full 60 minutes.
A smaller model could beat larger systems
SwarmEvolve using the smaller Qwen3 8B model had a higher average score than the comparison systems using the much larger Qwen3 32B model.
This is important because smaller models require less computing power and are cheaper to run.
It improved some results from AlphaEvolve
On three problems, SwarmEvolve using Qwen3 8B found solutions better than solutions originally discovered by AlphaEvolve using much more powerful “frontier” AI models.
For example, it found an improved arrangement for packing circles into a square and improved some mathematical bounds involving sequences.
Diversity helped the search
The experiments showed that different swarms occupied different regions of the AI’s hidden space. This suggests that the swarms were genuinely exploring different kinds of ideas.
The novelty filter also kept agents with different ways of thinking. This helped the system avoid repeatedly trying nearly identical solutions.
Latent reasoning worked better than text reasoning
The researchers replaced latent reasoning with ordinary written reasoning and compared the results.
The latent version:
- Tested more programs.
- Took less time.
- Achieved the best average score.
When the AI had to write longer explanations, the process became slower and sometimes overloaded the amount of information the summarizer had to read.
6. Why are these findings important?
Finding good programs for mathematics and science can require trying thousands or millions of possibilities. If each attempt takes a long time, the search becomes too expensive.
SwarmEvolve makes this search more efficient by:
- Running hundreds of agents at once.
- Allowing agents to explore different possibilities.
- Sharing internal information without long written messages.
- Testing many more programs in the same amount of time.
- Using smaller and cheaper AI models.
This could help researchers design faster algorithms, better computer simulations, and improved methods for solving scientific equations.
7. What are the limitations?
The paper also explains several weaknesses:
- All agents must currently use the same AI model, because their internal information is difficult to combine if it comes from different models.
- The method needs a large amount of computer memory to store the agents’ internal information.
- The system works best with certain types of AI models and may not work directly with every model design.
- The method still depends on having a reliable way to test and score programs. If there is no clear test, it is difficult to know which program is better.
- The agents can share information quickly, but they may still share the same blind spots because they are all based on one LLM.
Conclusion
SwarmEvolve shows that AI agents do not always need to communicate by writing long explanations. They can share internal numerical information and work together as a large swarm.
The paper’s main message is that many fast, diverse, inexpensive AI agents can sometimes discover better scientific and mathematical programs than fewer, larger, more expensive systems.
If the method continues to improve, it could make computer-assisted scientific discovery more affordable. Researchers might use it to find new algorithms, improve simulations, discover mathematical patterns, and solve difficult engineering problems using only modest computing equipment.
Practical Applications
Immediate Applications
- Scientific-computing optimization pipelines — scientific software, engineering, and research laboratories. Organizations can use SwarmEvolve now to generate and test improved programs for sparse linear systems, eigenvalue computation, PDE solvers, symbolic regression, numerical integration, and optimization. A practical workflow is to provide a baseline implementation, a deterministic evaluator, and a measurable objective such as accuracy, runtime, memory use, or convergence rate. The system can then return the highest-scoring candidate together with evaluation logs and error messages. Assumptions and dependencies: The problem must be expressible as executable code with an automated, reliable evaluator. Results require independent validation because evolutionary search may exploit weaknesses in the benchmark or overfit the test cases.
- Algorithm engineering and performance tuning — software infrastructure and high-performance computing. Development teams can use latent-agent swarms to optimize sorting routines, matrix multiplication, graph algorithms, schedulers, compiler passes, data structures, and parallel kernels. Refinement swarms can modify a strong implementation, while hybridization swarms can combine techniques from several high-performing candidates. The parameter-tuning agent can automatically explore numerical constants, thresholds, block sizes, and solver tolerances. Assumptions and dependencies: Candidate programs must run in a sandbox and be evaluated across representative workloads. Hardware-specific optimizations may require access to the target CPU, GPU, compiler, and runtime environment.
- Rapid exploration of mathematical constructions — mathematics and theoretical computer science. Researchers can encode construction problems such as packing, geometric arrangements, combinatorial designs, bounds, and discrete optimization tasks into objective-driven search environments. SwarmEvolve can explore multiple proof-inspired or construction-inspired directions in parallel, potentially identifying candidates that merit formal mathematical analysis. The reported improvements over AlphaEvolve-style constructions suggest that relatively small open-weight models may be useful for inexpensive exploratory searches. Assumptions and dependencies: A numerical score is not equivalent to a proof. Candidate constructions require exact verification, formal proof, or exhaustive checking before publication.
- Research-assistant tooling for program discovery — academia and industrial R&D. A deployable tool could accept a research question, baseline code, evaluator, and resource budget, then produce an archive of candidate programs, scores, failure logs, and mutations. This would support researchers who need to explore many implementation hypotheses without manually writing every variant. The archive could also make the search process reproducible by recording parent programs, prompts, seeds, hardware, and evaluation results. Assumptions and dependencies: The current method is best suited to well-specified computational tasks rather than open-ended research questions. Human researchers remain necessary to interpret, validate, and explain the generated solutions.
- Low-cost on-premises AI search — universities, startups, and smaller laboratories. Because the experiments report strong performance using Qwen3 8B on a single GPU, institutions without access to frontier-model APIs can run comparable exploratory workflows using open-weight models. This can reduce dependence on external inference services and lower the cost of repeated program-search experiments. Assumptions and dependencies: The reported hardware and model performance may not transfer directly to all GPUs, models, or problem domains. KV-cache memory is a significant constraint, especially with many agents, long latent trajectories, or larger models.
- Automated regression and benchmark improvement — software quality assurance. The framework can be integrated into continuous benchmarking systems that search for faster or more accurate implementations while retaining existing tests as hard correctness constraints. For example, a nightly workflow could evolve numerical kernels or database query strategies and submit only candidates that improve performance without reducing test coverage. Assumptions and dependencies: Evaluators must include correctness tests, adversarial cases, and resource limits. Otherwise, the optimizer may produce brittle solutions that perform well only on the benchmark.
- Evaluation of diverse solution strategies — education and research training. In advanced programming, numerical methods, or optimization courses, instructors could use the system to generate multiple implementations of the same task and compare their accuracy, complexity, and design choices. Students could inspect the evolutionary archive to study how candidate solutions improve over time. Assumptions and dependencies: Generated programs need human review and clear attribution policies. The system should supplement, rather than replace, instruction in algorithmic reasoning and mathematical justification.
- Personal and small-team optimization tools — daily technical work. Developers could use a local application to optimize repetitive scripts, data-processing pipelines, spreadsheet formulas translated into code, or small simulation programs. A user would provide a baseline script and a measurable goal, such as lower execution time or reduced memory consumption. Assumptions and dependencies: This is practical only for tasks with safe test data and deterministic or statistically stable evaluation. Sensitive source code and data should remain within an appropriately secured environment.
Long-Term Applications
- Automated discovery of scientific models and numerical methods — physics, climate science, biology, and engineering. At larger scale, SwarmEvolve could search for discretization schemes, constitutive equations, surrogate models, control laws, and simulation algorithms. Different swarms could specialize in physical constraints, numerical stability, computational cost, or agreement with experimental data. This could produce tools for computational fluid dynamics, materials modeling, structural analysis, and biological simulation. Assumptions and dependencies: Scientific validity requires incorporating conservation laws, dimensional consistency, uncertainty quantification, and out-of-distribution testing. More research is needed to prevent solutions that optimize numerical benchmarks while violating domain principles.
- Healthcare and biomedical algorithm design — medical imaging, diagnostics, and drug discovery. Future systems could evolve image-processing pipelines, segmentation algorithms, physiological simulators, treatment-scheduling rules, or molecular-scoring programs. Swarms could explore accuracy–latency–fairness trade-offs while evaluators assess performance on multiple patient cohorts. Assumptions and dependencies: Clinical deployment would require privacy protection, representative datasets, prospective validation, regulatory approval, and strong safeguards against demographic bias. The current paper does not demonstrate medical reliability or clinical usefulness.
- Robotics and autonomous systems — motion planning, control, and coordination. SwarmEvolve could search for robot controllers, trajectory planners, sensor-fusion code, multi-robot coordination policies, and energy-efficient behaviors. Latent swarms could specialize in robustness, speed, safety margins, or adaptation to different environments, while simulations and hardware tests serve as evaluators. Assumptions and dependencies: Simulation-to-real transfer, safety verification, real-time constraints, and hardware-specific evaluation are major dependencies. Generated control programs would require formal safety checks and extensive physical testing before deployment.
- Energy-system optimization — grids, batteries, and industrial energy management. The framework could evolve dispatch algorithms, battery charging policies, demand-response strategies, power-flow solvers, and renewable-energy forecasting pipelines. A multi-objective evaluator could score candidates on cost, reliability, emissions, and resilience. Assumptions and dependencies: Real deployment depends on high-fidelity grid models, secure operational data, regulatory constraints, and guarantees against unstable or adversarial behavior. Multi-objective optimization and hard safety constraints would need to be integrated into the framework.
- Finance and operations research — portfolio construction, trading infrastructure, and logistics. Future applications could search for execution algorithms, risk models, inventory policies, routing heuristics, and scheduling programs. Evolutionary search is particularly suitable where candidate strategies can be back-tested or evaluated in simulation. Assumptions and dependencies: Historical back-tests are vulnerable to overfitting, leakage, and distribution shift. Deployment would require walk-forward validation, transaction-cost modeling, compliance review, and strict risk controls; a high benchmark score alone would not justify financial use.
- Compiler and systems co-design — computer architecture and cloud infrastructure. Larger swarms could jointly optimize compiler transformations, GPU kernels, memory layouts, query planners, network protocols, and hardware-aware numerical libraries. A future product could connect the framework to profilers and automated benchmarking systems to evolve code for specific hardware configurations. Assumptions and dependencies: This requires robust compilation, hardware-in-the-loop testing, and multi-objective evaluation of speed, energy, memory, portability, and correctness. Search costs may become substantial when each candidate requires long compilation or hardware execution.
- Formal-methods and theorem-proving assistance — mathematics and software verification. Swarm-generated constructions could be paired with proof assistants, SAT/SMT solvers, and symbolic algebra systems. One swarm might propose a conjecture or algorithm, while another generates lemmas, invariants, or formally checkable proof scripts. This would convert the current numerical-discovery workflow into a hybrid discovery-and-verification system. Assumptions and dependencies: Latent diversity does not guarantee logically valid reasoning. Formal verification, proof checking, and specialized representations are required, and these capabilities are not evaluated in the paper.
- Cross-model and heterogeneous agent ecosystems — scalable AI research platforms. The current implementation requires agents and summarizers to share one model because they exchange KV caches directly. In the longer term, learned translations between KV caches or other latent representations could allow specialized agents based on different models to collaborate—for example, a mathematical model, a code model, and a domain-specific scientific model. Assumptions and dependencies: Reliable cache translation, alignment across model architectures, preservation of meaning, and protection against incompatible latent representations are unresolved technical issues.
- Distributed and large-scale discovery services — cloud computing and national research infrastructure. Multi-GPU and multi-node implementations could distribute swarms, archive management, evaluators, and long-running evolutionary searches. Compressed latent messages, cache sharing, and asynchronous evaluation could support searches involving expensive simulations or large scientific datasets. Assumptions and dependencies: The paper identifies KV-cache memory growth as a major limitation. Practical scaling will require cache compression, scheduling strategies, fault tolerance, communication-efficient aggregation, and careful control of duplicate or correlated searches.
- Human–AI collaborative discovery platforms — research management and policy. A mature product could present researchers with a ranked set of candidate algorithms, visualizations of search diversity, evaluator traces, and explanations generated after discovery. Policymakers and funding agencies could use such platforms to support reproducible, low-cost computational experimentation across institutions. Assumptions and dependencies: The latent reasoning itself is not directly interpretable, so accountability cannot rely on the internal swarm traces alone. Provenance, reproducibility, independent replication, licensing, and disclosure of generated versus human-authored contributions would be necessary for trustworthy adoption.
Glossary
- Activation: The numerical output produced by a neural-network layer or unit during computation. “LLMs exchange token embeddings, activations, hidden states, or KV caches instead of text messages.”
- Alignment matrix: A matrix that maps vectors from one representation space into another. “First, an alignment matrix $\mathbf{W}_{\mathrm{a}$ maps into the input embedding space.”
- Argmax: The operation that returns the input value or index maximizing an objective function. “”
- Autocorrelation: The correlation of a signal or sequence with a shifted version of itself. “its step functions improve AlphaEvolve's bounds for the second and third autocorrelation inequalities.”
- Bootstrap interval: An uncertainty interval estimated by repeatedly resampling observed data. “with 95\% bootstrap intervals.”
- Crossover: An evolutionary operation that combines characteristics from multiple candidate solutions. “This search can be carried out through evolutionary computation, a method to iteratively improve candidate programs through variation, crossover, and selection”
- Cosine distance: A distance measure based on the angle between two vectors, commonly defined as one minus cosine similarity. “Greedy farthest-point selection~\citep{gonzalez1985clustering} in cosine distance then adds one agent at a time”
- Cosine similarity: A measure of similarity between vectors based on the cosine of the angle separating them. “when its cosine similarity to an archived program exceeds 0.99”
- Decoder-only transformer: A transformer LLM architecture that generates outputs using only a decoder stack. “We use decoder-only transformer LLMs~\citep{vaswani2017attention}”
- Differential equation: An equation involving an unknown function and one or more of its derivatives. “building robust solvers for differential equations.”
- Embedding: A learned numerical vector representation of a token, word, or other object. “The LLM instead feeds the last hidden state back as the next input embedding ”
- Eigenvalue: A scalar associated with a matrix that describes how a corresponding eigenvector is scaled by that matrix. “We also design five scientific computing problems on sparse linear systems, eigenvalues of non-normal matrices”
- Evolutionary computation: A family of optimization methods inspired by biological evolution, using variation and selection over candidate solutions. “This search can be carried out through evolutionary computation”
- Farthest-point selection: A greedy procedure that iteratively selects the point farthest from the already selected set. “Greedy farthest-point selection~\citep{gonzalez1985clustering} in cosine distance then adds one agent at a time”
- FP8: An 8-bit floating-point numerical format used to reduce memory and computation requirements. “Qwen3 32B-FP8”
- Frontier LLM: A leading, highly capable LLM, typically at the current state of the art. “While AlphaEvolve relies on frontier LLMs”
- Greedy algorithm: An algorithm that makes the locally best available choice at each step. “Greedy farthest-point selection~\citep{gonzalez1985clustering}”
- Hidden state: An internal vector representation generated by a neural network for an input position. “The output of the last layer at position is the last hidden state .”
- Hybridization: The combination of components, methods, or ideas from different candidate solutions. “Three hybridization swarms each receive five programs drawn at random from the ten best”
- Inference: The process of using a trained model to produce predictions or outputs. “for fast inference.”
- Latent communication: Communication between agents through internal vector representations rather than decoded text. “We present SwarmEvolve, an evolutionary search framework in which swarms of low-cost latent agents reason in latent space and communicate by passing KV caches.”
- Latent reasoning: Reasoning performed in a model’s continuous internal representation space without generating intermediate text tokens. “In latent reasoning, the LLM instead feeds the last hidden state back as the next input embedding ”
- KV cache: Stored attention keys and values that allow an autoregressive transformer to reuse prior computation. “The LLM stores them in a KV cache ”
- Linear attention: An attention mechanism designed to reduce the computational cost of standard attention, often by restructuring the attention calculation. “Linear-attention, state-space, and hybrid models compress the past into a fixed-size state”
- MAP-Elites: An evolutionary algorithm that maintains an archive of high-performing solutions across different regions of a behavior or feature space. “AlphaEvolve and its open-source variants add a MAP-Elites archive to keep diverse programs”
- Non-normal matrix: A matrix that does not commute with its conjugate transpose, potentially exhibiting unusual spectral and numerical behavior. “eigenvalues of non-normal matrices”
- Novelty filter: A mechanism that retains candidate solutions considered sufficiently different from one another. “A novelty filter then keeps the agents in each swarm whose latent reasoning trajectories are farthest apart in cosine distance.”
- Paged attention: An attention implementation that manages key-value memory in blocks or pages to improve memory efficiency. “Agents that read the same program attend to one shared copy of its KV cache through paged attention”
- Principal component: An orthogonal direction obtained through principal component analysis that captures successively decreasing amounts of variance in data. “It projects the centered and normalized mean hidden states of the latent agents onto their first two principal components.”
- Ridge regression: A regularized form of linear regression that penalizes large parameter values to improve stability or prevent overfitting. “The matrix $\mathbf{W}_{\mathrm{a}$ is the ridge regression solution, with regularization weight ”
- Rotary position embedding (RoPE): A positional encoding method that applies position-dependent rotations to query and key vectors. “The Qwen3 models that we use encode positions with rotary position embeddings (RoPE)”
- Sparse linear system: A system of linear equations whose matrix contains mostly zero entries. “We also design five scientific computing problems on sparse linear systems”
- State-space model: A sequence-modeling architecture that represents prior inputs using a compact evolving internal state. “Linear-attention, state-space, and hybrid models compress the past into a fixed-size state”
- Symbolic regression: The search for mathematical expressions that fit observed data or satisfy a specified objective. “Examples include symbolic regression”
- Throughput: The amount of work completed per unit of time. “SwarmEvolve evaluates 5 to 13 times more programs per hour than existing SOTA frameworks”
- Top- sampling: A language-generation method that restricts the next-token distribution to its most probable tokens. “\color{brown}Top-”
- Top- sampling: A language-generation method that samples from the smallest set of tokens whose cumulative probability reaches a specified threshold. “\color{brown}Top-”
- Transformer: A neural-network architecture based primarily on attention mechanisms for processing sequences. “We use decoder-only transformer LLMs~\citep{vaswani2017attention}”
- Variational operator: An operator or transformation used to generate a modified candidate solution in an evolutionary search process. “This search can be carried out through evolutionary computation, a method to iteratively improve candidate programs through variation, crossover, and selection”
- Vector embedding space: A continuous numerical space in which entities such as tokens or hidden representations are encoded as vectors. “so it reasons in its continuous embedding space without sampling tokens”











