Elamur Research

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

Paper · 2026 · Weinan Dai, Hanlin Wu, Qiying Yu et al.

Summary

A PyTorch program specifies what to compute. Its GPU implementation determines how much work that computation takes, where the data moves, and how long the result takes to produce. A compiler such as torch.compile can improve the implementation automatically. There is often further room for improvement, especially when several operations can share work or avoid writing an intermediate result to memory. CUDA Agent asks whether a coding agent can learn to find those opportunities by developing and testing CUDA implementations inside a GPU workspace.

The authors build a training set of 6,000 PyTorch tasks by collecting existing operators and composing some of them into new sequences. The reference programs supply expected outputs, so the authors can train on a task without first commissioning an expert CUDA solution for it. In the workspace, the agent can inspect the reference, edit source files, compile its implementation, check numerical results, and profile execution. Training rewards distinguish incorrect submissions, correct submissions, and correct submissions that clear performance milestones against PyTorch. The authors prepare the agent for long interactions by first training it to generate CUDA in a single response, then using recorded workspace sessions to initialize both the policy that takes actions and the critic that estimates their value.

The main results table gives CUDA Agent a 98.8% Pass Rate across KernelBench and a 96.8% Faster Rate against torch.compile. The latter measures how frequently a task yields a correct implementation that beats the compiler under the benchmark protocol. Among correct solutions, the geometric mean speed-up against the compiler is 2.11×. On Level 2, which contains operator sequences, the Faster Rate against the compiler is 100.0% and the geometric mean speed-up among correct solutions is 2.80×. On Level 3, the hardest split, the main table reports a 90.0% Faster Rate against the compiler. Gemini 3 Pro reaches 52.0% there and Claude Opus 4.5 reaches 50.0% under the same workspace procedure.

The examples show why performance can improve. In one task, CUDA Agent recognizes that multiplying by a diagonal matrix amounts to scaling rows and eliminates the construction of the matrix. In a residual neural-network block, it combines some operations in custom CUDA and delegates others to a tuned library routine. The ablations also distinguish two kinds of progress. Direct generation can produce correct code on many tasks, while interactive training and a milestone-based reward are associated with much more consistent gains in latency. The reported gains concern the implementation selected from each session on the evaluation hardware. The experiments leave open how those gains carry over to other GPUs, workloads, and compiler systems.

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

CUDA Agent learns to write and tune GPU kernels through execution feedback, then tests their correctness and speed against PyTorch on KernelBench. · about 33 minutes to read

The problem and its context

Why a correct kernel can still be slow

A GPU kernel is a function that runs on a graphics processor. In GPU & parallel computing, much of the engineering concerns dividing work among threads and arranging data so those threads can retrieve it efficiently. Two implementations of a tensor operation can return numerically equivalent results while making very different demands on the hardware. One may repeatedly fetch values from global memory. Another may arrange for threads to reuse those values in faster storage. The speed difference depends on how the computation is mapped to the device.

Consider a sequence in which an early operation produces a tensor that a later operation consumes immediately. A straightforward implementation can launch a kernel for the first operation, write the tensor to global memory, and launch another kernel to read it. Kernel fusion combines work from the operations in a shared implementation. It can eliminate that intermediate write and read, along with a separate launch. Fusion also creates new engineering choices. The two stages must share a plan for assigning work to threads, and the storage used by either stage can affect how much work runs concurrently. An efficient implementation of each operation on its own therefore gives limited guidance about the best combined implementation.

The paper treats this as a problem of Code & programming languages in which the specification and the objective are expressed through different evidence. The PyTorch reference tells the agent what output to reproduce. The profiler measures how long the generated implementation takes. Reading the source can expose an opportunity, such as a tensor that need never be built. Only compiling and running the candidate can establish whether the resulting implementation is valid and faster under the test conditions. The authors want the agent to learn how to use that evidence over a sequence of decisions.

torch.compile is an important comparison because it already performs automatic optimization. Beating ordinary PyTorch execution can show that there was overhead to remove. Beating the compiled version asks whether the agent can find additional savings on the same task. The authors argue that general programming ability gives a weak indication of how well a system will do on this narrower problem. CUDA optimization calls for attention to features such as launch overhead, memory access, and the amount of work that can proceed in parallel. A candidate can be well formed and functionally correct while doing poorly on all of them.

How earlier systems searched or learned

One line of work described by the authors improves candidates at test time using a prescribed search procedure. STARK assigns planning, coding, and debugging to separate agents that explore a tree of possible fixes and optimizations. ReGraphT organizes earlier optimization traces as a graph and searches it to guide a smaller system. EvoEngineer uses repeated code edits and validation in an evolutionary search. CudaForge gives a profiling agent access to hardware information and has it relay diagnoses to a coding agent. These methods differ in how they organize attempts, but all make execution feedback part of the development process. The CUDA Agent authors regard such search procedures as potentially complementary to a policy trained for the domain.

The other line of work changes the generator through fine-tuning. Kevin trains with reinforcement learning over several rounds of CUDA development and reports improvements over its starting system. Its procedure provides an example of learning from iterations involving generated code and execution. CUDA-L1 uses execution-based rewards to compare candidate implementations in a contrastive training procedure. ConCuR assembles generated kernels and reasoning traces for supervised training of KernelCoder. The authors identify limited data and predetermined refinement procedures as constraints on this family of approaches. In particular, they argue that repeatedly feeding prior solutions back into a fixed loop uses context that a file-based agent can devote to inspecting code, interpreting diagnostics, and deciding what to try next. Kevin · CUDA-L1

