TL;DR
daVinci-kernel is a novel reinforcement learning framework that automates high-performance GPU kernel optimization by co-evolving a generative policy with a dynamic skill library. By jointly training three specialized agents (selection, policy, and summarization) on a single LLM backbone, it continuously discovers and exploits optimization strategies, achieving state-of-the-art results on KernelBench and significantly outperforming prior models on complex tasks.
What Problem Does This Paper Address?
Writing highly efficient GPU kernels (in CUDA or Triton) is notoriously difficult. Unlike standard code generation where the goal is binary correctness (does the code work or not?), kernel optimization starts with code that is already correct but runs slowly. The goal is to iteratively apply complex transformations—like operator fusion, shared memory allocation, and tiling—to maximize execution speed.
Reinforcement learning (RL) is a natural fit for this iterative process, but it suffers from a moving frontier problem. Early in training, an RL agent benefits from broad, obvious fixes. As it improves, those basic tricks get internalized, and the remaining performance bottlenecks require much subtler, tightly coupled optimizations. A static library of optimization tips quickly becomes obsolete or redundant. To sustain long-term performance gains, an automated system needs a way to continuously discover new skills, evaluate their utility relative to the model's current competence, and discard stale advice.
Methods
The authors introduce daVinci-kernel, a closed-loop framework where three distinct agent roles share a single LLM backbone and co-evolve through joint reinforcement learning:
- Skill Selection Agent (The Retriever): Given a GPU task description, this agent queries a shared skill library. It uses a lightweight BM25 lexical pre-filtering step followed by an LLM-based reranking step to inject the top 3 most relevant optimization techniques directly into the prompt context.
- Policy Agent (The Executor): This agent generates the actual CUDA/Triton code over multiple turns, conditioned on the selected skills and real-world environment execution feedback. It is optimized using Turn-level REINFORCE Leave-One-Out (TRLOO).
- Skill Summary Agent (The Distiller): When the Policy Agent achieves a significant speedup, the Summary Agent analyzes the successful trajectory and abstracts the underlying optimization insight into a reusable "skill" (complete with motivation, key ideas, and code examples).
Crucially, candidate skills must pass execution-based verification—meaning they are re-tested in the environment to confirm they deliver reproducible speedups—before they are officially added to the library.
To prevent the model from overfitting to easy, generic tricks early on, the framework utilizes a structured SFT cold start that applies HDBSCAN clustering to downsample repetitive skill patterns and ensure a diverse initial vocabulary.
Datasets
- KernelBench: The primary benchmark used to evaluate the framework. It organizes GPU kernel optimization tasks into three difficulty levels (Level 1, 2, and 3) and measures performance based on the percentage of tasks that achieve specific speedup thresholds (e.g., $\text{Fast}_1$, $\text{Fast}_{1.2}$).
- CUDALLM Tasks: A seed dataset used to collect initial multi-turn optimization trajectories via a strong teacher model (GPT-4 class) to bootstrap the supervised fine-tuning (SFT) phase.
Key Insights and Ideas
- The Skill Frontier Shifts: Optimization knowledge is not static. As the policy agent internalizes basic patterns, the selection agent naturally shifts to surfacing more complex, task-specific strategies.
- Joint Multi-Agent RL is Essential: Training the selection and summarization mechanisms jointly with the policy agent prevents a mismatch between the library's contents and the policy's evolving competence. Without joint training, the system stagnates and surfaces stale advice.
- Lexical Search is Not Enough: While simple keyword matching (BM25) can help find shallow speedups, LLM-based reranking is required to assess whether a skill matches the specific structural bottleneck of a complex task.
Key Results
Evaluated on KernelBench, daVinci-kernel-14B achieved substantial performance leaps over existing open and closed-source models:
- State-of-the-Art Performance: Under the $\text{Fast}_1$ threshold, it achieved 37.2% on Level 1, 70.6% on Level 2, and 32.2% on Level 3 tasks, consistently outperforming
Dr. Kernel-14B(the previous best RL-trained baseline). - Widening Gap on Hard Tasks: The benefits of the evolving skill library became more pronounced as task difficulty increased, yielding up to a 46% relative improvement on highly complex Level 3 kernels.
Ablation studies confirmed that removing inference-time skill injection (Ablation 1) caused the most severe performance drops, proving that explicit skill context is vital for guiding the model through highly constrained optimization spaces.
Limitations and Future Work
- Domain Constraints: The framework was exclusively validated on GPU kernel optimization. It remains unproven how well this co-evolutionary skill loop generalizes to broader domains like software engineering or scientific discovery.
- Retrieval Scalability: As the skill library expands over long training runs, relying on purely textual summarization and BM25 pre-filtering may introduce semantic noise or become computationally inefficient.
- Potential Redundancy: Even with execution-grounded verification, the library can still accumulate narrow, task-specific skills that offer low transferability to novel problems.
Summary updated