CUDA-L2: Leistungssteigerung gegenüber cuBLAS bei Matrixmultiplikation durch Reinforcement Learning
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
In diesem Beitrag stellen wir CUDA-L2 vor, ein System, das große Sprachmodelle (LLMs) und bestärkendes Lernen (RL) kombiniert, um Halbgenauigkeit-General-Matrix-Multiplikation (HGEMM) CUDA-Kernel automatisch zu optimieren. Indem es die CUDA-Ausführungsgeschwindigkeit als RL-Belohnung verwendet, optimiert CUDA-L2 HGEMM-Kernel automatisch über 1.000 Konfigurationen hinweg. CUDA-L2 übertrifft systematisch die wichtigsten Matmul-Baselines bis heute, von der weit verbreiteten {\it torch.matmul} bis hin zu state-of-the-art, quellgeschützten Bibliotheken von Nvidia, d.h. {\it cuBLAS} und {\it cuBLASLt}. Im Offline-Modus, bei dem Kernel ohne Zeitintervalle nacheinander ausgeführt werden, erzielt CUDA-L2 im Durchschnitt eine Steigerung von +22,0 % gegenüber {\it torch.matmul}; +19,2 % gegenüber {\it cuBLAS} unter Verwendung der optimalen Layout-Konfiguration (normal-normal NN und transponiert-normal TN); +16,8 % gegenüber {\it cuBLASLt-heuristic}, das die {\it cuBLASLt}-Bibliothek abfragt und den Algorithmus basierend auf der Heuristik-Auswahl wählt; und +11,4 % gegenüber dem wettbewerbsfähigsten {\it cuBLASLt-AutoTuning}-Modell, das den schnellsten Algorithmus aus bis zu 100 Kandidaten der {\it cuBLASLt}-Vorschläge auswählt. Im Server-Modus, bei dem Kernel in zufälligen Intervallen zur Simulation von Echtzeit-Inferenz ausgeführt werden, erhöhen sich die Beschleunigungen weiter auf +28,7 %, +26,0 %, +22,4 % bzw. +15,9 % für {\it torch.matmul}, {\it cuBLAS}, {\it cuBLASLt-heuristic} und {\it cuBLASLt-AutoTuning}. CUDA-L2 zeigt, dass selbst die leistungskritischsten, stark optimierten Kernel wie HGEMM durch LLM-gesteuerte RL-Automatisierung verbessert werden können, indem Konfigurationsräume in einem für Menschen unpraktikablen Umfang systematisch erkundet werden. Projekt und Code sind unter github.com/deepreinforce-ai/CUDA-L2 zu finden.
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