Performance measurement · Research feature

New AI framework boosts GPU kernel efficiency with expert-driven optimization

A new multi-agent system uses reusable expert knowledge and task memory to improve GPU kernel performance across diverse AI workloads.

Adapted from research by Qitong Sun, Jun Han, Tianlin Li and colleagues.

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

Editor’s introduction

KernelClaw, a multi-agent framework with dual-memory mechanisms, integrates long-term storage of expert optimization rules and short-term task-specific memory to guide kernel refinement. It achieves 100% success on KernelBench Levels 1–3 and outperforms prior methods in average speedups and Fast1 metrics, with results consistently tied to or exceeding baseline performance. The framework demonstrates stable optimization across multiple task trajectories, showing that improvements are broadly distributed rather than limited to specific kernels. The evidence is based on experiments conducted on KernelBench, where KernelClaw achieves the best or tied-best Fast1 scores on all levels. Baseline results are drawn from published papers, and since complete implementations of some prior systems were unavailable, comparisons are based on reported performance under original conditions.

Introduction

Efficient GPU kernels are fundamental to modern AI systems, as they largely determine the throughput of core operators such as GEMM, convolution, and data movement. Achieving high performance, however, remains a highly expertise-intensive and architecture-dependent process, requiring careful coordination of memory access patterns, parallel decomposition, and synchronization. As a result, manual kernel optimization often demands lengthy profiling-guided iteration cycles, bottleneck diagnosis, targeted code refinement, and repeated validation, making the development process both costly and time-consuming.

Recent advances in large language models (LLMs) have opened a promising avenue for automated GPU kernel generation and optimization. Existing LLM-based kernel optimization approaches typically follow two paradigms: (i) training-based methods that collect data and train models for kernel optimization. However, such approaches require curating large-scale datasets and substantial training compute, leading to high cost and long training cycles, and often exhibit limited generalization capability. To mitigate these limitations, agentic methods have been proposed, in which models iteratively refine kernels using compilation and correctness checks, together with profiling feedback. Although these agentic approaches have achieved commendable progress, important gaps in kernel optimization still remain. In particular, ❶ optimization decisions are often opaque, emerging from implicitly learned heuristics within LLMs that are weakly interpretable. This makes it difficult to understand why a given strategy is selected and, in turn, hinders effective correction and further improvement of the optimization process. In addition, ❷ these methods typically rely on multi-round iterative refinement, which can be redundant, i.e., repeatedly revisiting previously seen and incorrect optimization strategies, thereby increasing runtime overhead.

Prior work has studied automated GPU kernel optimization through expert libraries, compiler/DSL ecosystems, and search-based autotuning, including cuDNN, TVM, Triton, and ThunderKittens. These systems provide effective optimization primitives, but require substantial engineering effort and continuous maintenance as hardware and workloads evolve. Recent LLM-based methods reduce this burden by using code-generation models for kernel synthesis and optimization. Training-based approaches, such as CUDA-L1, Kevin, and MTMC, adapt specialized models or policies using optimization signals, but can be costly and may struggle to generalize across the large, hardware-dependent kernel optimization space.

A complementary line performs inference-time closed-loop refinement, where LLMs iteratively revise kernels using compilation checks, correctness tests, runtime measurements, and profiling feedback. Recent methods further improve this process through expert-guided decomposition, failure-driven adaptation and diversity-preserving search, evolutionary program search, or DSL-constrained optimization with Speed-of-Light guidance. However, these designs mainly structure the search process or accumulate optimization experience; they do not explicitly separate reusable cross-task knowledge from task-local trajectories through an auditable evidence-to-method interface. In contrast, KernelClaw represents expert knowledge as deterministic decision rules retrieved jointly from static code features and profiling signals, while maintaining a separate short-term memory for repair and optimization histories. This functional separation enables traceable method selection and trajectory-aware refinement under a fixed optimization budget. A more detailed discussion is provided in Appendix A of the supplementary material.

Multi-Agent Pipeline

Generator. The Generator agent aims to generate functionally correct CUDA kernel implementations from a given PyTorch reference program while maximizing kernel diversity for subsequent optimization. Specifically, we implement the Generator as an LLM-based agent that translates PyTorch operators into equivalent custom CUDA kernels and prompts the LLM to explore diverse kernel implementations whenever possible.

