CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning

Songqiao Su, Xiaofei Sun, Xiaoya Li, Albert Wang, Jiwei Li +1 more
12/2/2025
cs.LGcs.AI

No official code found. Best implementation: deepreinforce-ai/CUDA-L2 (484 stars, MIT, last commit 2026-03-30). 1 more below.

Abstract

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/deepreinforce-ai/CUDA-L2

View on arXivView PDF

Code Implementations(2)

MIT

CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning

48433C++, CudaDec 2, 20256 months agoMIT
cublascuda-kernelslarge-language-modelsmatrix-multiplicationnvidia+1 more
MIT

CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning

00C++, CudaDec 18, 202510 months agoMIT

Similar Papers

Cite this paper

@article{su2025cudal,
  title  = {CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning},
  author = {Songqiao Su and Xiaofei Sun and Xiaoya Li and Albert Wang and Jiwei Li and Chris Shum},
  year   = {2025},
  eprint = {2512.02551},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2512.02551v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2512.02551.svg)](https://codeofpaper.com/paper/2512.02551)

Discussion