Table of Contents
Fetching ...

Large Language Model-Powered Evolutionary Code Optimization on a Phylogenetic Tree

Leyi Zhao, Weijie Huang, Yitong Guo, Jiang Bian, Chenghong Wang, Xuhong Zhang

TL;DR

The paper tackles the challenge of efficiently optimizing GPU kernels for scientific computing by reframing the process as trajectory conditioned in context reinforcement learning. It introduces PhyloEvolve, an LLM driven framework that uses a phylogenetic forest, an Elite Pool, multi island exploration, and containerized backends to store and reuse optimization trajectories without weight updates. Central to the approach are Algorithm Distillation and prompt based Decision Transformers that learn from historical modification sequences to guide future refinements, enabling zero shot adaptation to new tasks and hardware. Empirical results across LLG, LTSA, and GraphWave show consistent runtime, memory, and correctness gains, with cross lineage transfer uncovering domain transferable optimization motifs. The study highlights opportunities to incorporate cost models, extend hardware support, formalize theory of trajectory based learning, and scale to distributed accelerators, establishing trajectory centered ICRL as a practical path to automated, cross domain GPU optimization.

Abstract

Optimizing scientific computing algorithms for modern GPUs is a labor-intensive and iterative process involving repeated code modification, benchmarking, and tuning across complex hardware and software stacks. Recent work has explored large language model (LLM)-assisted evolutionary methods for automated code optimization, but these approaches primarily rely on outcome-based selection and random mutation, underutilizing the rich trajectory information generated during iterative optimization. We propose PhyloEvolve, an LLM-agent system that reframes GPU-oriented algorithm optimization as an In-Context Reinforcement Learning (ICRL) problem. This formulation enables trajectory-conditioned reuse of optimization experience without model retraining. PhyloEvolve integrates Algorithm Distillation and prompt-based Decision Transformers into an iterative workflow, treating sequences of algorithm modifications and performance feedback as first-class learning signals. To organize optimization history, we introduce a phylogenetic tree representation that captures inheritance, divergence, and recombination among algorithm variants, enabling backtracking, cross-lineage transfer, and reproducibility. The system combines elite trajectory pooling, multi-island parallel exploration, and containerized execution to balance exploration and exploitation across heterogeneous hardware. We evaluate PhyloEvolve on scientific computing workloads including PDE solvers, manifold learning, and spectral graph algorithms, demonstrating consistent improvements in runtime, memory efficiency, and correctness over baseline and evolutionary methods. Code is published at: https://github.com/annihi1ation/phylo_evolve

Large Language Model-Powered Evolutionary Code Optimization on a Phylogenetic Tree

TL;DR

The paper tackles the challenge of efficiently optimizing GPU kernels for scientific computing by reframing the process as trajectory conditioned in context reinforcement learning. It introduces PhyloEvolve, an LLM driven framework that uses a phylogenetic forest, an Elite Pool, multi island exploration, and containerized backends to store and reuse optimization trajectories without weight updates. Central to the approach are Algorithm Distillation and prompt based Decision Transformers that learn from historical modification sequences to guide future refinements, enabling zero shot adaptation to new tasks and hardware. Empirical results across LLG, LTSA, and GraphWave show consistent runtime, memory, and correctness gains, with cross lineage transfer uncovering domain transferable optimization motifs. The study highlights opportunities to incorporate cost models, extend hardware support, formalize theory of trajectory based learning, and scale to distributed accelerators, establishing trajectory centered ICRL as a practical path to automated, cross domain GPU optimization.

Abstract

Optimizing scientific computing algorithms for modern GPUs is a labor-intensive and iterative process involving repeated code modification, benchmarking, and tuning across complex hardware and software stacks. Recent work has explored large language model (LLM)-assisted evolutionary methods for automated code optimization, but these approaches primarily rely on outcome-based selection and random mutation, underutilizing the rich trajectory information generated during iterative optimization. We propose PhyloEvolve, an LLM-agent system that reframes GPU-oriented algorithm optimization as an In-Context Reinforcement Learning (ICRL) problem. This formulation enables trajectory-conditioned reuse of optimization experience without model retraining. PhyloEvolve integrates Algorithm Distillation and prompt-based Decision Transformers into an iterative workflow, treating sequences of algorithm modifications and performance feedback as first-class learning signals. To organize optimization history, we introduce a phylogenetic tree representation that captures inheritance, divergence, and recombination among algorithm variants, enabling backtracking, cross-lineage transfer, and reproducibility. The system combines elite trajectory pooling, multi-island parallel exploration, and containerized execution to balance exploration and exploitation across heterogeneous hardware. We evaluate PhyloEvolve on scientific computing workloads including PDE solvers, manifold learning, and spectral graph algorithms, demonstrating consistent improvements in runtime, memory efficiency, and correctness over baseline and evolutionary methods. Code is published at: https://github.com/annihi1ation/phylo_evolve
Paper Structure (31 sections, 5 equations, 5 figures, 1 algorithm)

This paper contains 31 sections, 5 equations, 5 figures, 1 algorithm.

Figures (5)

  • Figure 1: Example of a phylogenetic tree used in PhyloEvolve. Each node represents an algorithm variant, and edges correspond to refinement steps applied during optimization. The tree structure captures divergent exploration paths, where different branches pursue distinct optimization trajectories. High-performing variants contribute their trajectories and modifications to the elite pool, enabling cross-lineage reuse in subsequent iterations. This structured representation preserves diversity, prevents premature convergence, and organizes optimization history into reusable, hierarchical lineages.
  • Figure 2: The interaction loop between agents in PhyloEvolve. The NextStepper proposes refinement actions conditioned on historical trajectories; the ModifyAgent applies and validates the proposed code edits; the Designer performs higher-level structural transformations only when necessary; and the Summarizer compresses the evolving trajectory history into reusable context. Performance feedback from executing each candidate informs subsequent proposals, and successful trajectories are routed into the elite pool. Through this coordinated multi-agent loop, the system iteratively generates, evaluates, and preserves algorithmic improvements.
  • Figure 3: Simplified pipeline of PhyloEvolve. The Orchestrator coordinates the LLM agents to generate refinement candidates and larger structural redesigns. Generated variants are inserted into the phylogenetic forest, executed and benchmarked by the CodeExecutor, and evaluated for performance. High-performing variants are preserved in the Elite Pool, which in turn guides subsequent evolution through trajectory-conditioned retrieval and cross-lineage knowledge transfer.
  • Figure 4: Runtime acceleration achieved by PhyloEvolve on (a) the Landau–Lifshitz–Gilbert (LLG) PDE solver and (b) the Local Tangent Space Alignment (LTSA) manifold-learning algorithm. In both cases, PhyloEvolve generates GPU-optimized code variants that substantially outperform the baseline implementations. The system adapts to the computational structure of each workload—stiff vector-field updates for LLG and dense/small-matrix linear algebra for LTSA—achieving multi-fold speedups without compromising numerical correctness. These results highlight PhyloEvolve’s ability to discover workload-specific optimization strategies through trajectory-conditioned learning rather than random mutation.
  • Figure 5: Performance improvements achieved by PhyloEvolve on the GraphWave algorithm across varying graph sizes (a) and densities (b). GraphWave relies heavily on spectral graph computations, including Laplacian eigendecomposition and heat-kernel-based wave propagation. PhyloEvolve autonomously discovers GPU-efficient kernel variants that outperform the baseline implementation, especially on larger and denser graphs. These optimizations arise from trajectory-conditioned learning rather than random mutation, enabling the system to restructure sparse-linear-algebra operations, reduce kernel launch overhead, and exploit batching opportunities. The results highlight PhyloEvolve’s ability to adapt to different graph regimes and improve throughput in spectral embedding workflows.