Performance measurement · Research feature

CuTeGen generates faster GPU kernels using LLM-driven agentic workflow

The study evaluates CuTeGen, an LLM-based agentic framework designed to generate and optimize high-performance GPU kernels through a generate-test-refine cycle on the CuTe abstraction layer.

Adapted from research by Tara Saba, Zhiyang Chen, Jikai Jason Li and colleagues.

arXiv preprint revision · 2026-06-03 · Attribution & reuse
In this article
Editorial illustration of processor die.

Editor’s introduction

The study evaluates CuTeGen, an LLM-based agentic framework designed to generate and optimize high-performance GPU kernels through a generate-test-refine cycle on the CuTe abstraction layer. It compares generated kernels against PyTorch’s reference implementation, measuring speedup as the ratio of reference to generated runtime. The framework outperforms prior work CudaForge by 1.71× over PyTorch on 209 tasks across KernelBench Level-1 and Level-2, with better results on structurally complex kernels like matrix multiplication and convolution. Performance is measured under consistent conditions, excluding compiler optimizations, to isolate kernel-level design effects. However, CuTeGen does not match expert-tuned vendor kernels such as cuBLAS on the most demanding workloads. The study finds that targeting CuTe improves correctness and structural reasoning, especially in kernels requiring tiling and memory layout. Delaying performance profiling until kernel structure stabilizes yields stronger results, particularly on complex workloads.

Introduction

The continued scaling of deep learning models—especially large language models (LLMs)—has made high-performance GPU computing a central bottleneck for modern AI systems. Across workloads in language, vision, and scientific computing, end-to-end throughput is often dominated by a small set of compute-intensive primitives. While GPU hardware capabilities have advanced rapidly, realizing these gains in practice depends critically on low-level kernel implementations that effectively exploit massive parallelism, the memory hierarchy, and specialized instructions. As a result, system performance is frequently determined not by algorithms alone, but by how close kernel code can approach the hardware’s theoretical limits.

LLM-driven coding agents have reshaped many aspects of software development, yet their impact on high-performance GPU kernels remains limited. For many performance-critical operators, e.g., GEMM and FlashAttention, state-of-the-art implementations are still largely hand-engineered by experts. Recent work has explored using LLMs to generate GPU kernels automatically, but the performance gap between generated kernels and carefully tuned expert implementations is still substantial, especially for kernels that rely on hardware-specific features and tightly coupled optimization decisions.

Background

High-performance GPU kernels are typically developed using vendor libraries, template libraries, domain-specific programming systems, and compiler frameworks. Vendor-provided libraries such as cuBLAS and cuDNN offer highly optimized implementations of common operations but are closed-source and limited to predefined kernels. Template-based libraries such as CUTLASS offer reusable CUDA templates for building custom kernels, while still requiring substantial manual engineering effort. Higher-level systems such as Triton and ThunderKittens make kernel programming more accessible by abstracting memory layout and execution structure, but developers have less control over low-level optimization choices. Compiler-based systems such as torch.compile further automate graph- and operator-level transformations, but generally only optimize using fixed optimization patterns. These systems reduce the burden of GPU kernel development, yet efficient custom kernels still often depend on expert-designed implementations and optimization strategies.

CuTeGen targets the automatic generation and optimization of custom GPU kernels from PyTorch reference implementations. To support this goal, CuTeGen uses CuTe, the tensor abstraction layer used by CUTLASS, as its kernel representation. CuTe provides structured abstractions for layouts, tiling, tensors, and data movement while preserving the low-level control required for hardware-aware optimization. This combination gives the model a stable representation for iterative refinement without sacrificing access to performance-critical GPU features.

Training-based and search-based kernel generation

