Source-linked AI summary

Controlled Self-Evolution for Algorithmic Code Optimization

Tu Hu, Ronghao Chen, Shuo Zhang, Jianghao Yin, Mou Xiao Feng, Jingping Liu, Shaolei Zhang, Wenqi Jiang, Yuqi Fang, Sen Hu, Huacan Wang, Yi Xu

arXiv:2601.07348v5cs.CLcs.AIcs.NE

TL;DR

Existing self-evolution methods struggle to find algorithmically efficient code under limited exploration budgets because of initialization bias, uncontrolled stochastic operations, and weak experience reuse. CSE addresses these bottlenecks with diversified planning, feedback-guided genetic evolution, and hierarchical memory, and experiments on EffiBench-X show consistent gains across LLM backbones with faster early improvement and continued progress.

  • Problem

    Existing self-evolution methods have low exploration efficiency and struggle to discover solutions with superior time and space complexity under limited exploration budgets.

  • Method

    CSE combines diversified planning initialization, feedback-guided genetic evolution with targeted mutation and compositional crossover, and hierarchical memory of intra-task and inter-task experiences.

  • Results

    CSE consistently outperforms baselines across EffiBench-X, languages, and LLM backbones, improving efficiency from early generations and continuing to improve throughout evolution.

  • Takeaways & Limitations

    The results support controlled, feedback-driven exploration as an effective approach for improving code evolution efficiency.

  • Takeaways & Limitations

    CSE does not yet amortize iterative optimization into the base model through distillation of evolution trajectories.

Abstract

from arXiv · show

Self-evolution methods enhance code generation through iterative "generate-verify-refine" cycles, yet existing approaches suffer from low exploration efficiency, failing to discover solutions with superior complexity within limited budgets. This inefficiency stems from initialization bias trapping evolution in poor solution regions, uncontrolled stochastic operations lacking feedback guidance, and insufficient experience utilization across tasks. To address these bottlenecks, we propose Controlled Self-Evolution (CSE), which consists of three key components. Diversified Planning Initialization generates structurally distinct algorithmic strategies for broad solution space coverage. Genetic Evolution replaces stochastic operations with feedback-guided mechanisms, enabling targeted mutation and compositional crossover. Hierarchical Evolution Memory captures both successful and failed experiences at inter-task and intra-task levels. Experiments on EffiBench-X demonstrate that CSE consistently outperforms all baselines across various LLM backbones. Furthermore, CSE achieves higher efficiency from early generations and maintains continuous improvement throughout evolution. Our code is publicly available at https://github.com/QuantaAlpha/EvoControl.

1 Introduction

Existing self-evolution methods must discover functionally correct and algorithmically efficient code under limited exploration budgets, but low exploration efficiency hinders this goal. CSE addresses initialization bias, uncontrolled stochastic evolution, and weak experience reuse with diversified planning, feedback-guided genetic evolution, and hierarchical memory.

  • Motivation: Limited computational resources make it necessary to discover correct, time-efficient, and space-efficient code within a restricted exploration budget.Extensive multi-turn inference can impose prohibitive cost and latency.
  • Motivation: Existing self-evolution methods explore inefficiently because initialization bias, uncontrolled stochastic evolution, and insufficient guidance impede movement toward algorithmically optimal solutions.Initialization from few solutions can trap evolution in poor regions and local optima.
  • Approach: CSE generates structurally distinct strategies, uses feedback-guided mutation and compositional crossover, and reuses intra-task and inter-task evolutionary experiences.These components target broad solution-space coverage, controlled refinement, and reusable optimization patterns.

2 Related Work

Prior code-generation work includes instruction tuning, retrieval augmentation, and specialized programming models, while self-evolution enables iterative refinement from execution feedback. Existing self-evolution approaches primarily emphasize debugging or population search and retain efficiency limitations.

  • Code Generation with LLMs: Large language models have advanced code generation through instruction tuning, retrieval augmentation, and specialized programming models.Examples include WizardCoder, Magicoder, GPT-4o, and DeepSeek-Coder.
  • Self-Evolution: Self-evolution methods address single-turn generation by iterating through generate-verify-refine cycles and learning from execution feedback.The related-work discussion distinguishes these methods from direct single-turn generation.
  • Self-Evolution: Self-reflection methods focus mainly on debugging, while local-refinement and population-based approaches face initialization bias, local optima, or related search limitations.The passage specifically identifies AfterBurner with initialization bias and local optima.

3 Problem Formulation