Data provenance matters in these comparisons. The paper describes Kevin as training on a subset of KernelBench and evaluating on a separate subset of that benchmark. It describes CUDA-L1 as using benchmark tasks in both training and evaluation. ConCuR’s generated training examples come from a Kevin system that was itself exposed to a KernelBench subset. The authors design a separate training collection so that their benchmark can ask how well the resulting policy handles tasks outside that collection. Their overlap check addresses the similarity of reference code, a specific criterion discussed below.

There are also differences in the scope of the earlier experiments. The authors say that EvoEngineer evaluates on 91 problems drawn from the 250 tasks in KernelBench and that STARK leaves its timing hardware unspecified. They describe ReGraphT as primarily studying how to transfer expertise to a smaller system. STARK and CudaForge also prescribe agent roles and control flow, whereas CUDA Agent uses a single policy to decide when to inspect, edit, compile, or profile. These differences shape the question addressed by CUDA Agent’s main experiment. It compares coding systems inside a common workspace, where each has access to the same basic feedback and must decide how to use it.

KernelBench supplies the common set of reference computations. Its role belongs to Evaluation & benchmarks, but its tasks are also executable programs. That gives the benchmark two forms of evidence about each candidate. The reference can produce outputs for a correctness check, and the reference execution paths can provide timings for comparison. The paper adapts those tasks to the same style of workspace used in training. KernelBench

The method, step by step

From a reference program to a training signal

Each task starts with a PyTorch implementation of an operation, a sequence of operations, or a more substantial module. The agent can inspect the reference and measure its latency. It then writes a replacement that calls CUDA code through a Python-facing extension. Compilation is the first test of whether those pieces fit together. A numerical check tests whether the implementation reproduces the reference outputs. Profiling supplies the latency comparison once there is a candidate worth timing. The agent can use each result to decide which part of the code to revisit.

The task construction, workspace, and training procedure serve different purposes. Task construction supplies computations that are executable and sufficiently varied to optimize. The workspace turns the effects of code edits into observations. The training procedure increases the likelihood of actions associated with a successful outcome and prepares the agent to operate over long sessions. The paper joins these pieces in the following sequence.

How CUDA Agent prepares tasks and learns from execution

The steps in order.

How CUDA Agent prepares tasks and learns from executionStep 1: Collect executable PyTorch operators1. Collect executable PyTorch operatorsStep 2: Compose operators and filter training tasks2. Compose operators and filter training tasksStep 3: Warm up with single-response CUDA generation3. Warm up with single-response CUDA generationStep 4: Record interactive CUDA development sessions4. Record interactive CUDA development sessionsStep 5: Initialize the policy and critic from sessions5. Initialize the policy and critic from sessionsStep 6: Train through compilation, verification, and profiling6. Train through compilation, verification, and profilingStep 7: Select the fastest candidate relative to torch.compile7. Select the fastest candidate relative to torch.compile

Building the training tasks

The authors start from operators implemented in the torch and transformers libraries. They choose these sources for the quality and maintenance of the underlying code. A task represents its reference computation as a subclass of torch.nn.Module. The initialization method sets up the parameters and other state the computation needs. The forward method defines what happens when the operator receives its runtime inputs. Companion functions supply inputs for constructing the module and running it. This format gives the environment enough information to instantiate the reference and execute it independently.

The synthesis stage combines operators from torch. A generator chooses up to 5 operator classes and arranges them in sequence in a single layer. It uses modules from transformers as standalone tasks because those modules already tend to combine several operations. The point of generating sequences is to create dependencies between stages. If a sequence hands a large tensor from one stage to another, the best replacement may change how both stages are executed. Training on the constituent operations independently would give the agent fewer occasions to discover such a change.

The filters target practical properties of a training task. The reference has to run in both PyTorch Eager, the ordinary execution path, and PyTorch Compile, the path through torch.compile. The authors remove inherently stochastic operators so the reference supplies a reproducible target. They also test whether distinct inputs lead to meaningfully distinct outputs. If the outputs are constant or numerically indistinguishable, a candidate could appear correct while reproducing little of the intended computation. Finally, the Eager runtime must fall in the range from 1 ms to 100 ms. That filter removes tasks the authors consider too slight or too expensive for this collection.

The authors check each training reference against KernelBench using PythonASTSimilarity. An abstract syntax tree, or AST, describes a program’s syntactic structure. The comparison uses the class that defines the reference computation. For each training sample, the authors take the highest similarity score against any evaluation sample and remove the training sample when that score exceeds 0.9. They report that most of the remaining programs have low maximum similarity and that all are within the cutoff. The check is useful for catching structurally similar reference implementations. Two programs can still express related computations through different syntax.

The resulting dataset, CUDA-Agent-Ops-6K, contains 6,000 samples. Its distribution makes clear what kind of practice dominates. Pairs of torch operators account for 83.77% of the final dataset. Compositions of three account for 7.62%, and single torch operators account for 3.40%. Compositions of four and five account for 2.80% and 1.23%, respectively. Standalone transformers operators account for 1.18%. The collection therefore gives the agent frequent opportunities to optimize across one boundary between operators, with less frequent practice on longer sequences and higher-level modules.

Developing in a workspace

The interaction is organized around files that persist as the session proceeds. The reference is in model.py. The agent writes the replacement module in model_new.py and puts implementation and binding files in the kernel directory. Bindings connect the Python-facing operator to the CUDA implementation. Keeping code in files allows the agent to inspect the current version and make a targeted edit after a failed test. It can compile, modify, and rerun that version as its understanding of the problem changes.