Reviewer. The Reviewer is a functional evaluation module that aims to assess each generated CUDA kernel and return execution feedback for subsequent repair and optimization. Given a generated kernel and its PyTorch reference program, the feedback must capture both functional validity and performance behavior, since the former determines whether the kernel should be repaired, while the latter provides evidence for identifying optimization opportunities. Accordingly, the Reviewer reports the compilation status, correctness results, runtime measurements, and profiling signals of the current implementation. To produce this feedback, the Reviewer consists of three deterministic components: a Compiler, a Verifier, and a Profiler. The Compiler builds the generated kernel and reports whether compilation succeeds, together with warnings and error messages when failures occur. The Verifier checks functional correctness by comparing the kernel outputs with those of the PyTorch reference under a prescribed numerical tolerance. The Profiler measures execution latency and collects low-level runtime signals using profiling tools such as nsys and ncu, including register usage, shared-memory footprint, and other resource-related indicators. The resulting feedback is consumed by downstream modules to determine the repair or optimization branch, diagnose failures, identify performance bottlenecks, and guide subsequent refinement.

Feature Extractor. The Feature Extractor converts a CUDA kernel implementation into source-level evidence for optimization-method retrieval. Profiling signals reveal where performance bottlenecks occur, but they do not always indicate whether a particular optimization method is structurally applicable to the current implementation. To complement this runtime evidence, the module extracts structural features of the code, such as memory-access patterns, precision choices and hardware-specific API/intrinsic usage. These features are obtained directly from the kernel source without executing the program. They are then combined with profiling signals to form retrieval keys for selecting candidate optimization methods from the long-term memory. For example, the applicability of Tensor Core computation, vectorized memory access, shared-memory tiling, and loop reorganization depends not only on the observed bottleneck but also on source-level constraints that may be ambiguous from profiling metrics alone. To extract such evidence, the Feature Extractor combines rule-based pattern matching for stable syntactic signatures with LLM-based inference for semantically defined features whose surface forms vary across implementations.

Planner. The Planner is an LLM-based agent that aims to select an optimization method and generate a concrete plan for a valid base kernel. After a kernel passes compilation and correctness verification, KernelClaw retrieves candidate optimization methods from the long-term memory using its static code features and profiling feedback. Given the current base kernel, retrieved methods, method rationales, profiling feedback, and short-term optimization memory, the Planner outputs a stepwise optimization plan for the Optimizer.

Dual-Memory

Long-term Memory. The long-term memory provides reusable expert knowledge for optimization-method selection across kernels. Given profiling feedback and static code features, KernelClaw uses the long-term memory to retrieve feasible candidate methods and provide method-specific rationales and implementation cues for downstream planning and execution. This design allows KernelClaw to select optimization methods through explicit evidence rather than relying solely on implicit prompt preferences or ad-hoc trial-and-error.

Concretely, the long-term memory consists of two complementary components: Deterministic Decision Policy, which stores rule-based gating, prioritization, and method candidate selection criteria over profiling/code evidence; and Method Knowledge, which stores method-specific rationales and implementation cues to make the selected actions interpretable and executable. Given profiling feedback and code features, KernelClaw first uses the Deterministic Decision Policy to filter and prioritize feasible method candidates, and then consults Method Knowledge to provide rationales and concrete implementation guidance for the Planner. A full schema of the long-term memory fields is provided in Appendix C of the supplementary material. We next describe how the two components support optimization-method retrieval.

Optimization-method retrieval. KernelClaw implements a structured retrieval pipeline that explicitly uses the two components of long-term memory. Given the current kernel’s profiling signals and structural characteristics, including static code features, NCU metrics, and runtime features, KernelClaw first normalizes raw profiling fields and derives composite indicators. These evidence fields are then matched against the Deterministic Decision Policy, where predicates, priority rules, and global veto rules are applied to filter and prioritize feasible optimization methods. After a candidate method set is selected, KernelClaw consults Method Knowledge to attach method-specific rationales and implementation cues, which are then provided to the Planner for plan synthesis. During this process, method selection remains traceable: for each recommendation, KernelClaw can record which normalized fields and predicates were satisfied, which rule or case in the decision table was matched, which constraints vetoed alternatives, and which method rationale was retrieved. The complete long-term memory decision workflow is provided in Appendix D of the supplementary material. We next explain how this knowledge is collected and organized into the two long-term memory components.