The paper formulates algorithmic code optimization as generating a correct implementation with optimal execution efficiency. It models search as a population-based evolutionary process driven by a reward over correctness and efficiency.

  • Optimization Objective: Given a problem specification x, the objective is to generate an implementation y that satisfies functional requirements while achieving optimal execution efficiency.The task combines correctness with efficiency rather than treating correctness alone as the objective.
  • Optimization Environment: The optimization environment O = (X, Y, F) comprises problem specifications, candidate solutions, and a reward function evaluating solution quality.F maps solutions and specifications to real-valued rewards capturing correctness and efficiency.
  • Evolutionary Process: Across T iterations, a population of candidate solutions evolves through feedback-driven selection, mutation, and crossover.The trajectory records successive populations P0 through PT.
  • Evolutionary Process: The objective is to discover y* = arg max over candidate solutions of F(y, x), requiring controlled rather than uncontrolled stochastic exploration.The formulation emphasizes efficient navigation of the solution space.

4 Method

CSE combines diversified initialization, controlled genetic evolution, and hierarchical memory to guide population-based code optimization. It broadens initial search, performs targeted structural updates, and reuses successful and failed experiences within and across tasks.

  • Diversified Planning Initialization: Diversified Planning Initialization creates semantically distinct strategy sketches and instantiates them into an initial population covering multiple solution-space regions.Examples include greedy, dynamic programming, and bit-manipulation strategies rather than superficial variations.
  • Genetic Evolution: Genetic Evolution replaces uncontrolled stochastic search with feedback-guided selection, functional decomposition, targeted mutation, and compositional crossover.The method combines controlled interventions with probability-based parent selection.
  • Genetic Evolution: Controlled mutation regenerates a faulty functional component while preserving the remaining well-performing components.This surgical repair strategy avoids disruptive interference with global context and improves mutation efficiency.
  • Genetic Evolution: Compositional crossover structurally combines complementary strengths from parent solutions, such as time efficiency from one and robustness from another.The operator performs logic-level recombination rather than naive textual concatenation.
  • Hierarchical Evolution Memory: Hierarchical Evolution Memory retrieves task-relevant experiences and maintains local success and failure lessons for bidirectional guidance during evolution.Local memory injects validated strategies and negative constraints into subsequent prompts.
  • Overall Procedure: The complete algorithm initializes diverse candidates, selects parents probabilistically, retrieves global and local experiences, applies controlled operators, evaluates offspring, and updates memories.Global memory is updated by distilling top-K improving and degrading steps after evolution.

5 Experiments

