GitHub - algorithmicsuperintelligence/openevolve: Open-source implementation of AlphaEvolve
Service

GitHub - algorithmicsuperintelligence/openevolve: Open-source implementation of AlphaEvolve

codelion
2025.06.01
·GitHub·by Anonymous
#LLM#Evolutionary Algorithms#Code Optimization#AI#Agent

Key Points

  • 1OpenEvolve is an open-source framework leveraging Large Language Models (LLMs) and evolutionary algorithms to autonomously discover and optimize code, turning LLMs into self-improving code agents.
  • 2It employs a sophisticated MAP-Elites quality-diversity approach with an island-based architecture, advanced LLM ensembles, and artifact-driven feedback to ensure diverse and high-performing algorithmic exploration.
  • 3The system has demonstrated breakthrough results, including 2-3x GPU kernel speedups, state-of-the-art circle packing, and significant convergence improvements in function minimization, all while providing full reproducibility.

OpenEvolve is an advanced open-source evolutionary coding agent designed to transform Large Language Models (LLMs) into autonomous code optimizers and algorithm discoverers. Its primary goal is to enable the discovery of breakthrough algorithms and provide significant performance enhancements, often achieving 2-3x speedups on real hardware, such as for GPU kernel optimization, or finding state-of-the-art solutions like for the circle packing problem.

The system addresses limitations of manual optimization by offering unlimited LLM creativity for exploration, full reproducibility through deterministic evolution, and automatic Pareto optimization for multi-objective problems, all while scaling through parallel evolution. It has demonstrated success in diverse domains including hardware-optimized kernel discovery (e.g., MLX Metal Kernels), mathematical problem-solving (state-of-the-art circle packing for n=26), adaptive algorithm design (Rust Adaptive Sort), and scientific computing (automated filter design).

The core methodology of OpenEvolve is centered on a sophisticated evolutionary coding pipeline that integrates MAP-Elites (Multi-dimensional Archive of Phenotypic Elites) with LLMs.

  1. Quality-Diversity Evolution (MAP-Elites): This fundamental component maintains diverse populations of programs across various "feature dimensions," preventing premature convergence to local optima and encouraging the exploration of a wide range of solutions. Programs are binned into a grid based on user-defined feature dimensions (e.g., "complexity," "diversity," "performance," "memory_usage"). The system supports custom feature dimensions, allowing evaluators to return raw values which OpenEvolve then bins into specified levels (e.g., 10 complexity levels, 20 performance buckets). This ensures that not just the "best" solution, but a collection of high-performing, diverse solutions are retained and evolved.
  2. LLM Integration as Mutator: LLMs act as the primary mutation operators within the evolutionary process. They receive current code (potentially including elite programs from the MAP-Elites archive), system messages, and feedback artifacts, then generate new code variations. OpenEvolve offers a universal API compatible with OpenAI, Google, and local models (Ollama, vLLM) and can integrate with advanced proxy systems like OptiLLM for test-time compute and intelligent routing.
  3. Island-Based Architecture: To further combat premature convergence and enhance exploration, OpenEvolve employs an island-based architecture. Multiple independent populations (islands) evolve in parallel, with controlled migration patterns (e.g., ring topology) allowing for the exchange of genetic material (programs) between islands. This fosters diversity and allows different evolutionary paths to be explored simultaneously.
  4. LLM Ensemble: The system can utilize an ensemble of LLMs with weighted combinations and sophisticated fallback strategies. This allows for leveraging different models' strengths and ensures robustness in code generation.
  5. Artifact Side-Channel: A critical feedback loop is established through the "artifact side-channel." The program evaluator can return not only performance metrics but also arbitrary artifacts such as stderr messages, profiling data, LLM-generated feedback on code quality, or build warnings. This rich feedback is then automatically included in the prompt for subsequent LLM generations (e.g., "Previous Execution Feedback: Warning: suboptimal memory access pattern"), allowing the LLMs to learn from execution failures, warnings, and performance insights, and adapt their generation strategy. This creates a powerful, iterative learning process.
  6. Evolution Algorithm Innovations:
    • Double Selection: Different programs are selected for performance (elites for current best) versus inspiration (diverse programs to guide future exploration).
    • Adaptive Feature Dimensions: Allows the system to dynamically adjust how programs are characterized in the quality-diversity grid.
    • Multi-Strategy Sampling: Incorporates elite, diverse, and exploratory selection methods to maintain balance between exploitation and exploration.

Scientific Reproducibility is a core design principle, achieved through comprehensive seeding of all components (LLM, database, evaluation) with a default seed of 42, ensuring exact reproduction of runs across machines. Hash-based isolation prevents cross-contamination between components.

LLM System Messages are crucial for guiding the evolution. They provide domain expertise, define constraints, specify optimization focus, and help prevent errors. Their creation is an iterative process: initial draft, refinement with specific guidance and domain terminology, specialization with detailed examples and error avoidance patterns, and final optimization. OpenEvolve supports custom prompt templates with "template stochasticity," allowing for randomized prompt variations using placeholders (e.g., {greeting}) to diversify LLM inputs and encourage broader exploration.

OpenEvolve provides comprehensive configuration options, including max_iterations, random_seed, LLM ensemble settings, MAP-Elites parameters (population_size, num_islands, migration_interval, feature_dimensions), and evaluator settings (enable_artifacts, cascade_evaluation, use_llm_feedback).

The system can be used as a Python library or via command-line scripts, with Docker support for containerized runs. Visualization tools are provided for real-time tracking of evolution, including evolution trees, performance graphs, code diff viewers, and MAP-Elites grid visualizations.

Cost estimation depends on LLM providers and iterations, with tips for cost-saving (e.g., fewer iterations, cheaper models, cascade evaluation, smaller population sizes).

OpenEvolve is a powerful framework for automated code and algorithm discovery, pushing the boundaries of what LLMs can achieve in software optimization and scientific discovery.