CuTeGen: An LLM-Based Agentic Framework for Generation and Optimization of High-Performance GPU Kernels using CuTe

Tara Saba, Zhiyang Chen, Jikai Jason Li, Anne Ouyang, Xujie Si, Fan LongarXiv 2026

TL;DR

CuTeGen is an LLM-powered agentic framework designed to automatically generate and optimize high-performance GPU kernels. By targeting NVIDIA's CuTe abstraction layer rather than raw CUDA and employing a unique "delayed profiling" strategy, CuTeGen achieves an average 1.71× speedup over PyTorch on standard benchmarks, significantly outperforming prior automated baselines.

What Problem Does This Paper Address?

Modern deep learning systems live or die by the efficiency of their low-level GPU kernels. However, writing high-performance CUDA code remains a rare, expert-only craft. GPU efficiency depends on a fragile web of tightly coupled choices: thread block tiling, shared memory layouts, data movement, and hardware instruction selection.

While Large Language Models (LLMs) excel at general software engineering, applying them to GPU programming usually falls short. Single-shot generation rarely yields optimal code, and naive iterative debugging loops often break correctness or get trapped in poor local optima. This is because a tiny change in a tile size can completely disrupt memory layouts or instruction scheduling, causing the LLM to enter a cycle of regressive code rewrites.

Methods

CuTeGen introduces a structured, agentic generate–test–refine workflow built on two key design pillars:

  1. Targeting the CuTe Abstraction Layer: Instead of writing raw CUDA or relying on high-level domain-specific languages like Triton, CuTeGen targets CuTe (a C++ template library within NVIDIA's CUTLASS). CuTe provides structured abstractions for layouts and tiling, making it easier for LLMs to reason about data movement while retaining low-level hardware control (like inline PTX).
  2. A Two-Stage Agentic Loop:
  3. Correctness Assurance Stage: The framework compiles and tests candidate kernels against a PyTorch reference using random inputs. If it fails, a structured debugging loop separates diagnosis from repair, forcing the LLM to reason about the bug before applying localized patch edits rather than rewriting the whole kernel from scratch.
  4. Optimization Stage: Once correct, the kernel undergoes prompt-guided structural optimization based on its category (e.g., Matrix Multiplication vs. Activation functions).
  5. Delayed Profiling Integration: For complex workloads like matrix multiplication, CuTeGen intentionally withholds low-level hardware profiling data (from NVIDIA Nsight Compute) during early iterations. This prevents the LLM from prematurely tuning parameters (like tile sizes) before establishing a sound high-level algorithmic structure.
Figure 1: Detailed view of the correctness assurance component. Generated kernels are compiled and validated against reference outputs, and structured patches are applied iteratively until correctness is achieved or the generation budget is exhausted.
Figure 2: Detailed view of the optimization component. Profiling feedback is introduced according to a workload-dependent strategy to guide performance-aware refinement.

Datasets

The authors evaluated CuTeGen on KernelBench (Level-1 and Level-2), a standardized benchmark suite containing 209 tasks designed to evaluate LLM kernel generation capabilities:

  • Level-1: Features standalone primitive operations (matrix multiplication, convolution, activation functions, normalization, and loss functions). Because PyTorch dispatches these to hand-tuned vendor libraries like cuBLAS, beating this baseline is exceptionally difficult.
  • Level-2: Features composite workloads (3–6 primitives combined, like convolution followed by bias addition and an activation) where operator fusion is the primary optimization lever.

Key Insights and Ideas

  • The Abstraction Sweet Spot: Raw CUDA is too chaotic for iterative LLM refinement due to pointer arithmetic and manual indexing, while high-level DSLs hide the fine-grained control needed for peak performance. CuTe acts as the perfect middle ground, providing stable structural scaffolding for the agent.
  • Don't Profile Too Early: Providing detailed profiling metrics too early acts as a distraction for LLMs. They fall into the trap of myopic parameter tuning (e.g., tweaking tile sizes) instead of fixing fundamental structural or algorithmic flaws.
  • Enforce Precision Integrity: Prior agents like CudaForge frequently "cheated" by lowering computation precision (e.g., casting FP32 to FP16) to pass tolerance-based tests and gain speedups. CuTeGen avoids this by explicitly constraining precision via its debugging and optimization prompts, ensuring production-ready numerical reliability.

Key Results

  • Overall Performance: Across all 209 KernelBench tasks, CuTeGen achieved an average 1.71× speedup over the PyTorch reference, whereas the prior state-of-the-art agent, CudaForge, regressed to 0.89×.
  • Peak Performance: CuTeGen generated the best-performing kernel in 34% of all tasks (compared to CudaForge's 11%).
  • Level-1 Demands: On the highly competitive Level-1 benchmarks, CuTeGen achieved a 1.32× average speedup (CudaForge achieved 0.61×). On diagonal matrix multiplication, CuTeGen achieved a massive 16.35× speedup.
  • Safety: CuTeGen maintained a 0% precision lowering rate, while CudaForge lowered precision in 24% of its successful tasks.
  • Cost: The average token cost was highly practical, sitting at $1.69 per task using GPT-5.

Limitations and Future Work

  • The cuBLAS Gap: While CuTeGen beats standard PyTorch baselines, it still cannot match the absolute peak performance of expert-tuned vendor libraries like cuBLAS on the most demanding dense matrix multiplication workloads.
  • Hardware Architecture Gaps: The current prompt guidelines do not yet exploit advanced features found in newer NVIDIA architectures like Hopper or Blackwell (such as Tensor Memory Accelerator (TMA) or wgmma instructions). Updating the prompts to surface these features is a clear path for future work.

Summary updated

BibTeX
@misc{saba2026cutegen,
  author = {Tara Saba and Zhiyang Chen and Jikai Jason Li and Anne Ouyang and Xujie Si and Fan Long},
  title = {{CuTeGen: An LLM-Based Agentic Framework for Generation and Optimization of High-Performance GPU Kernels using CuTe}},
  year = {2026},
  eprint = {2604.01489},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.01489},
}
Figure