arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.05475cs.LGcs.CL
收藏

MaxCode: 一种用于自动代码优化的max-奖励强化学习框架

MaxCode: A Max-Reward Reinforcement Learning Framework for Automated Code Optimization

Johns Hopkins University(约翰霍普金斯大学);Amazon Web Services(亚马逊网络服务)

Jiefu Ou, Sapana Chaudhary, Kaj Bostrom, Nathaniel Weir, Shuai Zhang, Huzefa Rangwala, George Karypis

AI总结:

MaxCode通过max-reward强化学习框架提升代码优化性能,实现20.3%的绝对速度提升和10.1%的相对排名提升。

摘要:

大型语言模型(LLMs)在通用编程任务中表现出强大的能力,但在优化代码时面临两个关键挑战:(i)编写优化代码(如高性能CUDA内核和竞赛级CPU代码)需要系统、算法和特定语言的专业知识;(ii)需要解释性能指标,如时间和设备利用率,而不仅仅是二进制正确性。在本工作中,我们探索了推理时间搜索算法,通过基于执行反馈的迭代改进引导LLM发现更好的解决方案。我们的方法称为MaxCode,将现有的搜索方法统一到max-reward强化学习框架下,使观察和动作价值函数模块化以进行修改。为了增强观察空间,我们集成了一个自然语言批评模型,将原始执行反馈转换为关于错误和性能瓶颈的诊断见解以及迄今为止最佳折扣奖励。这些共同为代码提案功能提供了更丰富的输入。为了在搜索过程中提高探索,我们使用从rollouts中获得的动作值训练生成奖励到去模型,以重新排序潜在解决方案。在KernelBench(CUDA)和PIE(C++)优化基准测试中,MaxCode相比基线方法提高了优化代码的性能,实现了绝对速度提升值的20.3%和相对速度排名的10.1%的提升。

英文摘要:

Large Language Models (LLMs) demonstrate strong capabilities in general coding tasks but encounter two key challenges when optimizing code: (i) the complexity of writing optimized code (such as performant CUDA kernels and competition-level CPU code) requires expertise in systems, algorithms and specific languages and (ii) requires interpretation of performance metrics like timing and device utilization beyond binary correctness. In this work, we explore inference-time search algorithms that guide the LLM to discover better solutions through iterative refinement based on execution feedback. Our approach, called MaxCode unifies existing search methods under a max-reward reinforcement learning framework, making the observation and action-value functions modular for modification. To enhance the observation space, we integrate a natural language critique model that converts raw execution feedback into diagnostic insights about errors and performance bottlenecks, and the best-discounted reward seen so far. Together, these provide richer input to the code proposal function. To improve exploration during search, we train a generative reward-to-go model using action values from rollouts to rerank potential solutions. Testing on the KernelBench (CUDA) and PIE (C++) optimization benchmarks shows that MaxCode improves optimized code performance compared to baselines, achieving 20.3% and 10.1% relative improvements in absolute speedup value and relative speedup ranking, respectively.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