arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2506.09092cs.LGcs.AI
收藏

CUDA-LLM: 大语言模型能够编写高效的CUDA内核

CUDA-LLM: LLMs Can Write Efficient CUDA Kernels

Shanghai Jiao Tong University(上海交通大学)

Wentao Chen, Jiace Zhu, Qi Fan, Yehan Ma, An Zou

AI总结:

针对大语言模型难以生成高性能GPU适配代码的问题,提出特征搜索与强化框架FSR,可联合优化CUDA代码的正确性与运行效率,生成的内核速度最高超人类手写代码179倍,为GPU编程自动化提供新路径。

摘要:

大语言模型(LLMs)已在通用代码生成领域展现出强大能力。然而,生成深度适配硬件、具备架构感知能力且对性能要求极高的代码——尤其是针对大规模并行GPU的代码——仍是一项复杂挑战。本研究探索利用LLMs自动生成与优化CUDA程序,目标是产出能充分挖掘底层硬件潜力的高性能GPU内核。\n为应对这一挑战,我们提出了名为**特征搜索与强化(Feature Search and Reinforcement, FSR)**的新型框架。FSR联合优化编译正确性、功能正确性与运行时性能,其中前两者通过丰富多样的测试用例验证,后者则通过目标GPU上的实际内核执行延迟来衡量。该方法不仅能让LLMs生成语法和语义均正确的CUDA代码,还能结合GPU架构特性对代码进行迭代优化以提升效率。\n我们在覆盖AI工作负载与计算密集型算法的代表性CUDA内核上评估了FSR框架。结果表明,搭载FSR的LLMs可始终保证正确率,同时自动生成的内核执行速度最高可比普通人类编写的代码快179倍。这些发现凸显了将LLMs与性能强化相结合,为硬件特定、架构敏感且性能关键的应用实现GPU编程自动化的潜力。

英文摘要:

Large Language Models (LLMs) have demonstrated strong capabilities in general-purpose code generation. However, generating the code which is deeply hardware-specific, architecture-aware, and performance-critical, especially for massively parallel GPUs, remains a complex challenge. In this work, we explore the use of LLMs for the automated generation and optimization of CUDA programs, with the goal of producing high-performance GPU kernels that fully exploit the underlying hardware. To address this challenge, we propose a novel framework called \textbf{Feature Search and Reinforcement (FSR)}. FSR jointly optimizes compilation and functional correctness, as well as the runtime performance, which are validated through extensive and diverse test cases, and measured by actual kernel execution latency on the target GPU, respectively. This approach enables LLMs not only to generate syntactically and semantically correct CUDA code but also to iteratively refine it for efficiency, tailored to the characteristics of the GPU architecture. We evaluate FSR on representative CUDA kernels, covering AI workloads and computational intensive algorithms. Our results show that LLMs augmented with FSR consistently guarantee correctness rates. Meanwhile, the automatically generated kernels can outperform general human-written code by a factor of up to 179$\times$ in execution speeds. These findings highlight the potential of combining LLMs with performance reinforcement to automate GPU programming for hardware-specific, architecture-sensitive, and performance-critical applications.

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

↑