Another line of work improves kernel generation through model training or structured search. AscendKernelGen, AutoTriton, and CUDA-L1 adapt models with domain-specific data, supervised fine-tuning, or reinforcement learning to improve hardware-specific code generation. K-Search and AutoComp instead explore optimization spaces at inference time, the former using a co-evolving world model and the latter LLM-driven search with hardware feedback. CuTeGen differs from these systems on two axes. Where the training-based approaches rely on model adaptation and the search-based approaches on parallel space exploration, CuTeGen iteratively refines a single evolving kernel via execution feedback, with no retraining and no parallel search. The two groups also target different abstraction layers—Triton DSL for AutoTriton and Python/PyTorch code for AutoComp—whereas CuTeGen operates at the CuTe C++/CUDA template layer, which exposes tiling and layout while preserving low-level hardware control.

Hardware-feedback and agentic kernel optimization

The closest related systems use execution or profiling feedback to iteratively improve GPU kernels. Some works operate primarily on CUDA kernels: CUDA-LLM uses compilation, correctness, and runtime feedback to refine CUDA implementations; CUDAForge adds a Coder-Judge workflow with Nsight Compute feedback; and Astra coordinates specialized agents to optimize existing CUDA kernels. CuTeGen differs from these systems by using CuTe as the synthesis representation, exposing layout and tiling structure to the model instead of refining raw CUDA code directly. Other works target other abstractions or broader search spaces. TritonForge applies profiling-guided optimization to Triton kernels, while KernelEvolve explores evolving candidate implementations across multiple accelerator programming abstractions, including Triton and CuTe. CuTeGen differs from these systems by centering the entire workflow on a single CuTe kernel and improving it through localized patch edits, rather than maintaining a broad candidate search over many alternative implementations.

Method

Starting from an initial task specification and reference implementation, the model produces a CuTe-based kernel. This kernel is compiled, executed, and validated against the reference implementation using randomized inputs. Compilation failures, runtime errors, and output mismatches are recorded and used to guide subsequent refinement steps. When correctness issues arise, diagnostic information is incorporated into structured debugging prompts that enable the model to analyze failures and generate targeted code patches. Once a kernel produces correct outputs, the system transitions to the optimization phase, where performance feedback obtained through hardware profiling, together with a domain-specific optimization guide that we provide to the model, is used to guide further improvements. Through this iterative feedback loop, CuTeGen progressively refines both functional correctness and execution efficiency.

Task Formulation and Objective

CuTeGen takes as input a PyTorch specification of the target computation, typically written as a torch.nn.Module whose forward method defines the intended semantics. The specification may additionally provide helper code for constructing representative input tensors, mainly to specify expected tensor shapes, data types, and invocation patterns. Based on this specification, CuTeGen synthesizes a functionally equivalent implementation in which performance-critical PyTorch operators are replaced by custom GPU kernels. The output of CuTeGen is therefore not just a generated kernel, but an optimized implementation that can be invoked under the same high-level interface as the original PyTorch code. From the user’s perspective, adopting CuTeGen only requires providing a correct reference implementation together with representative inputs; CuTeGen then handles kernel generation and iterative optimization toward improved execution performance. This task formulation also aligns with standardized evaluation setups used in benchmarks such as KernelBench.

In our framework, we explicitly guide the model to generate kernels using the CuTe abstraction layer. CuTe provides structured tensor and layout abstractions that expose performance-critical design choices such as tiling strategies, memory layouts, and execution organization while preserving low-level control over GPU execution. Compared to raw CUDA, these abstractions make kernel generation more tractable for language models, while remaining lower-level than DSLs such as Triton or ThunderKittens. This combination provides a stable representation for iterative refinement while retaining the flexibility needed for hardware-aware optimization.

Correctness Assurance Stage

CuTeGen follows an iterative generate–test–refine workflow in which kernel correctness is established before performance optimization is attempted. The correctness assurance stage coordinates a sequence of LLM interactions and program executions designed to progressively identify and repair errors in generated kernels.

The process begins with an initial synthesis prompt (detailed in Appendix A) which describes the target task and provides a representative CuTe kernel example to anchor the expected structure and coding style. Using this prompt, the LLM produces an initial candidate kernel implementation.

Diagnosis Stage

