[2026] CUDA Agent: When LLMs Outperform Compilers in GPU Kernel Optimization

CUDA Agent: Large-Scale Agentic RL for High-Performance CUDA Kernel Generation

Summary
Problem
Method
Results
Takeaways
Abstract

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:

  1. Data Scarcity: CUDA makes up <0.01% of the web.
  2. Brittleness: A single missing __syncthreads() leads to silent race conditions.
  3. Static Limitations: Compilers like torch.compile use 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.py to find bottlenecks.
  • Implement: Write .cu kernels and .cpp bindings.
  • Verify: Check numerical correctness + performance.
  • Iterate: Refine until it beats torch.compile by at least 5%.

Overall Architecture

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:

  1. Single-turn RL: Initial boost in CUDA knowledge.
  2. Rejection Fine-Tuning (RFT): Collecting high-quality agent trajectories to initialize the Actor.
  3. 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.

Metrictorch.compileClaude Opus 4.5CUDA Agent
Pass Rate (L3)-88.0%94.0%
Speedup (Geomean L2)1.0x1.60x2.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.

Performance Benchmarks

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 cudnnConvolutionBiasActivationForward to 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.

Find Similar Papers

Try Our Examples

  • Search for recent papers published after 2025 that use agentic reinforcement learning for low-level hardware code optimization beyond CUDA, such as Triton or ROCm.
  • Which study first introduced the concept of "Agent Skills" (as cited from Anthropic 2025), and how does integrating these skills into the prompt-space differ from traditional tool-calling in LLM agents?
  • Explore research applying multi-stage RL warm-up strategies, similar to CUDA Agent's RFT and Value Pretraining, to solve training collapse in other domain-specific long-context tasks like legal reasoning or complex mathematical proving.
Contents
[2026] CUDA Agent: When LLMs Outperform Compilers in GPU Kernel Optimization
1. TL;DR
2. Professional Motivation: The CUDA Expertise Gap
3. The Strategy: Agentic RL with "Stable" Foundations
3.1. 1. Scaling the Data (Combinatorial Synthesis)
3.2. 2. The Skill-Integrated Agent Loop
3.3. 3. Solving the Stability Problem
4. Experiments: Dominating KernelBench
4.1. Case Study: ResNet BasicBlock
5. Critical Analysis & Takeaways