[论文解读] Dr. Kernel: Reinforcement Learning Done Right for Triton Kernel Generations
该论文提出 KernelGym 与多轮强化学习方法(特别是 TRLOO、基于性能分析的奖励与 PRS)来训练 Dr. Kernel,一款 14B 模型,使其能够生成高性能的 Triton 内核,实现显著加速并降低奖励操纵。它在 KernelBench 上与前沿模型的表现具有竞争力,并在测试时的扩展性方面显示出显著提升。
High-quality kernel is critical for scalable AI systems, and enabling LLMs to generate such code would advance AI development. However, training LLMs for this task requires sufficient data, a robust environment, and the process is often vulnerable to reward hacking and lazy optimization. In these cases, models may hack training rewards and prioritize trivial correctness over meaningful speedup. In this paper, we systematically study reinforcement learning (RL) for kernel generation. We first design KernelGYM, a robust distributed GPU environment that supports reward hacking check, data collection from multi-turn interactions and long-term RL training. Building on KernelGYM, we investigate effective multi-turn RL methods and identify a biased policy gradient issue caused by self-inclusion in GRPO. To solve this, we propose Turn-level Reinforce-Leave-One-Out (TRLOO) to provide unbiased advantage estimation for multi-turn RL. To alleviate lazy optimization, we incorporate mismatch correction for training stability and introduce Profiling-based Rewards (PR) and Profiling-based Rejection Sampling (PRS) to overcome the issue. The trained model, Dr Kernel-14B, reaches performance competitive with Claude-4.5-Sonnet in Kernelbench. Finally, we study sequential test-time scaling for Dr Kernel-14B. On the KernelBench Level-2 subset, 31.6% of the generated kernels achieve at least a 1.2x speedup over the Torch reference, surpassing Claude-4.5-Sonnet (26.7%) and GPT-5 (28.6%). When selecting the best candidate across all turns, this 1.2x speedup rate further increases to 47.8%. All resources, including environment, training code, models, and dataset, are included in https://www.github.com/hkust-nlp/KernelGYM.
研究动机与目标
- Motivate automated generation of high-quality GPU kernels to accelerate AI systems.
- Develop a robust, distributed RL environment (KernelGym) for long-horizon kernel generation with execution-based feedback.
- Identify and mitigate reward hacking and lazy optimization in multi-turn RL for kernel generation.
- Propose unbiased multi-turn RL estimators (TRLOO) and bottleneck-aware rewards to improve optimization.
- Demonstrate scalable training and evaluation against KernelBench benchmarks and frontier models.
提出的方法
- Create KernelGym, a server–worker distributed environment with hacking checks and rich profiling feedback.
- Use multi-turn RL where each turn refines kernel code and receives execution feedback from KernelGym.
- Introduce Turn-level Reinforce-Leave-One-Out (TRLOO) to remove self-inclusion bias in multi-turn GRPO-style updates.
- Incorporate mismatch correction via geometric MRS to stabilize training.
- Add Profiling-based Rewards (PR) to reward optimization of true bottlenecks and Profiling-based Rejection Sampling (PRS) to filter low-impact samples.
- Apply sequential test-time scaling (STTS) to improve inference-time kernel generation.
实验结果
研究问题
- RQ1Can multi-turn RL with explicit execution feedback produce kernel code that yields meaningful speedups beyond correctness?
- RQ2How can we mitigate reward hacking and lazy optimization in RL-guided kernel generation?
- RQ3What unbiased advantage estimators and training stabilizers improve long-horizon RL for kernel synthesis?
- RQ4Does bottleneck-aware reward design and selective sampling improve alignment with real performance gains?
- RQ5Can test-time scaling further enhance generation quality without excessive context growth?
主要发现
- Dr. Kernel-14B with STTS achieves higher speedups than several baselines on KernelBench Level-2 and surpasses some frontier models on stricter metrics.
- TRLOO provides unbiased turn-level advantages and outperforms GRPO and single-turn baselines in Fast@1.2.
- Profiling-based Rewards (PR) and PRS significantly lift Fast@1.2 beyond MRS alone, indicating better focus on true bottlenecks.
- STTS with context management substantially improves Level-1/Level-2 metrics and, in best-turn selection, reaches competitive results with GPT-5 and Claude-4.5-Sonnet.
- Dr. Kernel-14B-STTS with best-turn selection achieves Fast@1.2 of 47.8% on Level-2, surpassing several frontier models.
- Sequential test-time scaling further improves Level-3 results, narrowing the gap to frontier models.
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。