The exponential growth in demand for GPU computing resources has created an urgent need for automated CUDA optimization strategies. While recent advances in LLMs show promise for code generation, current SOTA models achieve low success rates in improving CUDA speed. In this paper, we introduce CUDA-L1, an automated reinforcement learning framework for CUDA optimization that employs a novel contrastive RL algorithm. CUDA-L1 achieves significant performance improvements on the CUDA optimization task: trained on A100, it delivers an average speedup of x3.12 with a median speedup of x1.42 against default baselines over across all 250 CUDA kernels of KernelBench, with peak speedups reaching x120. In addition to the default baseline provided by KernelBench, CUDA-L1 demonstrates x2.77 over Torch Compile, x2.88 over Torch Compile with reduce overhead, x2.81 over CUDA Graph implementations, and remarkably x7.72 over cuDNN libraries. Furthermore, the model also demonstrates portability across different GPU architectures. Beyond these benchmark results, CUDA-L1 demonstrates several properties: it 1) discovers a variety of CUDA optimization techniques and learns to combine them strategically to achieve optimal performance; 2) uncovers fundamental principles of CUDA optimization, such as the multiplicative nature of optimizations; 3) identifies non-obvious performance bottlenecks and rejects seemingly beneficial optimizations that actually harm performance. The capabilities demonstrate that, RL can transform an initially poor-performing LLM into an effective CUDA optimizer through speedup-based reward signals alone, without human expertise or domain knowledge. This paradigm opens possibilities for automated optimization of CUDA operations, and holds promise to substantially promote GPU efficiency and alleviate the rising pressure on GPU computing resources.


翻译:GPU计算资源需求的指数级增长催生了对自动化CUDA优化策略的迫切需求。尽管大语言模型(LLM)在代码生成方面展现出潜力,但当前最先进模型在提升CUDA速度方面成功率较低。本文提出CUDA-L1,一种基于新型对比强化学习算法的自动化CUDA优化强化学习框架。在CUDA优化任务中,CUDA-L1取得了显著的性能提升:在A100上训练后,针对KernelBench全部250个CUDA内核,相较于默认基线实现了平均3.12倍、中位数1.42倍的加速效果,峰值加速比达到120倍。除KernelBench提供的默认基线外,CUDA-L1相较Torch Compile实现2.77倍加速,相较降低开销的Torch Compile实现2.88倍加速,相较CUDA Graph实现2.81倍加速,相较cuDNN库更实现7.72倍的显著提升。此外,该模型还展现出跨GPU架构的可移植性。除基准测试结果外,CUDA-L1展现出以下特性:1)发现多种CUDA优化技术并学会策略性组合以实现最优性能;2)揭示CUDA优化的基本原理,如优化效果的乘性特征;3)识别非显性性能瓶颈,并拒绝实际损害性能的表面有益优化。这些能力表明,仅通过基于加速比的奖励信号,强化学习即可将初始性能欠佳的LLM转化为高效的CUDA优化器,无需人类专业知识或领域经验。该范式为CUDA运算的自动化优化开辟了新路径,有望显著提升GPU效率并缓解日益增长的GPU计算资源压力。

0
下载
关闭预览

相关内容

【ECCV2022】对比视觉Transformer的在线持续学习
专知会员服务
23+阅读 · 2022年7月29日
【NeurIPS2019】图变换网络:Graph Transformer Network
专知会员服务
112+阅读 · 2019年11月25日
ICLR'21 | GNN联邦学习的新基准
图与推荐
12+阅读 · 2021年11月15日
论文浅尝 | GEOM-GCN: Geometric Graph Convolutional Networks
开放知识图谱
14+阅读 · 2020年4月8日
图机器学习 2.2-2.4 Properties of Networks, Random Graph
图与推荐
10+阅读 · 2020年3月28日
【NeurIPS2019】图变换网络:Graph Transformer Network
Single-Shot Object Detection with Enriched Semantics
统计学习与视觉计算组
14+阅读 · 2018年8月29日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关资讯
ICLR'21 | GNN联邦学习的新基准
图与推荐
12+阅读 · 2021年11月15日
论文浅尝 | GEOM-GCN: Geometric Graph Convolutional Networks
开放知识图谱
14+阅读 · 2020年4月8日
图机器学习 2.2-2.4 Properties of Networks, Random Graph
图与推荐
10+阅读 · 2020年3月28日
【NeurIPS2019】图变换网络:Graph Transformer Network
Single-Shot Object Detection with Enriched Semantics
统计学习与视觉计算组
14+阅读 · 2018年8月29日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员