← Latest papers
🤖 machine learning

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

The paper introduces CUDA-L2, a system that leverages large language models and reinforcement learning to automatically optimize Half-precision General Matrix Multiply (HGEMM) kernels, achieving significant performance gains over established baselines like torch.matmul, cuBLAS, and cuBLASLt by systematically exploring configuration spaces at scales impractical for human engineers.

Original authors: Songqiao Su, Xiaoya Li, Albert Wang, Guoyin Wang, Jiwei Li, Chris Shum

Published 2026-07-14
📖 5 min read🧠 Deep dive

Original authors: Songqiao Su, Xiaoya Li, Albert Wang, Guoyin Wang, Jiwei Li, Chris Shum

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to bake the perfect cake. For years, the world's best bakers (human experts) have been tweaking the recipe for a specific type of cake called "Matrix Multiplication." This cake is the secret ingredient in almost every modern AI brain. These bakers have spent years making it faster, but they hit a wall: every time the cake size changes (from a tiny cupcake to a massive wedding tier), they have to start from scratch, and the tricks that worked for one size often fail on another. It's like trying to use a tiny spoon to eat a giant soup; the tool just doesn't fit.

Enter CUDA-L2, a new team of "AI bakers" built by combining a super-smart language model with a video game-style learning system called Reinforcement Learning (RL). Instead of asking a human to guess the best recipe, CUDA-L2 plays a massive game of "try, fail, learn, and try again."

The Big Discovery: The AI Bakes Faster Cakes

The main finding of this paper is that CUDA-L2 can automatically design these matrix multiplication "recipes" (called kernels) and bake them faster than the best human-made recipes currently available.

The researchers tested this on 1,000 different cake sizes (combinations of dimensions M, N, and K ranging from 64 to 16,384). These sizes cover the exact dimensions used in famous open-source AI models like Qwen, Llama, and DeepSeek.

Here is how much faster the AI bakes compared to the current champions, measured on an A100 GPU:

  • Vs. The Standard Tool (torch.matmul): In a continuous baking session (offline mode), CUDA-L2 is 22.0% faster. In a busy kitchen where orders come in randomly (server mode), it's 28.7% faster.
  • Vs. The Gold Standard (cuBLAS): Even against NVIDIA's own highly optimized library, CUDA-L2 wins. It's 19.2% faster in continuous mode and 26.0% faster in the busy server mode.
  • Vs. The "Auto-Optimizer" (cuBLASLt-AutoTuning): This is the most important comparison. cuBLASLt-AutoTuning is a tool that tries up to 100 different recipes to find the best one. CUDA-L2 still beats it by 11.4% in continuous mode and 15.9% in server mode.

The paper is very sure about these numbers because they were measured directly by running the code thousands of times, not just guessed or simulated.

What the AI Did NOT Do

It is important to know what this system doesn't do. The paper explicitly states that the current version of CUDA-L2 is limited to the A100 architecture. However, the framework is designed for broad applicability, and the team is actively working to extend it to other GPU architectures, including older Ampere chips like the RTX 3090, as well as newer Hopper (e.g., H100) and Blackwell (e.g., B200) chips. The paper also argues against the idea that human experts have "solved" matrix multiplication; the fact that the AI found better recipes proves that human tuning is far from perfect.

How the AI Learned to Bake Better

The AI didn't just guess; it learned specific, clever tricks that even human experts might miss because they are too busy to check every single possibility.

  1. Padding the Cake: Imagine you have a cake that is 8,192 inches wide, but your baking pan only fits perfectly if the width is divisible by 160. 8,192 isn't divisible by 160. A human might say, "I'll use a pan size of 128 because it fits." But the AI said, "I'll add a tiny bit of extra batter (padding) to make the cake 8,320 inches wide so I can use the 160-inch pan." This tiny bit of extra work actually made the whole process faster.
  2. The Ping-Pong Strategy: Usually, a baker loads ingredients, mixes them, then loads the next batch. The AI figured out a "ping-pong" method: while the mixer is working on Batch A, the assistant is already loading ingredients for Batch B. This means the mixer never has to wait.
  3. The "Staggered" Delivery: Sometimes, the AI realized that asking for two ingredients at once (A and B) causes a traffic jam in the kitchen. Instead, it asked for ingredient A, started mixing, and then asked for ingredient B. This kept the kitchen moving smoothly.
  4. Choosing the Right Pan Size: The AI learned that for small cakes, small pans work best. But for giant cakes, it needs much larger pans. It figured out the perfect size for every single cake dimension, a task that would take a human a lifetime to calculate for 1,000 different sizes.

The "Server" vs. "Offline" Difference

The paper also noticed something interesting about the kitchen environment.

  • Offline Mode: Imagine a factory line where cakes are baked one after another without stopping. The oven stays hot, and the workers are in a rhythm. Here, the AI was 11.4% to 22.0% faster than the competition.
  • Server Mode: Imagine a busy restaurant where orders come in at random times. The oven might cool down between orders, and the workers have to warm up again. In this "real-world" chaos, the AI's advantage actually grew, beating the competition by 15.9% to 28.7%. The paper suggests this is because the AI's recipes are better at handling these "cold starts" and unpredictable pauses.

The Bottom Line

The paper concludes that even for the most critical, heavily optimized tasks like matrix multiplication, LLM-guided Reinforcement Learning can find better solutions than humans by exploring a space of possibilities that is too huge for a person to check. While this specific version of CUDA-L2 is currently limited to A100 GPUs, the framework is designed to be expanded to other chips in the future.

In short: The AI didn't just tweak the recipe; it discovered entirely new ways to bake the cake that humans hadn't thought of, proving that even in a field as mature as GPU optimization, there is still plenty of room for improvement.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →