arXiv(opens in a new tab)cs.CLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.00058

CUDA-Harness: Harnessing Agentic CUDA Kernel Generation and Optimization from Natural Language

Qi Fan, An Zou, Yehan Ma

ABSTRACT

Developing high-performance CUDA kernels demands specialized knowledge in algorithm implementation, correctness validation, and hardware-aware parallel optimization, creating a substantial expertise barrier and making generating CUDA kernels directly from natural language (Text2CUDA) essential. Meanwhile, the general-purpose code generation capability of Large Language Models (LLMs) prompts a series of works exploring LLM-based CUDA kernel generation. They mainly focus on transpilation from high-level frameworks such as PyTorch to CUDA (Torch2CUDA) rather than Text2CUDA, where models must understand the high-level input semantics and handle low-level kernel implementation and validation. Additionally, these methods are vulnerable to reward hacking due to reliance on predefined test inputs. In this paper, we propose CUDA-Harness, a framework for harnessing agentic CUDA kernel generation and optimization from natural language. Specifically, we introduce Intermediate-Structured Generation to connect high-level semantic understanding with low-level kernel generation. To dilute reward hacking in Text2CUDA, we construct Synthesis-Based Verification to provide isolated test data and progressive validation. Furthermore, we propose Feedback-Adaptive Evolution, a kernel evolution strategy that prioritizes correctness while optimizing performance. Finally, through extensive experiments, we demonstrate the effectiveness of CUDA-Harness, with further evaluations illustrating generalization across LLMs, hardware platforms, and to C-to-CUDA transpilation.

1 INTRODUCTION

With the advancement of high-performance computing, CUDA has become the dominant platform for parallel computing, powering applications from artificial intelligence (Paszke et al., 2019; Shah et al., 2024) to quantum computing (Guo et al., 2025) and scientific simulation (Xie et al., 2025). However, developing high-performance kernels remains challenging, as it requires not only concise knowledge of algorithm implementation and testing details, but also specialized understanding of hardware architectures and parallel optimization. These requirements create a substantial expertise barrier that limits the accessibility of GPU programming. Hence, generating CUDA kernels directly from natural language (Text2CUDA) is essential to bridge the gap between high-level application needs and low-level parallel implementation.

Large Language Models (LLMs) have demonstrated remarkable capabilities in general-purpose code generation (Zheng et al., 2025), prompting a series of studies (Yu et al., 2026) that leverage LLMs to produce high-performance CUDA kernels. Nevertheless, existing works (Ouyang et al., 2025; Dong et al., 2025) primarily focus on transpilation from high-level frameworks (e.g., Torch2CUDA, which transpiles PyTorch to CUDA) rather than Text2CUDA. The distinction is fundamental. Transpilation starts from programs whose algorithmic details are already specified, whereas Text2CUDA starts from natural language descriptions that can be incomplete and underspecified. Hence, Text2CUDA requires the model to more deeply understand the high-level intended semantics while simultane-

*Corresponding Author

Figure

Figure 1: Text2CUDA vs. Torch2CUDA. Torch2CUDA starts from detailed PyTorch code, while Text2CUDA starts from an underspecified natural-language prompt with no available test data.

ously handling low-level kernel implementation and validation, as illustrated in Fig. 1. Therefore, a Text2CUDA framework that systematically addresses input semantic understanding is essential.

Existing LLM-based CUDA kernel generation approaches can be broadly categorized into two types: training-based and agent-based. Training-based approaches (Li et al., 2025; Dai et al., 2026; Du et al., 2026) enhance the model's CUDA kernel generation capability through supervised fine-tuning or reinforcement learning. Nevertheless, they heavily rely on high-quality kernel implementations and optimization trajectories to build the training data (Zhou et al., 2023), which is scarce and expensive in practice. Agent-based approaches (Dong et al., 2025; Zhang et al., 2025; Chen et al., 2025a) leverage multi-agent collaboration and self-refinement (Madaan et al., 2023) to achieve training-free kernel generation and optimization. However, they typically depend on predefined test inputs for validation and feedback construction during iterative refinement, which may lead to reward hacking (Denison et al., 2024) and optimization over flawed implementations. Therefore, harnessing agentic CUDA generation is critical for generating correct and efficient CUDA kernels.

In this paper, we propose CUDA-Harness, a framework for harnessing agentic CUDA kernel generation and optimization from natural language. With three components for kernel generation, verification, and optimization, it connects input semantic understanding with verification-guided refinement to improve correctness and efficiency. Empirically, CUDA-Harness shows that natural language can serve as a practical interface for correct and high-performance CUDA kernel development. The contributions are fourfold.

  • We introduce Intermediate-Structured Generation, bridging the gap between high-level semantic understanding and low-level kernel synthesis for Text2CUDA.
  • We construct Synthesis-Based Verification, providing isolated test data synthesis and progressive validation to dilute reward hacking in Text2CUDA.
  • We propose Feedback-Adaptive Evolution, prioritizing correctness to avoid error accumulation during optimization.
  • We conduct extensive experiments demonstrating the effectiveness of CUDA-Harness, while extended evaluations illustrate its generalizability across LLMs, hardware platforms, and to C-to-CUDA transpilation.

References (29)