The authors align the workspace with the coding-agent framework described by OpenHands. The local interfaces include shell execution, file discovery and search, file reading, and editing. The agent can observe output from a running process and stop it if needed. The design combines these capabilities with a loop inspired by ReAct. In that loop, the policy considers the current state, takes an action, receives an observation, and uses the observation to decide what to do next. A compiler error invites an inspection of the affected source or binding. A successful build followed by a numerical discrepancy points to the computation. A correct candidate with disappointing latency calls for a different investigation.

CUDA-specific guidance lives in a skill file called SKILL.md. It tells the agent to examine the native PyTorch execution, identify expensive work, implement a replacement, and develop it through repeated checks. It also documents what the workspace permits. Custom CUDA, cuBLAS for general matrix multiplication, and cuDNN for convolution are among the permitted implementations. The instructions direct the agent to use cuDNN for convolution and transposed convolution, and constrain Python in the replacement to tasks such as creating tensors, inspecting their properties, and calling the extension. The reference and shared evaluation infrastructure sit outside the intended edit area.

The skill gives optimization a sequence of priorities. Changes that remove a computation or cut memory traffic come early. Tuning how threads load data or how much work runs concurrently comes later. The appendix illustrates how an implementation can expose a launch configuration through its binding so that the agent can compare configurations without recompiling for each one. The instructions also ask the agent to continue improving a correct version after it reaches the target of 5% lower latency than torch.compile. The workspace supplies the measurement, while the policy decides which proposed improvements are worth trying.

The environment separates CPU work from GPU measurement. A Docker terminal environment handles work such as compiling source. Verification and profiling requests go to a pool of 128 NVIDIA H20 GPUs. The authors allocate GPU resources exclusively for these jobs and use process isolation to limit interference, including contention for high-bandwidth device memory. This separation is important because timings influence learning. If independent jobs competed with the kernel being measured, a latency change could reflect the machine’s other work as easily as the agent’s edit.

The authors also protect the scripts that produce correctness and performance feedback. File permissions restrict edits to the evaluator, and runtime checks forbid fallbacks through torch.nn.functional. Each correctness check compares outputs on five randomly drawn inputs. The skill specifies absolute and relative tolerances of 1e-2. The profiler warms up execution, synchronizes the device, and averages repeated measurements. Synchronization matters because work submitted to a GPU may continue after the host call returns. The timings need to reflect that work rather than just the host’s act of submitting it. The environment also confines the agent’s information gathering to local resources.

Turning correctness and speed into a reward

The authors want the reward to encourage improvements across tasks with different amounts of room for optimization. A raw speed ratio gives especially large credit to any task where the reference is slow and an easy shortcut exists. It can also amplify a favorable timing fluctuation. CUDA Agent uses a milestone-based reward. It first tests correctness and then checks whether the runtime improvement over each baseline exceeds a meaningful margin.

b(t, t₀) = 𝟙[(t₀ − t) / t₀ > 5%]

Here t is the candidate’s measured runtime and t₀ is the baseline’s measured runtime. The difference t₀ − t is the latency saved, and division by t₀ expresses it relative to the baseline. The indicator 𝟙 makes b true when the condition inside the brackets holds. The inequality is strict, so the reward test asks for an improvement greater than 5%.

r = ⎧ −1   if correctness fails
    ⎪  3   if b(t, tₑₐgₑᵣ) ∧ b(t, t꜀ₒₘₚᵢₗₑ)
    ⎨  2   if b(t, tₑₐgₑᵣ) and the preceding case does not apply
    ⎩  1   otherwise

The symbol r is the reward for the tested outcome. The eager subscript refers to ordinary PyTorch execution, and the compile subscript refers to execution through torch.compile. The conjunction ∧ requires both comparisons to clear the margin. The cases are applied in order. A failure receives −1. A correct result that clears both margins receives 3, and a correct result that clears only the Eager margin receives 2. All other correct results receive 1. The formula makes the Eager milestone a condition of the highest reward, regardless of the ordering of the measured baseline times on a particular task.

This scoring rule gives the same credit to any correct result that has already cleared both milestones. A much larger latency reduction on one task therefore cannot overwhelm the contribution of successful results on other tasks. It also means the policy receives the same reward for distinct timings within a band. The skill can still ask the agent to push for the fastest implementation it finds. At evaluation, candidate selection uses the measured speed-up against the compiler, which distinguishes implementations within a reward band.

Preparing the agent for long sessions

A policy specifies the probabilities of the agent’s next actions. Here those actions are generated tokens, which can form text, code, or a tool call. The critic predicts how valuable it is to be in the state associated with a token position. This helps training assign credit before the final test result arrives. Long development sessions can contain many actions whose importance becomes apparent only when a later compilation succeeds, a test passes, or a timed run improves.

The authors trace an initial training collapse to a large difference between general pretraining and the specialized CUDA tasks they need the policy to solve. They cite estimates putting CUDA code at less than 0.01% of pretraining data. In their account, the starting policy can assign very small probabilities to the tokens it generates for CUDA work. Differences between numerical formats used during rollout generation and during training, such as BF16 and FP16, can then matter. When an action probability is near the numerical precision floor, a small discrepancy can cause a large relative change. The same issue arises for the ratio used to weight actions when updating the policy. The paper gives a token probability of approximately 10⁻⁹ as an illustration of the regime it has in mind.

The first warm-up stage uses proximal policy optimization, or PPO, in a single-response setting. The starting system provides the policy and the value network. It learns to emit the kernel and its supporting code directly. This stage gives the policy practice with CUDA code before it has to produce valid tool actions and respond to a changing workspace. The authors then run the warmed-up policy interactively and record its development trajectories. A trajectory is a sequence of states and actions from one attempt at a task, together with the outcome used for training.