In the diagnosis stage, the model receives diagnostic information—including compilation errors, runtime exceptions, and correctness discrepancies—together with our structured debugging guidelines, and is prompted to generate diagnostic suggestions explaining the likely causes of the observed failures. We developed these guidelines based on both domain knowledge of CuTe kernel development and empirical observations of common failure patterns in LLM-generated kernels. Accordingly, they encode both CuTe-specific considerations and recurrent LLM pitfalls, providing targeted guidance for interpreting compiler feedback, runtime behavior, and correctness mismatches. The full debugging guideline used in our system is provided in Appendix B.

Repair Stage

Following diagnosis, the model generates structured patch edits that repair the implementation. Rather than regenerating the entire kernel, the model proposes localized modifications in a constrained patch format (e.g., line-level insertions, deletions, or replacements), which are then applied directly to the existing code. This staged design encourages the model to first reason explicitly about the source of failure before proposing edits, leading to more targeted and coherent fixes. Constraining the repair process to localized patches further preserves valid portions of the existing kernel, avoids unnecessary large-scale rewrites, and helps retain performance-relevant design choices while resolving correctness issues.

Once a kernel passes compilation and correctness validation, the optimization stage is invoked to improve performance. Subsequent optimization steps may again introduce correctness issues, in which case the same execution, validation, and debugging loop is re-entered. This alternating process ensures that performance improvements are built on functionally correct implementations.

Structural Optimization

In the structural optimization phase, CuTeGen prompts the underlying LLM to generate performance-aware kernel transformations while preserving correctness. The prompt specifies a set of task-specific optimization guidelines based on GPU kernel design principles and empirical observations of LLM optimization behavior. CuTeGen uses different optimization guidelines for different kernel categories. The model is instructed to infer the kernel category, reason about dimensional relationships and relevant GPU optimization strategies, and then apply the corresponding optimization principles. For example, matrix multiplication kernels are guided toward tiling strategies, memory hierarchy utilization, and data layout transformations, whereas activation-function kernels emphasize vectorization, memory access patterns, and lightweight computation fusion. The full optimization prompts used in our system are provided in Appendix C.

Importantly, we encourage the model to introduce optimizations incrementally—typically one transformation at a time—rather than attempting multiple simultaneous changes. Based on our observations, this strategy improves stability, reduces correctness regressions, and requires fewer debugging iterations compared to more aggressive multi-step modifications. This incremental refinement behavior is facilitated by the structured starting point provided by the CuTe representation, which exposes tiling and execution structure from the outset; a direct comparison with a raw CUDA baseline is provided in Appendix D. In practice, this structured and category-aware guidance enables the model to prioritize meaningful algorithmic improvements over superficial code changes. A detailed GEMM optimization case study is provided in Appendix E.

Profiling-Driven Refinement

In the profiling-driven refinement phase, CuTeGen incorporates hardware profiling signals obtained using NVIDIA Nsight Compute to inform later optimization stages. Rather than exposing raw profiler outputs, we provide the model with a structured summary of performance indicators, including kernel launch configuration parameters (e.g., block and grid sizes, register usage, and shared-memory allocation), execution-time metrics such as kernel duration and throughput estimates, resource utilization measures including achieved occupancy, and selected profiler diagnostics highlighting potential bottlenecks. Presenting these signals in a concise, structured form enables the model to reason about performance trade-offs without being overwhelmed by low-level detail.

A key design choice in our system, especially for primitive operations, is the delayed introduction of profiling feedback. We do not expose profiling signals uniformly across all workloads. For structurally complex kernels such as matrix multiplication, profiling information is intentionally withheld during early optimization iterations and introduced only after the model has explored higher-level structural transformations. We found that introducing profiling feedback too early biases the model toward premature parameter tuning (e.g., tile sizes or shared-memory configurations), often leading to suboptimal local optima before more impactful algorithmic improvements are implemented. By delaying profiling, we encourage the model to first establish a strong structural design and only then refine low-level parameters.

Benchmarks