Expert knowledge sources. The long-term memory is built from expert kernel-optimization knowledge distilled by us. Concretely, we start from a large-scale GPU optimization survey and translate its taxonomy into the two memory components through a three-step curation procedure. (1) Scenario abstraction: we group optimization techniques into recurring, task-agnostic scenarios, such as memory-bound access patterns and underutilized parallelism, and identify the observable decision factors that practitioners use in bottleneck identification. This step defines the high-level scenario and method taxonomy used by both Deterministic Decision Policy and Method Knowledge. (2) Evidence formalization: we specify how each decision factor is measured from available signals, including normalized profiling metrics via field_mapping, runtime features, and static code features; we also define deterministic composite indicators via derived_fields so that the same concept can be evaluated consistently across kernels and tool versions. This step mainly constructs the evidence fields used by the Deterministic Decision Policy. (3) Rule materialization: we encode scenario-to-method criteria into predicates, priority rules, global veto rules, and a decision table that maps matched evidence patterns to candidate method sets, i.e., allowed_methods. These rules form the core of the Deterministic Decision Policy, while the companion llm_assist store forms the Method Knowledge by providing method-level rationales and implementation cues.

Baselines

Compiler and general coding baselines. We evaluate torch.compile under both its default and max-autotune configurations as compiler-based optimization baselines. We also include Cursor, a general-purpose coding agent that can inspect source code, modify implementations, execute programs, and iteratively respond to execution feedback. These baselines assess whether general compiler optimization or general-purpose agentic code editing is sufficient for the KernelBench tasks without a kernel-specific optimization workflow.

Training-based methods. Kevin trains a specialized model using a multi-turn reinforcement learning procedure that explicitly optimizes iterative kernel refinement. QiMeng adopts a macro-to-micro paradigm that first produces high-level optimization guidance and then realizes the selected strategy through stepwise low-level code generation.

Agentic and search-based optimization. CudaForge employs a training-free Coder–Judge workflow that iteratively generates and evaluates CUDA kernels using correctness, runtime, and hardware feedback. Astra organizes kernel generation, testing, profiling, and planning through specialized agents, while PRAGMA explicitly maps profiling evidence to bottleneck-specific optimization actions. STARK combines grounded optimization instructions, dynamic task context, and strategic exploration for multi-round kernel refinement. We additionally compare with more recent structured-search methods. EGG decomposes kernel generation into algorithmic design and hardware-specific refinement through expert-guided agent collaboration. AdaExplore combines failure-driven adaptation with diversity-preserving tree search, whereas OpenEvolve maintains an evolving population of programs and generates new candidates from selected historical implementations.

Experimental Results and Analysis

For Fast1, KernelClaw achieves 0.74, 1.00, and 0.88 on Levels 1–3, respectively. It exceeds the strongest baselines on Levels 1 and 3, improving over STARK from 0.71 to 0.74 and from 0.87 to 0.88, while tying EGG and STARK at 1.00 on Level 2. The consistently strong Fast1 results show that the acceleration of KernelClaw is distributed across a broad range of tasks rather than being concentrated in only a few exceptionally fast kernels.

Conclusion

We present KernelClaw, a multi-agent framework for GPU kernel optimization with dual-memory mechanisms. By combining reusable expert knowledge with task-specific refinement trajectories, KernelClaw supports evidence-driven method selection and stable multi-round optimization. Experiments on KernelBench demonstrate 100% Success, the best or tied-best Fast1, and a Speedup advantage that remains after auditing. Limitations and broader deployment considerations are discussed in Appendix P of the supplementary material.

Training-Based LLM Methods

Recent progress in code-oriented LLMs has enabled specialized models to synthesize and optimize GPU kernels through supervised adaptation, reinforcement learning, and learned optimization policies. CUDA-L1 and Kevin train models to improve CUDA generation and multi-round kernel refinement. QiMeng introduces the Macro-Thinking and Micro-Coding paradigm, in which high-level optimization strategies are learned separately from their step-by-step code realization. Related approaches learn optimization behaviors at different levels of the software stack, including Triton program synthesis and low-level GPU instruction scheduling.

Training-based methods can internalize recurring optimization patterns and reduce reliance on manually designed inference-time workflows. However, collecting suitable trajectories and performing model training or reinforcement learning can be computationally expensive. Moreover, optimization knowledge is primarily encoded in model parameters or learned policies, making the relationship among the observed runtime bottleneck, the selected optimization strategy, and the resulting code transformation difficult to inspect. Their learned policies may also require further adaptation when workloads, programming abstractions, or target hardware change.