The policy initialization uses rejection fine-tuning, or RFT. The authors keep trajectories with outcome reward R > 0, where R is the reward assigned to the trajectory. They also screen the action pattern. Sessions with redundant loops or tool calls that violate the required format can be discarded even if the outcome is positive. The resulting collection serves as supervised data for learning which actions to generate in a given state.

Lᴿᶠᵀ(θ) = −𝔼τ∼D′[Σₜ₌₁ᵀ log πθ(aₜ | sₜ, a₍<ₜ₎)]

Lᴿᶠᵀ is the loss minimized during rejection fine-tuning, and θ denotes the policy parameters. The expectation 𝔼τ∼D′ averages over trajectories τ from the filtered dataset D′. The sum visits the T positions indexed by t. At each position, πθ gives the probability of the recorded action aₜ conditioned on the state sₜ and the earlier actions a₍<ₜ₎. The bar denotes conditioning, and log takes the logarithm of that probability. Minimizing the negative sum increases the probability of the recorded actions. The paper writes this sum with positions starting at 1. Its value and PPO equations below index states from 0 through T − 1.

The critic is prepared through value pretraining. The recorded sessions give it a sequence of states and an outcome. The paper assigns the outcome reward to the last token and uses zero immediate reward at earlier positions.

rₜ = ⎧ 0   for t < T − 1
     ⎩ r   for t = T − 1

Here rₜ is the immediate reward associated with position t, T is the trajectory length in token positions, and r is the final outcome reward. The assignment delays the reward until the outcome is known. A value estimate at an earlier position concerns the prospective outcome given that state.

Estimating the value of an action

The paper uses generalized advantage estimation to construct targets for critic pretraining and advantages for PPO. The calculation starts with a temporal difference error. This compares the value predicted at the current position with the immediate reward plus the estimated value at the next position.

δₜ = rₜ + γVϕ(sₜ₊₁) − Vϕ(sₜ)

δₜ is the temporal difference error at position t. Vϕ is the critic with parameters ϕ. Its arguments sₜ and sₜ₊₁ are the current state and the succeeding state. The immediate reward is rₜ, and γ is the discount applied when carrying the next estimate back to the current position. The authors set γ = 1, so this parameter leaves the next estimate undiscounted.

Vϕ(sₜ) = 0  when t = T

The state sₜ at t = T is the terminal state after the last token position. Its value is set to 0, so that the final temporal difference uses the actual outcome reward and the prediction just before termination.

Âₜ = Σₗ₌₀^(T − 1 − t) (γλ)ˡ δₜ₊ₗ

Âₜ is the estimated advantage at position t. The summation uses the offset l, beginning at 0 and ending at T − 1 − t. Each term uses the temporal difference error δₜ₊ₗ from that many positions ahead. The power l tells how often the combined factor γλ is applied. The parameter λ controls the decay of more distant errors, and the paper sets λ = 0.95. The estimate thus uses the succession of value corrections through the end of the session, while giving a distant correction less direct weight.

Vₜᵗᵃʳᵍ = Vϕ(sₜ) + Âₜ

Vₜᵗᵃʳᵍ is the training target for the value at position t. It adds the estimated advantage Âₜ to the critic’s value Vϕ(sₜ) at that state. The target uses the observed trajectory to adjust the prediction. This lets a session with a reward only at the end supply targets at earlier positions.

Lⱽᴾ(ϕ) = 𝔼τ∼D[(1 / 2)(1 / T) Σₜ₌₀^(T − 1) (Vϕ(sₜ) − Vₜᵗᵃʳᵍ)²]

Lⱽᴾ is the value-pretraining loss. The expectation averages over trajectories τ in the sampled collection D. At each position t, the critic prediction Vϕ(sₜ) is compared with the target Vₜᵗᵃʳᵍ. The superscript ² squares the error, and the factor 1 / T averages those errors across the trajectory’s token positions. The factor 1 / 2 scales the loss. Minimization adjusts the critic parameters ϕ to bring predictions towards the targets.

Policy and critic initialization use the recorded sessions for different learning problems. The rejection fine-tuning stage sees selected actions to imitate. The critic sees states and outcome-derived targets from the trajectory collection. It learns to predict the prospect of a useful outcome before one is known. An agent can start a session with well-formed actions and still use its time poorly. Conversely, an informative value estimate alone cannot teach the agent the syntax of an edit or compilation request. The two initializations address these different demands before interactive PPO resumes.

Updating the policy during interactive training

PPO uses trajectories sampled under an earlier version of the policy to update the current one. It compares how probable the recorded action is under the current and sampling policies.

ρₜ(θ) = πθ(aₜ | sₜ) / πθₒₗ𝒹(aₜ | sₜ)

ρₜ(θ) is the importance sampling ratio at position t. The numerator gives the probability assigned to action aₜ in state sₜ by the current policy with parameters θ. The denominator uses the policy with parameters θₒₗ𝒹, which generated the trajectory. The ratio expresses how much more or less probable that action is after the parameter change. An extremely small denominator can make this ratio sensitive to the numerical discrepancies that motivated the warm-up.

Lᶜˡⁱᵖ(θ) = 𝔼τ∼D[(1 / T) Σₜ₌₀^(T − 1) min(ρₜ(θ) Âₜ, clip(ρₜ(θ), 1 − εₗₒwₑᵣ, 1 + εₕᵢgₕₑᵣ) Âₜ)]

