Open-source implementation of AlphaEvolve
Autonomous DiscoveryLLMs don't just optimize—they discover entirely new algorithms. No human guidance needed. |
Proven Results2-3x speedups on real hardware. State-of-the-art circle packing. Breakthrough optimizations. |
Research GradeFull reproducibility, extensive evaluation pipelines, and scientific rigor built-in. |
OpenEvolve vs Manual Optimization:
| Aspect | Manual Optimization | OpenEvolve |
|---|---|---|
| Time to Solution | Days to weeks | Hours |
| Exploration Breadth | Limited by human creativity | Unlimited LLM creativity |
| Reproducibility | Hard to replicate | Fully deterministic |
| Multi-objective | Complex tradeoffs | Automatic Pareto optimization |
| Scaling | Doesn't scale | Parallel evolution across islands |
Get from zero to evolving code in 30 seconds:
# Install OpenEvolve
pip install openevolve
# The example uses Google Gemini by default (free tier available)
# Get your API key from: https://aistudio.google.com/apikey
export OPENAI_API_KEY="your-gemini-api-key" # Yes, use OPENAI_API_KEY env var
# Run your first evolution!
python openevolve-run.py examples/function_minimization/initial_program.py \
examples/function_minimization/evaluator.py \
--config examples/function_minimization/config.yaml \
--iterations 50Note: The example config uses Gemini by default, but you can use any OpenAI-compatible provider by modifying the config.yaml. See the configs for full configuration options.
OpenEvolve can be used as a library without any external files:
…Prefer Docker? See the Installation & Setup section for Docker options.
Watch OpenEvolve discover optimal circle packing in real-time:
| Generation 1 | Generation 190 | Generation 460 (Final) |
|---|---|---|
| Random placement | Learning structure | State-of-the-art result |
Result: Matches published benchmarks for n=26 circle packing problem.
GPU Kernel EvolutionBefore (Baseline):
// Standard attention implementation
kernel void attention_baseline(/* ... */) {
// Generic matrix multiplication
float sum = 0.0;
for (int i = 0; i < seq_len; i++) {
sum += query[tid] * key[i];
}
}After Evolution (2.8x faster):
// OpenEvolve discovered optimization
kernel void attention_evolved(/* ... */) {
// Hardware-aware tiling + unified memory optimization
threadgroup float shared_mem[256];
// ... evolved algorithm exploiting Apple Silicon architecture
}Performance Impact: 2.8x speedup on Apple M1 Pro, maintaining numerical accuracy.
OpenEvolve implements a sophisticated evolutionary coding pipeline that goes far beyond simple optimization:
| Use Case | Why OpenEvolve Excels |
|---|---|
| Performance Optimization | Discovers hardware-specific optimizations humans miss |
| Algorithm Discovery | Finds novel approaches to classic problems |
| Scientific Computing | Automates tedious manual tuning processes |
| Competitive Programming | Generates multiple solution strategies |
| Multi-Objective Problems | Pareto-optimal solutions across dimensions |
pip install openevolvegit clone https://github.com/algorithmicsuperintelligence/openevolve.git
cd openevolve
pip install -e ".[dev]"# Pull the image
docker pull ghcr.io/algorithmicsuperintelligence/openevolve:latest
# Run an example
docker run --rm -v $(pwd):/app ghcr.io/algorithmicsuperintelligence/openevolve:latest \
examples/function_minimization/initial_program.py \
examples/function_minimization/evaluator.py --iterations 100Cost depends on your LLM provider and iterations:
Cost-saving tips:
OpenEvolve works with any OpenAI-compatible API:
OpenAI (Direct)export OPENAI_API_KEY="sk-..."
# Uses OpenAI endpoints by default# config.yaml
llm:
api_base: "https://generativelanguage.googleapis.com/v1beta/openai/"
model: "gemini-2.5-pro"export OPENAI_API_KEY="your-gemini-api-key"# config.yaml
llm:
api_base: "http://localhost:11434/v1" # Ollama
model: "codellama:7b"For maximum flexibility with rate limiting, model routing, and test-time compute:
# Install OptiLLM
pip install optillm
# Start OptiLLM proxy
optillm --port 8000
# Point OpenEvolve to OptiLLM
export OPENAI_API_KEY="your-actual-key"llm:
api_base: "http://localhost:8000/v1"
model: "moa&readurls-o3" # Test-time compute + web accessUse the Claude Code CLI as the LLM backend — no API keys needed, authentication uses the CLI's OAuth session.
# Install and authenticate
npm install -g @anthropic-ai/claude-code
claude login# config.yaml
llm:
provider: "claude_code"
models:
- name: "sonnet"
weight: 0.8
max_tokens: 16000
max_budget_usd: 1.0
- name: "haiku"
weight: 0.2
max_tokens: 8000See the Claude Code quickstart example for a complete walkthrough.
Watch OpenEvolve evolve from random search to sophisticated optimization:
# Initial Program (Random Search)
def minimize_function(func, bounds, max_evals=1000):
best_x, best_val = None, float('inf')
for _ in range(max_evals):
x = random_point_in_bounds(bounds)
val = func(x)
if val < best_val:
best_x, best_val = x, val
return best_x, best_valEvolution Process
# Evolved Program (Simulated Annealing + Adaptive Cooling)
def minimize_function(func, bounds, max_evals=1000):
x = random_point_in_bounds(bounds)
temp = adaptive_initial_temperature(func, bounds)
for i in range(max_evals):
neighbor = generate_neighbor(x, temp, bounds)
delta = func(neighbor) - func(x)
if delta < 0 or random.random() < exp(-delta/temp):
x = neighbor
temp *= adaptive_cooling_rate(i, max_evals) # Dynamic cooling
return x, func(x)Performance: 100x improvement in convergence speed!
Evolve prompts instead of code for better LLM performance. See the LLM Prompt Optimization example for a complete case study with HotpotQA achieving +23% accuracy improvement.
Competitive ProgrammingAutomatic solution generation for programming contests:
# Problem: Find maximum subarray sum
# OpenEvolve discovers multiple approaches:
# Evolution Path 1: Brute Force → Kadane's Algorithm
# Evolution Path 2: Divide & Conquer → Optimized Kadane's
# Evolution Path 3: Dynamic Programming → Space-Optimized DPOpenEvolve offers extensive configuration for advanced users:
…For Gemini embeddings, set GEMINI_API_KEY. GOOGLE_API_KEY is also supported
as a fallback. OpenEvolve uses Google's OpenAI-compatible endpoint automatically.
Control how programs are organized in the quality-diversity grid:
database:
feature_dimensions:
- "complexity" # Built-in: code length
- "diversity" # Built-in: structural diversity
- "performance" # Custom: from your evaluator
- "memory_usage" # Custom: from your evaluator
feature_bins:
complexity: 10 # 10 complexity levels
performance: 20 # 20 performance buckets
memory_usage: 15 # 15 memory usage categoriesImportant: Return raw values from evaluator, OpenEvolve handles binning automatically.
Custom Prompt TemplatesAdvanced prompt engineering with custom templates:
prompt:
template_dir: "custom_templates/"
use_template_stochasticity: true
template_variations:
greeting:
- "Let's enhance this code:"
- "Time to optimize:"
- "Improving the algorithm:"
improvement_suggestion:
- "Here's how we could improve this code:"
- "I suggest the following impFeature Request: Expose Island Selection / Population Management as a Pluggable Strategy
Novelty judge can never reject: prompt asks for NOT_NOVEL, parser matches "NOT NOVEL"
Using Codex Subscription tokens
Include competition between evolved populations
Bidirectional interop with Google Cloud AlphaEvolve (run AE examples on OE, and export OE programs to the AE service)
evaluator` exec_module operator-supplied code in-process; `visualizer` serves checkpoint data with no auth
[Question/Usage] What is the best way of passing arguments to the evaluate.py function?
How to optimize the whole code repository?
Enhancing `combined_score` to support multi-objective optimization via lexicographical ordering
Add option to checkpoint only when improvement is detected