Inference-Time Agentic and Search-Based Optimization

A complementary line of work performs inference-time closed-loop optimization. These systems iteratively generate and revise kernels using compilation outcomes, correctness tests, runtime measurements, and, when available, hardware profiling feedback. CudaForge adopts a lightweight Coder–Judge workflow, while Astra organizes generation, testing, profiling, and optimization planning through specialized agents. PRAGMA explicitly connects profiling evidence with concrete optimization actions, and STARK combines grounded optimization instructions, strategic exploration, and dynamic task context. Other studies extend closed-loop optimization to Triton-oriented generation, evolutionary refinement, and end-to-end PyTorch inference optimization.

General-purpose coding agents can also serve as kernel-generation baselines. Cursor, for example, provides repository search, source-code editing, terminal execution, and iterative feedback within an integrated coding environment. Such agents offer flexible software-engineering capabilities but do not intrinsically provide kernel-specific profiling interpretation, hardware optimization rules, or structured mappings from runtime evidence to applicable optimization methods.

Recent kernel optimizers introduce more structured mechanisms for organizing inference-time exploration. EGG decomposes kernel generation into algorithmic structure design and hardware-specific tuning, using stage-aware multi-agent collaboration to progressively refine the implementation. AdaExplore combines failure-driven adaptation with diversity-preserving search. It converts recurring execution failures into reusable validity rules and organizes candidate kernels as a tree that alternates between local refinement and larger structural regeneration. OpenEvolve is a general evolutionary coding agent that maintains and selects candidate programs and uses LLMs to generate new variations under task-specific evaluation feedback.

These methods demonstrate that staged decomposition, evolutionary search, DSL constraints, and retrieval-augmented generation can substantially improve kernel optimization. Their principal emphasis, however, is on organizing candidate exploration, constraining the implementation space, or improving the generation procedure. In contrast, KernelClaw focuses on making optimization-method selection explicit and traceable: static source features and normalized runtime evidence are jointly evaluated against deterministic applicability rules before an optimization method is supplied to the code-generation agents.

Memory-Augmented Agents and Kernel Optimization

Memory has become an important component of long-horizon LLM agents. Recent surveys distinguish agent memory according to its representation, function, and update dynamics, covering factual, experiential, and working memory rather than relying exclusively on the conventional long-term/short-term distinction. Agentic Memory, or AgeMem, integrates long-term and short-term memory operations directly into the agent policy. It allows the agent to learn when to store, retrieve, update, summarize, and discard information through a reinforcement-learning framework. These general-purpose approaches focus primarily on long-horizon reasoning, autonomous context management, and efficient use of finite context windows.

Memory and experience reuse have also been explored specifically for accelerator and GPU kernel optimization. AccelOpt maintains an optimization memory derived from previously observed slow–fast kernel pairs and uses the accumulated experience to improve subsequent kernels for emerging AI accelerators. KernelBlaster constructs a persistent CUDA knowledge base from prior optimization trajectories and uses memory-augmented in-context reinforcement learning together with profile-guided textual feedback. AdaExplore extracts reusable validity rules from recurring failures before performing task-time candidate search. KernelEvolve retrieves relevant context to synthesize prompts for kernel generation across operators, programming abstractions, and hardware platforms. STARK additionally maintains dynamic within-task context to support strategic refinement across successive attempts.

Accordingly, the contribution of KernelClaw is not simply the use of both long-term and short-term memory. Instead, it defines a kernel-specific functional separation between two forms of optimization information. The long-term memory stores externally curated expert knowledge as deterministic evidence predicates, decision rules, and method-specific implementation guidance. Static code features characterize whether a transformation is structurally applicable, while profiling signals characterize the currently observed runtime bottleneck. Their combination forms an explicit evidence–rule–method chain for retrieving optimization knowledge.

The short-term memory serves a different role: it records the task-local repair and performance-optimization trajectories, including previous edits, selected methods, execution outcomes, and observed failures. Repair and optimization histories are maintained separately because they support different subsequent decisions. The former helps avoid repeatedly producing invalid implementations, whereas the latter helps the agents refine already correct kernels without revisiting unproductive optimization attempts.