Lᶜˡⁱᵖ is the clipped objective the actor maximizes. The expectation is over trajectories τ from D, the collection used for the update, and 1 / T averages over their token positions. At each position, ρₜ(θ) weights the estimated advantage Âₜ. The clip function bounds the ratio between 1 − εₗₒwₑᵣ and 1 + εₕᵢgₕₑᵣ. The min function chooses the smaller of the terms made with the original and bounded ratios. This limits the incentive to change an action’s probability too far in the direction that improves the objective. The lower tolerance is 0.2 and the upper tolerance is 0.28, a choice attributed to DAPO.

Seed1.6 is the starting system. Its mixture-of-experts architecture has 230B total parameters and 23B active parameters. The distinction reflects the fact that only some of the available expert parameters are used for a given input. The global batch size and the online PPO mini-batch size are both 1024. The actor learning rate is 3 × 10⁻⁶ and the critic learning rate is 6 × 10⁻⁶. The paper uses these batch and learning-rate settings for both the single-response and interactive reinforcement learning stages.

The context window grows from 32,768 tokens during single-response training to 131,072 tokens during interactive training. A training rollout can use up to 150 agent turns, and the evaluation allowance is 200 turns. A turn is part of an individual workspace session. An optimization step updates the training parameters from sampled work. The experiment settings describe a run of 150 training steps. The stability discussion separately describes a warmed-up trial that remained stable for 200 steps, compared with an initial trial that collapsed after 17 steps. The longer trial concerns how long the procedure can sustain learning. The results are presented under the paper’s stated experiment settings.

Experiments and results

What is measured

KernelBench contributes 250 evaluation tasks. Level 1 contains 100, Level 2 contains 100, and Level 3 contains 50. The levels range from individual operators to operator sequences and larger blocks. The authors convert the original single-file tasks into their multi-file development format, so comparison systems work through the same kind of reference, editing, verification, and profiling interface.

The main comparison includes the starting policy, Seed1.6. It also includes GLM 4.6 and Kimi K2 as open baselines, with Gemini 3 Pro and Claude Opus 4.5 as proprietary baselines. All are evaluated in the common agent loop. The comparison with Seed1.6 addresses the effect of specialization within this setup. The comparison with the other coding systems asks how well broadly capable competitors can use the same workspace for CUDA development. The paper cites Kimi K2 in describing its baselines.

The evaluation gives each task the best-performing solution found in the trajectory, with performance ranked against torch.compile. Pass Rate is the share of tasks for which a generated solution compiles and passes the functional checks. Faster Rate includes correctness as a requirement and measures the share of all tasks with a correct solution that runs faster than the specified baseline. There is one comparison against Eager execution and another against Compile execution. The benchmark’s metric definition says the solution must be faster. The training reward separately uses its stricter 5% milestone.

Geometric mean speed-up summarizes runtime ratios among correct solutions. A ratio above unity means the implementation runs faster than its baseline. Ratios are combined multiplicatively, so the geometric mean describes a typical factor of improvement within the population of correct outputs. Each system can have a different population of correct outputs. Pass Rate and Faster Rate give information that the geometric mean alone leaves out, including the share of tasks for which the agent obtained a usable result at all. The paper reports overall metrics weighted by the number of tasks at each level.

Results across the benchmark

Overall Faster Rate against torch.compile on KernelBench

CUDA Agent produces correct implementations that beat the compiler on a larger share of tasks than any comparison system.

Overall Faster Rate against torch.compile on KernelBenchGLM 4.6: 19.2GLM 4.619.2Kimi K2: 22.8Kimi K222.8Seed1.6: 27.2Seed1.627.2Claude Opus 4.5: 66.4Claude Opus 4.566.4Gemini 3 Pro: 69.6Gemini 3 Pro69.6CUDA Agent (this paper): 96.8CUDA Agent (this paper)96.8
The numbers
System or setting%
GLM 4.619.2
Kimi K222.8
Seed1.627.2
Claude Opus 4.566.4
Gemini 3 Pro69.6
CUDA Agent (this paper)96.8

CUDA Agent passes 98.8% of the overall tasks and is faster than Eager on 98.4%. It reaches a 96.8% Faster Rate against Compile. On correct solutions, its geometric mean speed-ups are 2.60× against Eager and 2.11× against Compile. Taken together, these measurements show broad coverage as well as a substantial magnitude of improvement on the programs that pass.

Seed1.6 passes 74.0% overall under the same agent-loop evaluation. Its Faster Rates are 43.6% against Eager and 27.2% against Compile. Its geometric means among correct solutions are 0.95× and 0.69× against those respective baselines. The shared workspace therefore gives the starting policy enough information to finish many tasks correctly, yet its typical correct solution is still slower than either reference path in the aggregate. The gap between its pass rate and compiler Faster Rate also shows how much room there is to improve after achieving numerical correctness.

Claude Opus 4.5 has a 95.2% overall Pass Rate, with geometric mean speed-ups of 1.99× against Eager and 1.46× against Compile. Gemini 3 Pro has a 91.2% Pass Rate, with corresponding speed-ups of 1.92× and 1.42×. Their Eager Faster Rates are 90.4% and 87.6%, respectively. Gemini 3 Pro wins on a larger share of tasks against Compile, as the chart shows. The order can change with the metric because the share of workloads that cross a baseline and the size of the gain among passing workloads describe different aspects of performance.

What changes with task complexity

CUDA Agent Faster Rate against torch.compile by KernelBench level

CUDA Agent beats the compiler most consistently on operator sequences and still does so on most larger-block tasks.

