TL;DR
Existing Large Language Model (LLM)-based automated algorithm design methods evolve code at the whole-program level, meaning valuable local sub-routines are thrown away if the overall program performs poorly. PACE (Primitive-Aware Code Evolution) solves this by decoupling local logic into persistent, reusable units called Executable Algorithmic Primitives (EAPs). By managing these primitives with a multi-armed bandit framework and structural variation operators, PACE significantly improves search efficiency and discovers state-of-the-art algorithms across control and optimization tasks.
What Problem Does This Paper Address?
Automated Algorithm Design (AAD) leverages LLMs to generate and optimize code iteratively. However, current state-of-the-art frameworks (like FunSearch or EoH) treat an entire program as a single, indivisible unit during evolution.
This "whole-program" perspective creates a fundamental coupling problem: a brilliant local code snippet (e.g., an excellent heuristic for estimating track curvature in a racing game) might be permanently lost if the rest of the program contains a bug or performs poorly overall. As a result, the LLM wastes its search budget repeatedly discarding and rediscovering the same useful local logic.
Methods
PACE introduces a modular framework that treats local algorithmic components as independent evolutionary objects called Executable Algorithmic Primitives (EAPs). At the code level, an EAP is a standalone, callable function with a fixed implementation and a stable identity across different host programs.
The PACE architecture consists of three core pillars:
- Primitive-Aware Operators: PACE defines four structural variation operators to guide the LLM:
- Primitive Insertion ($P_1$): Injects a new EAP into a parent program.
- Primitive Replacement ($P_2$): Swaps out a low-performing EAP for a new candidate.
- Primitive-Preserving Refinement ($P_3$): Optimizes the macro-algorithm structure around existing EAPs without changing them.
- Primitive-Aware Crossover ($P_4$): Recombines EAPs from two successful parent programs.
Crucially, an Abstract Syntax Tree (AST) verifier programmatically enforces these structural constraints, discarding any LLM hallucinations that violate the contracts.
- Bandit Credit Assignment via Thompson Sampling: To isolate an EAP's true utility from its host program's noise, PACE uses a Multi-Armed Bandit setup. It tracks parent-child relative performance. If a child program containing a specific EAP outperforms its parent, that EAP receives a positive binary reward, updating its Beta posterior distribution. Thompson sampling then dynamically selects the most promising EAPs for future insertions and replacements.
- EAP Discovery: New primitives are either extracted (refactored from a newly discovered historical best algorithm) or generated (the LLM is prompted to synthesize a novel function distinct from the current top-performing EAPs).
Datasets
The authors evaluated PACE on four benchmarks spanning two distinct domains:
- Continuous Control (OpenAI Gym):
- Racing Car: Evolving programmatic driving policies from visual (RGB) and state inputs.
- Bipedal Walker: Evolving a 4-torque motor controller from a 24-dimensional continuous state vector.
- Combinatorial Optimization (Traveling Salesperson Problem):
- TSP-Construct: Evolving a next-node selection function.
- TSP-ACO: Evolving a distance-to-heuristic matrix transformation function to guide a fixed Ant Colony Optimization solver.
Key Insights and Ideas
- Isolating Causal Impact: By evaluating EAPs based on parent-relative rewards rather than absolute task scores, PACE successfully filters out host program noise. A good primitive transferred into a mediocre program will still show a relative improvement, preserving its credit.
- Asymmetric LLM Ensembles: Because EAP discovery is decoupled from macro-program generation, researchers can use a stronger, more expensive LLM (like Gemini 3.1 Pro) solely for creating primitives, while using a cheaper model (like GPT-4o-mini) for the main evolutionary loop. Since primitive discovery accounts for only ~1.6% of total token consumption, this hybrid approach yields massive performance boosts at a negligible cost.
- Structural Boundaries as Regularizers: Forcing the LLM to interact with code through strict functional boundaries (verified via AST) prevents chaotic, unconstrained edits, acting as a powerful regularizer for code evolution.
Key Results
PACE consistently outperformed standard LLM-based AAD baselines (such as EoH, ReEvo, and MCTS-AHD) across all tasks:
- Continuous Control: On Racing Car, PACE achieved a test score of 98.90, outperforming both standard AAD baselines (~64–84) and deep reinforcement learning (PPO at 85.69). On the notoriously difficult Bipedal Walker task, where other programmatic methods flatlined near zero or failed entirely, PACE achieved a test score of 133.71.
- Zero-Shot Scale Generalization: In the TSP benchmarks, algorithms were evolved on small instances ($n=50$) and tested on larger scales ($n=200$ to $1000$). On TSP-Construct, PACE maintained the lowest tour costs across all out-of-domain scales (e.g., 26.596 at $n=1000$ vs. Greedy Construction's 28.917).
Limitations and Future Work
The primary limitation of PACE is its assumption of primitive independence. The framework evaluates and selects each EAP individually. However, in highly complex algorithms, strong coupling or non-linear dependencies may exist between different sub-functions (i.e., Primitive A might only work well when paired with Primitive B).
The authors note that future work will focus on developing primitive coupling metrics to explicitly model and exploit these inter-primitive dependencies during the evolutionary search.
Summary updated