[2026] CUDA Agent: When LLMs Outperform Compilers in GPU Kernel Optimization
CUDA Agent: Large-Scale Agentic RL for High-Performance CUDA Kernel Generation
This paper introduces CUDA Agent, a large-scale agentic reinforcement learning (RL) system designed to automate the generation and optimization of high-performance CUDA kernels. By integrating a scalable data synthesis pipeline, a skill-augmented development environment, and stable RL training techniques, it achieves state-of-the-art results on KernelBench, outperforming torch.compile by up to 100% and surpassing top-tier proprietary models like Claude 4.5 and Gemini 3 Pro by 40% in complex tasks.
TL;DR
CUDA Agent is a breakthrough agentic system that uses large-scale Reinforcement Learning (RL) to master CUDA kernel optimization. By moving beyond simple "code completion" to an active "developer workflow" involving profiling and iterative debugging, it achieves nearly double the performance of torch.compile and crushes proprietary giants like Claude 4.5 and Gemini 3 Pro on the KernelBench benchmark.
Professional Motivation: The CUDA Expertise Gap
Modern deep learning sits atop a foundation of CUDA kernels, yet writing them is a "dark art" requiring deep knowledge of GPU microarchitecture (memory coalescing, occupancy, tiling). While LLMs are great at Python, they struggle with CUDA because:
- Data Scarcity: CUDA makes up <0.01% of the web.
- Brittleness: A single missing
__syncthreads()leads to silent race conditions. - Static Limitations: Compilers like
torch.compileuse fixed heuristics that often fail to find optimal fusion strategies for non-trivial operator sequences.
The Strategy: Agentic RL with "Stable" Foundations
The authors argue that we shouldn't just "fine-tune" a model on code; we must train an Agent to use tools.
1. Scaling the Data (Combinatorial Synthesis)
To feed the RL loop, the team built a pipeline that crawls PyTorch operators and uses LLMs to fuse them (e.g., stacking a Relu on a MatMul). This creates a complex optimization landscape where the agent must avoid global memory writes—something a simple "copy-paste" of kernels cannot solve.
2. The Skill-Integrated Agent Loop
Following the ReAct (Reason + Act) paradigm, the agent is equipped with a GPU sandbox. It doesn't just write code; it follows a SKILL.md protocol:
- Analyze: Run
profile.pyto find bottlenecks. - Implement: Write
.cukernels and.cppbindings. - Verify: Check numerical correctness + performance.
- Iterate: Refine until it beats
torch.compileby at least 5%.

3. Solving the Stability Problem
Most RL for code collapses because the "search space" of low-probability tokens is too noisy. CUDA Agent introduces a Multi-Stage Warm-up:
- Single-turn RL: Initial boost in CUDA knowledge.
- Rejection Fine-Tuning (RFT): Collecting high-quality agent trajectories to initialize the Actor.
- Value Pretraining: Training the Critic on trajectory outcomes before the main RL starts, preventing the agent from wandering into "infinite loops" of useless debugging.
Experiments: Dominating KernelBench
The results (Table 1) are a "wake-up call" for the compiler community.
| Metric | torch.compile | Claude Opus 4.5 | CUDA Agent |
|---|---|---|---|
| Pass Rate (L3) | - | 88.0% | 94.0% |
| Speedup (Geomean L2) | 1.0x | 1.60x | 2.80x |
| Faster Rate (L2) | - | 69.0% | 100.0% |
In Level 2 (sequentially fused operators), CUDA Agent achieved a 100% faster rate over torch.compile. It discovered hardware-specific tiling and memory access patterns that static compiler rules simply missed.

Case Study: ResNet BasicBlock
In a ResNet-style block (Level 3), the agent didn't just write a better kernel; it performed architectural surgery:
- BN Folding: It folded BatchNorm into the convolution weights in Python.
- Library Fusion: It leveraged
cudnnConvolutionBiasActivationForwardto minimize kernel launches. - Mixed Precision: It enabled TF32 on the fly for Tensor Core acceleration.
Critical Analysis & Takeaways
The core insight of this paper is that Expertise = Knowledge + Environment. By giving the model a profiler and a "reason-act" loop—and then using RL to optimize the entire interaction history—the model develops a "physical intuition" for GPU latency.
Limitations:
- Resource Intensive: Training requires a massive H20 GPU pool (128 units) with strict process isolation.
- Benchmark Breadth: While KernelBench is solid, how this translates to 1M+ line production codebases (like vLLM) remains an open engineering challenge.
Conclusion: CUDA Agent marks the transition from "LLM as a Co-pilot" to "LLM as a Systems Optimizer," proving that learned search policies can surpass human-coded compiler heuristics in high-stakes performance engineering.
