TL;DR
Record-Remix-Replay ($R^3$) is a hierarchical framework that optimizes GPU kernels across the entire software stack—from unstructured source code rewrites down to compiler flags and runtime launch parameters. By combining LLM-driven evolutionary search with an in-memory record-replay engine, $R^3$ eliminates the massive compilation and execution bottlenecks of traditional auto-tuners, delivering superior speedups nearly an order of magnitude faster than modern evolutionary approaches.
What Problem Does This Paper Address?
Maximizing GPU performance is a notorious headache for high-performance computing (HPC) and AI engineers. The optimization space is deeply hierarchical and non-separable: a minor tweak to source code can alter register pressure, which completely changes which compiler transformations are profitable or which thread block dimensions are optimal.
As shown in the paper's taxonomy of related work, existing tools typically attack this problem in isolation:
While Large Language Models (LLMs) have recently been used as evolutionary agents to rewrite source code, they suffer from a massive evaluation bottleneck. To test if a generated code variant is fast and correct, traditional frameworks must recompile and rerun the entire application. For large scientific workloads, this makes evolutionary search prohibitively expensive and slow.
Methods
The authors introduce Record-Remix-Replay ($R^3$), a framework that decouples kernel optimization from full-application execution using a two-level hierarchical search loop:
- Outer Loop (Tune Source Code): $R^3$ uses an LLM ensemble guided by the MAP-Elites evolutionary algorithm to propose unstructured source code mutations.
- Inner Loop (Tune Compiler & Runtime): For every source candidate generated by the LLM, the framework compiles it directly to LLVM IR and passes it to a custom Persistent Replay Server. This server isolates the kernel, restoring a previously recorded execution context (prologue/epilogue snapshots of device memory). It then runs parallel Bayesian Optimization (BO) to find the best combination of compiler passes and launch configurations for that specific code variant.
To scale this process to hundreds of GPUs, $R^3$ introduces two key systems optimizations:
- Prefix-Cache Aware Prompting: It reorders code examples in the LLM prompt to maximize prefix cache hits in the inference engine, drastically cutting down LLM generation latency and cost.
- Runtime-Aware Scheduling: It opportunistically "backfills" faster, smaller LLM models to generate candidates when evaluation GPUs are idling, maximizing hardware utilization.
Datasets
The framework was evaluated using full CUDA and HIP implementations of four prominent scientific proxy applications from the HeCBench benchmark suite:
- LULESH: A shock hydrodynamics application (15 GPU kernels).
- MiniFE: An implicit finite-element application (7 GPU kernels).
- S3D: A turbulent combustion simulation code (54 GPU kernels).
- miniWeather: A weather simulation mini-app (7 GPU kernels).
Additionally, the authors conducted a real-world production case study on QUDA, a massive, state-of-the-art lattice Quantum Chromodynamics (QCD) library.
Key Insights and Ideas
- Flipping the Bottleneck: By replacing full-application execution with isolated, in-memory kernel replay, $R^3$ shifts evolutionary optimization from being evaluation-bound (waiting on compilers and runs) to inference-bound (waiting on the LLM).
- Co-designing Code and Parameters: Evaluating a source code change using a single, arbitrary compiler setting is misleading. $R^3$ ensures every code variant is judged by its best possible realization after compiler and launch parameter tuning.
- Prompt Engineering for Systems Efficiency: In evolutionary search, prompts accumulate historical code variants. By treating prompt generation as a caching problem and reordering history to maintain static prefixes, the authors achieved significant speedups in LLM generation times.
Key Results
- Drastic Speedups in Time-to-Solution: When optimizing the QUDA application, $R^3$ reduced compilation time by ~86% and evaluation time by ~88% compared to standard evolutionary methods. For MiniFE, $R^3$ arrived at its solution 8.5 hours faster than OpenEvolve.
- Superior Performance: $R^3$ consistently achieved higher median and maximum kernel speedups than both pure Bayesian Optimization and standard LLM evolution across AMD MI300A and NVIDIA H100 GPUs.
- Production Impact: In the QUDA case study targeting the expensive
CoarseDslashkernel, $R^3$ discovered novel loop reorganizations and invariant hoisting that yielded a 1.33x kernel speedup, translating to a 28.4% reduction in total compute time when deployed on a 64-GPU cluster.
Limitations and Future Work
- LLM Overhead: Although $R^3$ is nearly an order of magnitude faster than previous evolutionary coding agents, it is still slower than pure parameter auto-tuning due to the inherent latency of generating text with frontier LLMs.
- Numerical Correctness Constraints: By default, the replay engine enforces strict bitwise equality for correctness. For floating-point optimizations (like replacing division with a reciprocal square root), users must manually annotate variables to allow relaxed numerical tolerances.
- Single-Kernel Focus: The current framework optimizes kernels in isolation. Future work could expand $R^3$ to reason about multi-kernel interactions, data transfers, and graph-level optimizations across an entire application workflow.
Summary updated