Dr. Kernel:为Triton内核生成正确强化学习
Dr. Kernel: Reinforcement Learning Done Right for Triton Kernel Generations
AI总结:
Dr. Kernel通过强化学习方法优化内核生成,其模型在Kernelbench测试中达到与Claude-4.5-Sonnet相当的性能,并在速度提升方面超越其他模型。
摘要:
高质量内核对于可扩展的AI系统至关重要,使LLMs能够生成此类代码将推动AI发展。然而,训练此类LLMs需要足够的数据、稳健的环境,且过程常易受到奖励黑客和懒惰优化的攻击。在这些情况下,模型可能会黑客训练奖励,优先考虑琐碎的正确性而非有意义的速度提升。在本文中,我们系统研究了内核生成的强化学习(RL)。我们首先设计了KernelGYM,一个稳健的分布式GPU环境,支持奖励黑客检查、多轮交互的数据收集和长期RL训练。基于KernelGYM,我们研究了有效的多轮RL方法,并识别出由GRPO中的自我包含引起的偏见策略梯度问题。为了解决这一问题,我们提出了Turn-level Reinforce-Leave-One-Out(TRLOO),为多轮RL提供无偏的优势估计。为缓解懒惰优化,我们纳入了不匹配修正以提高训练稳定性,并引入基于轮廓的奖励(PR)和基于轮廓的拒绝采样(PRS)以克服该问题。训练后的模型Dr Kernel-14B在Kernelbench上的性能与Claude-4.5-Sonnet相当。最后,我们研究了Dr Kernel-14B的顺序测试时间扩展。在KernelBench Level-2子集上,31.6%的生成内核在Torch参考上实现了至少1.2倍的速度提升,超过了Claude-4.5-Sonnet(26.7%)和GPT-5(28.6%)。当在所有轮次中选择最佳候选时,这一1.2倍速度提升率进一步增加到47.8%。所有资源,包括环境、训练代码、模型和数据集,均包含在https://www.github.com/hkust-nlp/KernelGYM中。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。