OpenEvolve: Evolving Code with LLMs
Published on 9/4/2026
OpenEvolve is an open-source implementation of AlphaEvolve (DeepMind) - instead of editing code by hand, an LLM takes on the role of “mutator” in an evolutionary loop, with selection driven by scores from an evaluator.
How the loop works
Four main components:
- Prompt Sampler - builds prompts from prior code + scores + problem description
- LLM Ensemble - multiple models, with fallback if the primary model fails
- Evaluator - runs the generated code and returns a score
- Program Database - stores the population, using the MAP-Elites algorithm
Each round: pick 2 programs (1 to score, 1 to “inspire”) → the LLM generates a new variant → the evaluator scores it → the database is updated. The database is split into multiple islands (separate populations) that occasionally migrate individuals between each other - avoiding premature convergence on a local solution.
Installing and trying it out
pip install openevolve
export OPENAI_API_KEY="your-key"
python openevolve-run.py \
examples/function_minimization/initial_program.py \
examples/function_minimization/evaluator.py \
--iterations 50
Works with OpenAI, Gemini, local models, or any OpenAI-compatible API.
Evaluator cascade
The evaluator doesn’t just return a score - it also returns artifacts: stderr, profiling logs, build warnings, feedback from another LLM. These artifacts are fed directly into the next round’s prompt, forming an error feedback loop:
evaluator:
enable_artifacts: true # đưa lỗi vào prompt vòng sau
cascade_evaluation: true # chấm nhiều giai đoạn, loại sớm code tệ
use_llm_feedback: true # dùng LLM chấm chất lượng code
Notable config options
| Parameter | Meaning |
|---|---|
database.num_islands | number of parallel populations |
database.population_size | number of individuals per island |
database.feature_dimensions | quality-diversity axes used to classify individuals |
prompt.num_top_programs / num_diverse_programs | selects the best / most diverse code to include in the prompt |
random_seed | fixed seed for reproducible results |
Results
- Circle packing problem (n=26): achieved results close to the published benchmark
- GPU attention kernel: 2.8x speedup on Apple M1 Pro
- Overall, reported speedups of 2-3x across a variety of problems
When it’s worth using
Well-suited to problems with a clear, fast, measurable evaluation function (speed, accuracy, cost) - since the entire loop depends on the scores returned by the evaluator. Not suited to cases requiring subjective human judgment or problems where an automated evaluator can’t be written.