CUDA-L2:通过强化学习超越cuBLAS在矩阵乘法上的性能
CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning
AI总结:
研究提出CUDA-L2系统,结合大语言模型与强化学习自动优化HGEMM的CUDA内核,以CUDA执行速度为奖励,在多种配置上优化。实验表明其在离线和服务器模式下均超越主要基线,证明可通过该方法改进关键内核。
摘要:
本文提出了CUDA-L2系统,它结合大语言模型和强化学习来自动优化半精度通用矩阵乘法(HGEMM)的CUDA内核。以CUDA执行速度作为强化学习奖励,CUDA-L2能在1000种配置上自动优化HGEMM内核。在离线模式下,CUDA-L2平均比某基线高出22.0%,比cuBLAS使用最优布局配置高出19.2%,比cuBLASLt启发式高出16.8%,比最具竞争力的cuBLASLt自动调优模型高出11.4%。在服务器模式下,加速比进一步提高。这表明通过大语言模型引导的强化学习自动化可改进HGEMM内核。
英文摘要:
In this paper, we propose CUDA-L2, a system that combines large language models (LLMs) and reinforcement learning (RL) to automatically optimize Half-precision General Matrix Multiply (HGEMM) CUDA kernels. Using CUDA execution speed as the RL reward, CUDA-L2 automatically optimizes HGEMM kernels across 1,000 configurations. CUDA-L2 systematically outperforms major matmul baselines to date, from the widely-used torch.matmul to state-of-the-art Nvidia's closed-source libraries, i.e., cuBLAS, cuBLASLt. In offline mode, where kernels are executed consecutively without time intervals, CUDA-L2 yields +22.0% over torch.matmul on average; +19.2% over cuBLAS using the optimal layout configuration (normal-normal NN and transposed-normal TN); +16.8% over cuBLASLt-heuristic, which queries cuBLASLt library and selects the algorithm based on the heuristic's suggestion; and +11.4% over the most competitive cuBLASLt-AutoTuning model, which selects the fastest algorithm from up to 100 candidates from cuBLASLt's suggestions. In server mode, where kernels are executed at random intervals simulating real-time inference, the speedups further increase to +28.7%, +26.0%, +22.4%, and +15.9% for torch.matmul, cuBLAS, cuBLASLt-heuristic, and cuBLASLt-AutoTuning respectively. CUDA-L2 shows that even the most performance-critical, heavily-optimized kernels like HGEMM can be improved through LLM-guided RL automation by systematically exploring configuration spaces at scales impractical for humans. Project and code can be found at github.com/ornith-ai/CUDA-L2
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。