CUDA Agent Faster Rate against torch.compile by KernelBench levelLevel 1, individual operators: 97.0Level 1, individual operators97.0Level 2, operator sequences (this paper): 100.0Level 2, operator sequences (this paper)100.0Level 3, larger blocks: 90.0Level 3, larger blocks90.0
The numbers
System or setting%
Level 1, individual operators97.0
Level 2, operator sequences (this paper)100.0
Level 3, larger blocks90.0

On Level 1, CUDA Agent passes 100.0% of tasks, and its Faster Rate against Eager is 99.0%. The corresponding geometric mean factors among correct outputs are 2.48× against Eager and 1.87× against Compile. Its 97.0% Faster Rate against Compile shows that the compiler remains competitive on some individual operations even when the agent solves all of them correctly. The proprietary baselines both reach 72.0% on the Compile Faster Rate for this split. Their geometric mean speed-ups against Compile are 1.51× for Gemini 3 Pro and 1.54× for Claude Opus 4.5.

Level 2 is the strongest split for CUDA Agent’s compiler comparison. Pass Rate and both Faster Rates are 100.0%. The geometric mean speed-up among correct outputs is 3.27× against Eager and 2.80× against Compile. Gemini 3 Pro attains a 76.0% Faster Rate against Compile, and Claude Opus 4.5 attains 69.0%. Their geometric means against the compiler are 1.46× and 1.60×, respectively. The authors connect CUDA Agent’s results on this split to operator fusion and to a search over tiling and memory layouts. The aggregate outcomes establish that the trained agent performs particularly well on these sequences. The case trajectories give concrete instances of the transformations behind some of the wins.

On Level 3, CUDA Agent achieves a 94.0% Pass Rate and a 94.0% Faster Rate against Eager. The geometric mean factors among its correct solutions are 1.80× against Eager and 1.52× against Compile. Gemini 3 Pro passes 80.0% and beats Compile on 52.0% of the split. Claude Opus 4.5 passes 88.0% and beats Compile on 50.0%. Their geometric means against Compile are 1.17× and 1.10×, respectively. The split shows that a system can have a higher Pass Rate and still win on fewer tasks against the compiler. Correct implementations vary in how much they improve the baseline.

The abstract and main table report different level-wise Faster Rates against Compile. The abstract gives 100%, 100%, and 92% for Levels 1, 2, and 3. The detailed table gives 97.0%, 100.0%, and 90.0%. The paper supplies no reconciliation of these figures. The split comparisons here use the table, which identifies the metric, baseline, and subset for each value.

What the agent changes in individual programs

A Level 1 case begins with a vector turned into a diagonal matrix, followed by multiplication with a dense matrix. Every entry off the diagonal is zero. For any output row, only the matching input row contributes, scaled by the corresponding entry in the vector. The agent therefore implements row scaling directly. The resulting kernel uses a grid-stride traversal, in which a thread can process more output elements at intervals determined by the total number of threads. Each output is computed independently, with no dense diagonal tensor to build.

O(N²M) → O(NM)

This is the change in computational complexity the authors give for the diagonal multiplication case. O describes how the amount of work grows with the input dimensions. N is the size of the diagonal matrix and the number of rows of the dense input, and M is the number of columns of that input. The exponent ² represents the extra factor of N in the dense multiplication. The arrow shows the move to work that scales with the number of output elements. The paper measures a 73.31× speed-up against Compile for this particular Level 1 task.

The Level 2 example combines matrix multiplication, division, summation, and scaling. Its central opportunity is to move the summation from the outputs of the matrix multiplication to the weights used in that multiplication. Each input row can then interact with a smaller, pre-reduced representation of the weights. The authors express the rearrangement as follows.

Σⱼ (xᵢ · wⱼᵀ) / 2 = xᵢ · (Σⱼ wⱼᵀ) / 2

xᵢ is input row i, and wⱼ is the weight vector indexed by j. The superscript ᵀ denotes a transpose, and the dot denotes the dot product. The summation Σⱼ ranges over the weight vectors. The divisor 2 is the factor shown in the paper’s rearrangement. On the left, the computation forms a dot product for each weight vector and sums the resulting values. On the right, the vectors are summed first, leaving a dot product with their aggregate. The identity follows from linearity. Numerical verification determines whether the reordered floating-point computation remains within tolerance.

The implementation uses a kernel to sum the weights by column and a second kernel to compute the dot product with the reduced weights and apply the remaining arithmetic. The first kernel arranges neighboring accesses so they can be handled together. The second uses float4 loads to read several values at once and uses shared memory to combine contributions within a block of threads. It can perform the division and scaling before writing the result to global memory. The paper reports a 24.04× speed-up against Compile on this Level 2 example. The example joins a change in the amount of work with a change in the way the remaining work moves through the GPU.

The Level 3 case is a ResNet BasicBlock. The reference contains convolution, normalization, activation, and a residual path that adds a shortcut contribution to the block output. The first change folds the inference-time batch-normalization parameters into the convolution’s weights and bias. The convolution can then produce the appropriately adjusted values with no separate normalization stage. A cuDNN call combines convolution, bias, and a rectified linear activation. CUDA Agent also uses a custom kernel to combine the residual addition with the final activation.

The block illustrates how profiling can reverse an otherwise plausible decision. CUDA Agent explores changing the tensor layout from NCHW to NHWC, which places the channel dimension in a different position in memory. Layout changes can help match a hardware execution path, but the conversions in this attempt take enough time to offset the expected benefits. The selected implementation retains NCHW and uses compatible cuDNN routines. The case also uses TF32 to make use of Tensor Cores for convolution and matrix multiplication. The final implementation attains a 3.59× speed-up against Compile on that Level 3 task. The result belongs to the combination of changes in the selected version, which includes library routines as well as generated CUDA.

