Skip to main content

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

AuthorsWeinan Dai et al.
Year2026
FieldMachine Learning
arXiv2602.24286
PDFDownload
Categoriescs.LG, cs.AI

Abstract

GPU kernel optimization is fundamental to modern deep learning but remains a highly specialized task requiring deep hardware expertise. Despite strong performance in general programming, large language models (LLMs) remain uncompetitive with compiler-based systems such as torch.compile for CUDA kernel generation. Existing CUDA code generation approaches either rely on training-free refinement or fine-tune models within fixed multi-turn execution-feedback loops, but both paradigms fail to fundamentally improve the model's intrinsic CUDA optimization ability, resulting in limited performance gains. We present CUDA Agent, a large-scale agentic reinforcement learning system that develops CUDA kernel expertise through three components: a scalable data synthesis pipeline, a skill-augmented CUDA development environment with automated verification and profiling to provide reliable reward signals, and reinforcement learning algorithmic techniques enabling stable training. CUDA Agent achieves state-of-the-art results on KernelBench, delivering 100%, 100%, and 92% faster rate over torch.compile on KernelBench Level-1, Level-2, and Level-3 splits, outperforming the strongest proprietary models such as Claude Opus 4.5 and Gemini 3 Pro by about 40% on the hardest Level-3 setting.


Engineering Breakdown

Plain English

CUDA Agent tackles the problem that large language models are surprisingly bad at generating optimized GPU kernels compared to traditional compilers like torch.compile, despite excelling at general programming tasks. The paper presents a reinforcement learning system that trains models to develop genuine CUDA optimization expertise through three key components: a scalable data synthesis pipeline, skill-augmented training, and large-scale agentic RL. Rather than relying on static refinement or fixed multi-turn feedback loops that don't improve the model's underlying understanding, CUDA Agent learns to autonomously explore the CUDA optimization space and build transferable kernel expertise. This represents a fundamental shift from treating code generation as a supervised learning problem to treating it as a learned optimization task where the agent itself discovers better kernel implementations.

Core Technical Contribution

The core innovation is framing CUDA kernel generation as a large-scale agentic reinforcement learning problem rather than a supervised code generation task or rule-based refinement pipeline. The three-component system—scalable data synthesis, skill augmentation, and agentic RL—works together to let models develop intrinsic optimization ability instead of memorizing patterns from training data or applying hand-coded heuristics. This is fundamentally different from prior approaches because it allows the model to autonomously explore the vast space of valid CUDA implementations and learn which optimizations actually matter for performance on real hardware. The key insight is that CUDA optimization requires learned judgment about trade-offs (register pressure vs. memory bandwidth, block configuration vs. occupancy) that can only come from interactive experience, not passive pattern matching.

How It Works

The system operates in three stages that build on each other. First, the scalable data synthesis pipeline generates diverse CUDA kernel problems with ground-truth performance labels, creating a large corpus of training tasks without manual annotation. Second, the skill-augmented component equips the model with reusable optimization techniques—likely learned embeddings or sub-policies for common patterns like loop unrolling, memory coalescing, or thread block tiling. Third, the agentic RL loop lets the model act as an autonomous agent: it generates a kernel implementation, executes it on real GPU hardware or a simulator to measure performance, receives performance feedback as a reward signal, and uses RL to update its policy to generate better kernels on future problems. The agent can iteratively refine kernels, try multiple implementations, and learn which optimizations transfer across different kernel types, building genuine expertise rather than memorizing dataset patterns.

Production Impact

For engineers building deep learning frameworks or GPU-accelerated systems, CUDA Agent could dramatically reduce the need for manual kernel optimization and domain experts. Instead of hiring specialists to hand-optimize critical kernels or relying on compiler heuristics, you could use a trained agent to automatically generate near-optimal kernels for custom operations, significantly shortening the development cycle for new operators. The production pipeline would change from: define operation → wait for specialist → manually optimize → benchmark → iterate; to: define operation → run agent → get high-performance kernel in minutes. However, this introduces new costs: the agent requires access to real GPU hardware (or accurate simulators) for every inference iteration, meaning kernel generation latency increases from milliseconds to seconds or minutes depending on how many refinement steps the agent takes. You'd need robust evaluation infrastructure, fallback mechanisms if the agent produces suboptimal code, and careful integration to ensure the generated kernels are correct (not just fast).

Limitations and When Not to Use This

The paper assumes access to large-scale GPU compute for both training the RL system and running inference-time kernel generation, which is expensive and limits accessibility—smaller teams cannot easily replicate or deploy this approach. The method likely struggles with entirely novel kernel types that are far from training distribution, since RL agents tend to overfit to their training domain, and there's no guarantee the learned optimizations transfer to unseen hardware or CUDA versions. The abstract mentions three components but doesn't fully elaborate on the skill augmentation mechanism or how the system handles verification—there's a risk that the agent generates incorrect kernels that run fast but produce wrong results, and it's unclear how this is caught. Additionally, the agentic approach introduces non-determinism and potentially long generation times, which may be unacceptable for latency-sensitive scenarios where fast fallback to a compiler is needed, and the system's performance likely degrades gracefully as you move further from the training distribution.

Research Context

This work builds on a decade of research in neural program synthesis (GitHub Copilot, Codex) and more recent work applying RL to code generation (like REINFORCE-based policy optimization for programming tasks). It directly addresses documented limitations of LLMs on specialized low-level code—prior work showed GPT-3/GPT-4 struggle with CUDA compared to PyTorch's compiler optimizations, motivating the shift away from pure supervised learning. The paper likely benchmarks against torch.compile and other CUDA generation baselines (Tiramisu, Ansor, AutoTVM), aiming to close the performance gap between learned models and classical compiler optimization. This opens a research direction where expensive, specialized domains (kernel generation, circuit design, database query optimization) are attacked via large-scale RL rather than either pure supervision or hand-written heuristics, potentially enabling a new class of systems where learned agents beat human experts and traditional compilers.


:::tip Subscribe Get weekly breakdowns of papers like this in AI Letters - the newsletter for engineers building production AI systems. :::


Back to Research Lab → · Subscribe to AI Letters →

© 2026 EngineersOfAI. All rights reserved.