Level-1 consists of single primitive operations — matrix multiplication, convolution, activation functions, normalization and reduction layers, and loss functions. Because PyTorch dispatches these directly to hand-tuned vendor libraries such as cuBLAS and cuDNN, the PyTorch reference is already a heavily optimized kernel, and achieving speedup over it is very challenging.

Level-2 combines 3–6 primitives into a single workload (e.g., convolution followed by bias addition and an activation). PyTorch eager launches each primitive as a separate kernel, so the most effective optimization is often operator fusion — combining the sequence into one kernel to eliminate the overhead of multiple kernel launches and intermediate memory traffic.

Comparison Baseline: CudaForge

We surveyed several open-source systems from prior and concurrent work on agentic GPU kernel generation, and select CudaForge as our baseline. Among the systems we considered, CudaForge is the only one that is both publicly available and can be driven by the same underlying language model (GPT-5) we use for CuTeGen, allowing a fair comparison in which the model and hardware are held constant and only the agent design varies. The remaining candidates were unsuitable for one of three reasons: (i) the system requires training and is bound to its own fine-tuned model, precluding a head-to-head GPT-5 comparison; (ii) the system operates outside the kernel itself — for instance, modifying the surrounding PyTorch program rather than producing a standalone GPU kernel — and is therefore not directly comparable to CuTeGen’s task formulation; or (iii) we were unable to reproduce the system in our environment. We run CudaForge with its default 10 round setting.

Manual Correctness Audit

Tolerance-based correctness checks alone are insufficient for evaluating LLM-generated kernels. When pushed to optimize aggressively, language models frequently take shortcuts that compromise numerical accuracy — most commonly, enabling mixed-precision tensor core paths by lowering operand precision from FP32 to FP16/BF16 — and such kernels may pass the benchmark’s tolerance check while silently producing degraded outputs that would be unacceptable in deployment. To guard against this, we manually inspect every generated kernel, with particular scrutiny on those reporting a speedup over the PyTorch reference, for both CuTeGen and CudaForge. Kernels whose speedup is attributable to lowering precision below the reference, or otherwise altering the underlying computation, are excluded from the reported speedup numbers.

Overall Performance

One interesting observation is that CudaForge generated lower-precision kernels in a substantial fraction of tasks –24% of the cases on which it reports speedup– often by enabling FP16/BF16 computations while retaining FP32 accumulation. In contrast, CuTeGen does not exhibited this behavior, partly because our prompts across the debugging and optimization stages explicitly instruct the model to preserve the precision in computation. We found that many mixed-precision kernels can still pass the tolerance-based random testing harness used in KernelBench, despite deviating from the numerical behavior of the reference implementation. While such changes may improve benchmark speedups, they can silently reduce numerical reliability and lead to unacceptable behavior when deployed as part of larger end-to-end systems.

Level-1 Performance

Level-1 is the most demanding setting: each task is a standalone primitive and the PyTorch reference dispatches directly to cuBLAS or cuDNN, which are at or near hardware peak. Beating this reference requires precise control over tiling, shared-memory use, and instruction scheduling, and is the regime in which most LLM-generated kernels fail. On these tasks, CuTeGen consistently achieves higher speedup than CudaForge, and outperforms it most clearly on the categories where the vendor library is most aggressive. We attribute this gap to two design choices: operating in CuTe rather than raw CUDA exposes tiling and layout decisions to the model in a structured form, and delaying profiling integration lets the model establish a sound algorithmic skeleton before tuning low-level parameters.

Limitations

CuTeGen does not match expert-tuned vendor kernels such as cuBLAS, performance-wise, on the most demanding workloads, most notably dense matrix multiplication. Owing to compute budget, our experiments use a single language model (GPT-5) on a single NVIDIA RTX 4090; the framework is model-agnostic in principle, and we expect comparable behavior on other Ada and Ampere-class GPUs. Newer architectures such as Hopper and Blackwell introduce features (e.g., TMA, wgmma) not exercised by our current prompts, and reaping additional speedup on those generations will likely require prompt updates that surface them.