What the ablations show

The effect of interactive development

The first comparison starts from the single-response policy used in warm-up. It produces the kernel and bindings directly from the task. The complete system can observe compilation, numerical checks, and profiling during development and has been trained to act in that setting. The ablation therefore measures the combined effect of adding interactive training and using an interactive procedure at evaluation.

Overall KernelBench Faster Rate against torch.compile in the ablations

The full pipeline beats the compiler on a larger share of tasks than each ablated variant.

Overall KernelBench Faster Rate against torch.compile in the ablationsSingle-response generation: 14.1Single-response generation14.1Continuous speed-up reward: 60.4Continuous speed-up reward60.4Without rejection fine-tuning: 49.8Without rejection fine-tuning49.8Without value pretraining: 50.9Without value pretraining50.9CUDA Agent (this paper): 96.8CUDA Agent (this paper)96.8
The numbers
System or setting%
Single-response generation14.1
Continuous speed-up reward60.4
Without rejection fine-tuning49.8
Without value pretraining50.9
CUDA Agent (this paper)96.8

The single-response policy has a 77.1% Pass Rate, a 43.5% Faster Rate against Eager, and a 14.1% Faster Rate against Compile. Its geometric mean speed-up among correct outputs is 0.89× against Eager and 0.69× against Compile. With the full pipeline, Pass Rate rises to 98.8% and the geometric means are 2.60× and 2.11×, respectively. Direct generation has learned enough of the domain to produce many working implementations. The complete process finds faster working implementations far more consistently.

The paper points to mechanisms available only during interaction. An agent can respond to a build error with a targeted source change, test a suspected cause of a numerical discrepancy, or use a profile to evaluate an optimization that looked promising. Improving the code after the first correct version also makes latency an active part of the search. The comparison establishes the value of this package. It does not isolate the effect of extra attempts at evaluation from the effect of training on interactive trajectories, or the contribution of the skill file from the contribution of the surrounding workspace.

The effect of milestone-based rewards

The reward comparison trains with a continuous speed-up score in place of the milestone schedule. For correct implementations, it gives the ratio of Compile runtime to generated runtime. An incorrect submission still receives the failure reward.

rₛ = ⎧ t꜀ₒₘₚᵢₗₑ / tgₑₙ   if the solution is correct
     ⎩ −1                  otherwise

rₛ is the continuous reward. The numerator t꜀ₒₘₚᵢₗₑ is the measured baseline runtime under torch.compile, and the denominator tgₑₙ is the measured runtime of the generated implementation. The value −1 is the reward when the implementation fails correctness. This ratio lets an exceptionally fast correct result earn proportionally more credit than an ordinary improvement.

The continuous-reward variant reaches a 96.8% overall Pass Rate. Its Faster Rate is 90.4% against Eager and 60.4% against Compile. Among correct solutions, the geometric means are 1.70× against Eager and 1.25× against Compile. The full pipeline has a 98.8% Pass Rate and materially stronger performance on both latency metrics. The small separation in correctness and the much wider separation in speed indicate that the reward formulation mainly affects what the policy learns to do once it has enough competence to produce a valid kernel.

The authors’ explanation concerns where the credit goes during training. A latency ratio can give a large reward to a dramatic improvement on a relatively easy task. The milestone schedule gives comparable credit to solutions on different tasks when both clear the same criteria. It also contains an Eager milestone and a band for all other correct implementations. The experiment compares the schedules as packages, so the observed improvement supports that combined design. It leaves the separate contributions of bounded rewards, the choice of baseline milestones, and the margin unresolved.

The effect of preparing the policy and critic

The remaining ablations each omit one part of the initialization before interactive PPO. Both runs eventually collapse. The paper reports the last validation result before collapse for each of these variants, so their benchmark scores describe a point reached during an unstable run. They also show that a run can retain a high Pass Rate shortly before its optimization behavior deteriorates.

Without rejection fine-tuning, overall Pass Rate is 95.6%, and the Faster Rates against Eager and Compile are 82.0% and 49.8%. Its geometric mean factors on correct solutions are 1.56× against Eager and 1.05× against Compile. The training diagnosis uses actor entropy, which describes how diffuse the policy’s distribution over possible next actions is. In the run without RFT, entropy rises sharply around the time the training reward falls. The authors interpret this as a loss of coherent action structure. The supervised initialization gives the agent a set of valid, successful action patterns to begin from, before updates driven by its own new attempts can push the distribution away from those patterns.

The figure establishes that these changes coincide in the run without RFT. It does not directly measure the proportion of malformed tool calls or show that every session deteriorates through the same mechanism. The filtering procedure itself selects for both positive outcomes and valid behavior. Since the ablation removes the entire initialization step, it also leaves open how much stability comes from outcome selection and how much comes from removing redundant or invalid interactions.

Without value pretraining, the overall Pass Rate is 98.6%. The Faster Rates fall to 85.0% against Eager and 50.9% against Compile, and the geometric means on correct solutions are 1.49× and 1.00× against those baselines. The near-full Pass Rate makes the shortfall especially informative. In this variant, the agent frequently reaches a correct implementation. It has more difficulty reaching a strongly optimized one under the evaluation protocol.

The critic diagnostics give a separate account of what goes wrong. The authors report low explained variance, a measure of how well differences in predicted values account for differences in the training targets. They also observe excessive response length and interpret it as evidence of search that continues without improving the outcome. A critic that supplies weak estimates gives the actor less guidance about which earlier decisions led to a valuable state. The value-pretrained variant can start interactive learning with more informative estimates, which the authors connect to shorter and more productive sessions. The figure’s response-length clipping measure gives indirect evidence about this behavior, instead of a count of the useful and redundant actions in each trajectory.