Experiments on EffiBench-X evaluate CSE across languages, efficiency metrics, baselines, ablations, memory interactions, evolution dynamics, and a case study. CSE generally delivers stronger and more sustained efficiency improvements under fixed exploration budgets.

  • Main Results: CSE achieves the best performance across most ET, MP, and MI settings on Python and C++ under a 30-candidate budget.The advantage holds across open- and closed-source LLM backbones and is especially notable for memory integral.
  • Evolution Dynamics: CSE improves more rapidly in early generations and continues improving later, indicating stronger utilization of the fixed evolution budget.Figure 3 tracks the best-so-far MI as the generation count increases.
  • Ablation Studies: Removing Planning, Evolution, or Memory lowers performance under the same 30-candidate budget, with Memory having the largest impact.The consistent drops across ET and MP support the contribution of all three components and their interaction.
  • Memory Analysis: Memory provides negligible gain with Planning alone (∆MI = −0.23), substantial gain with Evolution (∆MI = +2.68), and its strongest gain with all components (∆MI = +5.02).These results indicate that Memory amplifies controlled evolutionary processes rather than providing universal standalone improvement.
  • Evolution Dynamics: CSE produces more frequent improvements (#Imp. = 1.79) and stronger late-stage progress (Last-10 #Imp. = 0.29) than AlphaEvolve and SE-Agent.The reported baselines are #Imp. = 0.90 and 1.60, and Last-10 #Imp. = 0.06 and 0.19, respectively.
  • Case Study: A 30-iteration case study shows CSE switching high-level formulations, refining bottlenecks through mutation, combining complementary strengths through crossover, and using memory to reduce redundancy.The final evolved solution differs markedly from the human reference and achieves better efficiency.

6 Conclusion

Controlled Self-Evolution addresses low exploration efficiency in code optimization through diversified planning, genetic evolution, and hierarchical evolution memory. On EffiBench-X, it outperforms baselines across LLM backbones and improves efficiency throughout evolution.

  • CSE addresses low exploration efficiency in existing self-evolution methods for code optimization.
  • CSE combines Diversified Planning Initialization, Genetic Evolution, and Hierarchical Evolution Memory to control exploration.
  • CSE consistently outperforms all baselines across various LLM backbones on EffiBench-X.
  • CSE achieves higher efficiency from early generations while maintaining continuous improvement throughout evolution.

Limitations

CSE improves solution quality through multi-round evolution, but the paper leaves amortizing this iterative optimization into the base model as an underexplored direction.

  • CSE can continuously improve solution quality through multi-round evolution.
  • Distilling CSE evolution trajectories into RL-style training remains an underexplored direction for strengthening the base model.

A Algorithmic Overview of CSE

CSE initializes a diverse population, iteratively applies reward-guided evolution with global and local memory, and returns the best solution while updating global experience.

  • Diversified Planning Initialization: Diversified planning initialization constructs an initial population by instantiating strategy sketches.
  • Evolutionary Loop: Each evolutionary iteration selects parents by reward and retrieves inter-task and intra-task experiences for the context.
  • Evolutionary Loop: Controlled mutation refines a selected solution, while compositional crossover generates a child from parent solutions.
  • Memory Update: After T iterations, CSE returns the best solution and distills top-K improving and degrading steps into task-level experience for global memory.

B Evaluation Metrics.

The evaluation measures execution time, peak memory, and memory–time integral relative to human reference solutions. Failed solutions receive zero scores, while metric values are clipped to retain credit for outperforming references and limit outliers.

  • ET, MP, and MI quantify execution time, peak memory usage, and memory–time integral for LLM solutions relative to human references.
  • Failure Handling: Solutions failing tests or encountering runtime errors receive a score of 0 for all metrics.
  • Clipping: Scores use clip(z, 0, k) with k = 5, preserving credit above human-reference performance while limiting extreme outlier influence.
  • Execution Time (ET): The overall ET is the mean per-problem execution-time score across evaluated problems, reported in a scaled form.
  • Memory Peak (MP): MP compares the peak memory usage of the LLM-generated solution with the human reference for each problem and in aggregate.
  • Memory Integral (MI): MI measures lifetime memory consumption through the memory–time integral, numerically approximated from high-resolution profiling traces.

C Implementation Details

CSE uses controlled evaluation, structured operators, deterministic scheduling, and hierarchical memories to guide reproducible algorithmic evolution under fixed budgets.

  • Efficiency is measured only on DIRECT-solved tasks, ensuring compared candidates are functionally correct.
  • Candidates are evaluated on 100 test cases with 10 s and 1024 MB limits; runtime errors, TLE, or MLE receive metric 0.
  • The raw memory–time integral A guides evolution, averaged over three non-outlier runs on the same machine.
  • T = 30 iterations generate one child each, alternating controlled mutation on odd iterations with compositional crossover on even iterations.
  • Module-level mutation and crossover use a fixed decomposition template to preserve interfaces and limit unintended edits.
  • Hierarchical memory combines compressed local experiences with task-level global items distilled from the top-K improving and degrading steps.

D Ablation Case Studies

Ablation case studies show that diversified initialization, genetic operators, and hierarchical memory each support faster progress and lower final performance values than their ablated variants.

  • Diversified Planning Initialization: 77.7% reduction by iteration 5 follows diversified planning, which starts at 886.1 and reaches 197.5 before later improvements.
  • Diversified Planning Initialization: Removing diversified planning plateaus near ≈433.7, versus 93.9 for full CSE, indicating prolonged stagnation from poor initial modes.
  • Genetic Evolution: Without Genetic Evolution, progress stays nearly flat for roughly 10 generations and improves only to ≈377.9.
  • Genetic Evolution: The genetic-evolution ablation ends near ≈377.9, compared with 93.9 for full CSE, showing a much higher final performance floor.
  • Hierarchical Evolution Memory: Removing Hierarchical Evolution Memory produces delayed drops from around ∼1200 to ∼910.6 and ∼405.9, followed by plateaus near ∼400 and ∼328.5.

E Prompt Templates

The prompt templates operationalize CSE's planning, implementation, diagnosis, mutation, crossover, and experience-extraction stages through structured outputs and explicit optimization guidance.

  • Diversified Planning Initialization: Diversified planning prompts request exactly K distinct high-performance strategies with algorithmic diversity and expected time and space complexity.
  • Decomposition: Slot-based diagnosis decomposes target solutions into components such as I/O, core logic, edge cases, and performance patches, then records risks and priorities.
  • Controlled Mutation: Mutation prompts emphasize correctness, algorithmic changes, failure-based pruning, and strict improvement over the prior solution.
  • Implementation: Implementation prompts require complete programs that fix bottlenecks, explore novel directions, and minimize the memory–time integral.
  • Compositional Crossover: Crossover prompts synthesize a cohesive hybrid by combining complementary strengths, avoiding shared weaknesses, and integrating prior trajectories.
  • Evolution Memory: Memory-extraction prompts distinguish success, failure, and neutral changes, producing reusable directions, reasoning patterns, or specific anti-patterns.
Loading 2601.07348v5…