CUDA-L2 : Surpasser les performances de cuBLAS pour la multiplication matricielle grâce à l'apprentissage par renforcement
CUDA-L2: Surpassing cuBLAS Performance for Matrix Multiplication through Reinforcement Learning
December 2, 2025
papers.authors: Songqiao Su, Xiaofei Sun, Xiaoya Li, Albert Wang, Jiwei Li, Chris Shum
cs.AI
papers.abstract
Dans cet article, nous proposons CUDA-L2, un système qui combine les grands modèles de langage (LLM) et l'apprentissage par renforcement (RL) pour optimiser automatiquement les noyaux CUDA de multiplication matricielle générale en demi-précision (HGEMM). En utilisant la vitesse d'exécution CUDA comme récompense RL, CUDA-L2 optimise automatiquement les noyaux HGEMM sur 1 000 configurations. CUDA-L2 surpasse systématiquement les principaux benchmarks matmul actuels, du {\it torch.matmul} largement utilisé aux bibliothèques propriétaires de pointe de Nvidia, à savoir {\it cuBLAS} et {\it cuBLASLt}. En mode hors ligne, où les noyaux sont exécutés consécutivement sans intervalle de temps, CUDA-L2 offre un gain de performance moyen de +22,0 % par rapport à {\it torch.matmul} ; +19,2 % par rapport à {\it cuBLAS} utilisant la configuration de disposition optimale (normal-normal NN et transposé-normal TN) ; +16,8 % par rapport à {\it cuBLASLt-heuristic}, qui interroge la bibliothèque {\it cuBLASLt} et sélectionne l'algorithme basé sur la suggestion heuristique ; et +11,4 % par rapport au modèle {\it cuBLASLt-AutoTuning} le plus compétitif, qui sélectionne l'algorithme le plus rapide parmi jusqu'à 100 candidats suggérés par {\it cuBLASLt}. En mode serveur, où les noyaux sont exécutés à des intervalles aléatoires simulant l'inférence en temps réel, les accélérations augmentent encore pour atteindre respectivement +28,7 %, +26,0 %, +22,4 % et +15,9 % par rapport à {\it torch.matmul}, {\it cuBLAS}, {\it cuBLASLt-heuristic} et {\it cuBLASLt-AutoTuning}. CUDA-L2 démontre que même les noyaux les plus critiques en termes de performances et fortement optimisés comme HGEMM peuvent être améliorés grâce à l'automatisation RL guidée par LLM, en explorant systématiquement des espaces de configuration à des échelles impraticables pour les humains. Le projet et le code sont disponibles sur github.com/deepreinforce-ai/CUDA-L2.
English
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 {\it torch.matmul} to state-of-the-art Nvidia's closed-source libraries, i.e., {\it cuBLAS}, {\it cuBLASLt}. In offline mode, where kernels are executed consecutively without time intervals, CUDA-L2 yields +22.0\% over {\it torch.matmul} on average; +19.2\% over {\it cuBLAS} using the optimal layout configuration (normal-normal NN and transposed-normal TN); +16.8\% over {\it cuBLASLt-heuristic}, which queries {\it cuBLASLt} library and selects the algorithm based on the heuristic's suggestion; and +11.4\% over the most competitive {\it cuBLASLt-AutoTuning} model, which selects the fastest algorithm from up to 100 candidates from {\it 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 {\it torch.matmul}, {\it cuBLAS}, {\it cuBLASLt-heuristic}, and {\it 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