Together, the diagnostics distinguish diffuse action generation from weak guidance about the value of continuing a search. Both can preserve enough programming ability to pass functional tests for a time. Both undermine the objective of finding a substantially faster candidate reliably. The complete result depends on keeping useful action patterns available while learning which paths through a session tend to produce better kernels.

Limitations

Limits stated by the authors

The authors identify compiler coverage as a limitation. They use torch.compile because it is a widely used baseline that can be integrated into training and evaluation. More sophisticated compilation frameworks such as TVM might provide stronger comparisons, but the paper describes their tuning requirements and deployment complexity as difficult to accommodate across large numbers of training rollouts. The reported Faster Rates and speed-ups establish the comparison with the PyTorch paths that were measured. The relative performance against TVM remains open.

The authors also identify the cost of the system as a limitation. The training infrastructure uses a large GPU pool, process isolation, and engineering to automate compilation, verification, and timing. Exclusive access helps create stable feedback but makes the procedure harder to reproduce with limited hardware. The paper describes resource-efficient training as future work. Its performance metrics describe the runtime of the resulting kernels, while the development and training resources are separate costs.

Limits visible in the evaluation

The results describe a specific hardware setup. CUDA Agent searches for code and parameter choices using feedback from the H20 pool. Thread assignments, memory behavior, and use of accelerated arithmetic can depend on the target device. The paper’s own ResNet example illustrates how the benefit of a change can depend on a surrounding cost, such as layout conversion. A successful choice on a measured task and device leaves the behavior on another architecture or shape unresolved. The paper gives detailed benchmark evidence on its chosen setup, rather than a study of performance portability.

Correctness is tested empirically on five randomly sampled inputs for a task. The checks are substantial enough to reject candidates that disagree with the reference on those inputs, and the dataset filter discourages solutions that ignore input values. Still, a finite sample with numerical tolerances leaves uncertainty about other input distributions, boundary values, shapes, or precisions. The two algebraic examples also show why mathematical simplification and numerical verification belong together. Reassociating a computation can change floating-point rounding even when the symbolic identity is valid. In the ResNet example, using TF32 is part of a successful solution under the stated test conditions. The paper gives no broader numerical-error study for that choice.

The AST check addresses recognizable structural overlap between the authors’ training collection and benchmark reference programs. It gives evidence that the final training set contains no reference above the stated 0.9 cutoff. Related computations can be expressed with different structures, and the training collection deliberately teaches common operations and their compositions. The cutoff answers a question about source similarity. It leaves semantic overlap and the prior training exposure of the compared systems unresolved.

The evaluation also measures the best implementation encountered during a trajectory. This protocol credits a session for finding a fast, correct candidate even if the initial attempt took a different approach. It fits the paper’s question about optimization through interaction. It leaves several deployment questions unanswered, including how long search takes per task, how performance changes with a shorter interaction allowance, and how reliably the agent identifies and preserves its own best candidate. End-to-end optimization costs would also depend on how frequently a selected kernel is reused. The kernel latency metrics provide only one part of that accounting.

The matched workspace makes the main comparison easier to interpret, but it also defines the scope of the comparison. Earlier systems can use their own search routines, retrieval mechanisms, or agent roles. The paper gives reasons for avoiding direct numerical comparisons with those systems, including different task subsets, hardware reporting, training data, and research objectives. The main table therefore answers how the named systems perform under CUDA Agent’s common procedure. It leaves the comparison with independently tuned workflows open.

Finally, the detailed examples explain plausible sources of large gains, while their selection limits what they establish about the benchmark as a whole. One diagonal multiplication can reveal exactly how a formulation wasted computation. It gives no estimate of how often the agent finds comparable identities. The ablations test major pieces of the training recipe and provide behavioral diagnostics. They do not measure separate effects for the distribution of synthesized tasks, the skill’s individual instructions, or every enforcement and timing choice. The aggregate results, the controlled variants, and the case studies each establish a different part of the account.

What came after

There are no documented follow-up papers to discuss. The studies the authors compare with CUDA Agent are predecessors or concurrent work. The paper closes by identifying more resource-efficient training as a direction for future study.

Cite

Cite as Weinan Dai, Hanlin Wu, Qiying Yu, Huan-ang Gao, Jiahao Li, Chengquan Jiang, Weiqiang Lou, Yufan Song, Hongli Yu, Jiaze Chen, Wei-Ying Ma, Ya-Qin Zhang, Jingjing Liu, Mingxuan Wang, Xin Liu and Hao Zhou. 2026. CUDA Agent: Large-Scale Agentic RL for High-Performance CUDA Kernel Generation. arXiv:2602.24286.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.2602.24286 · arXiv 2602.24286

@misc{dai2026cuda,
  title = {{CUDA Agent: Large-Scale Agentic RL for High-Performance CUDA Kernel Generation}},
  author = {Weinan Dai, Hanlin Wu, Qiying Yu, Huan-ang Gao, Jiahao Li, Chengquan Jiang, Weiqiang Lou, Yufan Song, Hongli Yu, Jiaze Chen, Wei-Ying Ma, Ya-Qin Zhang, Jingjing Liu, Mingxuan Wang, Xin Liu and Hao Zhou},
  year = {2026},
  doi = {10.48550/arxiv.2602.24286},
  eprint = {2602.24286},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2602.24286}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/dai-2026-cuda-agent-large-scale-agentic/