Manuscript Offprint

arXiv:2609.35568

From Experience to Expertise: Adoption-Aware Memory Learning for Data-Scarce NPU Kernel Synthesis

Longxiao Fan, Tao Zhang, Han Yan, Jiajun Li, Mingcong Song, Guoping Long, Hongjie Si, Weiwei Sun

Longxiao Fan

Fudan University

24110240020@m.fudan.edu.cn

Han Yan

Fudan University

24210240065@m.fudan.edu.cn

Guoping Long

Huawei Technologies Ltd.

robin3@huawei.com

Tao Zhang

University of Science and Technology of China

zhangtaolqy@mail.ustc.edu.cn

Jiajun Li

Huawei Technologies Ltd.

jiajun.work@huawei.com

Hongjie Si

Huawei Technologies Ltd.

sihongjie@huawei.com

Mingcong Song

Huawei Technologies Ltd.

songmingcong@huawei.com

Weiwei Sun

Fudan University

wwsun@fudan.edu.cn

September 29, 2026

ABSTRACT

High-performance kernels underpin efficient accelerator execution but require expert tuning and lengthy manual optimization cycles. LLM coding agents promise automation, yet their CUDA knowledge transfers poorly to data-scarce domain-specific architectures (DSAs) such as NPUs, whose execution models and memory hierarchies differ substantially from those of GPUs. To address this transfer gap, post-training methods adapt LLMs to NPU programming but depend on scarce expert data and substantial training compute. Memory-learning agents instead adapt through external memory, but their uniform credit assignment gives adopted and unused experiences the same reward target, potentially biasing subsequent retrieval rankings. Moreover, when learned values guide only retrieval, high-value experiences that generalize across operators must be retrieved repeatedly rather than retained in context, thereby increasing retrieval overhead and weakening cross-task guidance. We therefore present SAGE, a persistent self-improving agent for NPU kernel synthesis. Adoption-Traced Utility estimation (ATU) combines explicit adoption records with kernel evaluation outcomes for adoption-aware credit assignment. Utility-Gated Consolidation (UGC) uses positive utility and repeated adoption across operators to select and abstract reusable rules into a bounded resident context. On NPUKernelBench, SAGE achieves a 95.5% execution rate versus 84.1% for the strongest controlled baseline, with 86.9% of solved operators outperforming torch_npu. With GLM-5.3, SAGE achieves a 43.99× speedup over the torch_npu reference on sparse flash attention. These results show that adoption-aware credit assignment and selective consolidation enable agents to accumulate and reuse hardware-specific knowledge across tasks.

1 Introduction

Large Language Models (LLMs) have made rapid progress in CUDA and Triton kernel synthesis [1, 2, 3], benefiting from mature ecosystems with abundant public kernels, documentation, and optimization idioms [4]. Such resources serve as both large-scale pre-training signals and readily available supervision or retrieval sources for post-training and augmentation, allowing LLMs to achieve strong zero-shot performance and be further specialized with relatively low cost [5]. In contrast, emerging domain-specific architectures (DSAs) such as Ascend NPUs [6, 7] provide far less public code and require architecture-specific reasoning over memory hierarchies and execution models [8]. This distribution shift is substantial: GPT-5.2 drops from 92% CUDA correctness to 14% Ascend C correctness on KernelBench L1.

tasks [9, 10]. Thus, data-scarce kernel synthesis depends not only on generation but also on acquiring and reusing hardware-specific expertise under scarce supervision.

To address scarce NPU programming knowledge, post-training methods adapt LLMs through supervised fine-tuning (SFT) [11, 12] on hardware-aware data and reinforcement learning (RL) [13] with execution-based preferences [14]. Their scalability, however, is limited by scarce expert data and substantial training compute. Knowledge-augmented agents instead keep the backbone frozen and guide kernel generation and refinement with mined optimization experience [15] or structured domain knowledge [4]. Applying this knowledge to diagnose failures and revise kernels also generates new experience, raising the question of which experiences should guide subsequent tasks. Memory-learning methods in the broader agent literature address this through outcome-based values or dependency-aware credit propagation [16, 17, 18]. EvoKernel applies memory learning to NPU kernel synthesis but uses uniform credit assignment, a coarse-grained rule that gives every retrieved experience the same verifier reward target within an iteration [10]. A successful code repair can thus reward all top-k retrieved experiences even when the agent adopts only a small subset. Such uniform reward targets can give unused experiences favorable value estimates and higher priority in later retrieval, potentially crowding out more promising experiences with lower scores. Moreover, when learned values guide only retrieval, high-value experiences that generalize across operators must be retrieved again rather than retained in context, potentially adding retrieval overhead and limiting consistent guidance across tasks. Figure 1 contrasts retrieval-oriented memory learning with SAGE's finer-grained adoption-aware credit assignment and selective consolidation into a bounded resident context.

(a) Retrieval-Oriented Memory Learning

Figure

(b) SAGE

Figure 1: Retrieval-oriented memory learning with uniform credit and repeated retrieval (left) versus SAGE's adoption-aware credit assignment and selective consolidation into resident context (right).

Our central insight is to ground credit assignment and knowledge consolidation in evidence of use. Retrieval makes an experience available; recorded adoption indicates that it guided diagnosis or code revision. Adoption-aware credit assignment combines this evidence with the kernel outcome so that unused experiences do not receive the same credit as those adopted merely for being retrieved. A single adoption, however, does not establish transferability. Positive utility accumulated through repeated adoption across distinct operators provides evidence that an experience may encode a reusable NPU programming rule. Consolidating such rules into a bounded resident context makes them available to later tasks without requiring another successful retrieval.

Building on this insight, we propose SAGE, a self-improvement agent for NPU kernel generation and evolution. SAGE enables a frozen backbone LLM to evolve external memory through two complementary mechanisms. Adoption-Traced Utility estimation (ATU) combines explicit adoption records with episode-level verifier outcomes to update experience utility through adoption-aware credit assignment. Utility-Gated Consolidation (UGC) leverages positive utility and repeated adoption across operators to identify experiences for consolidation into reusable resident rules, while demoting underused rules under a fixed context budget.

Our contributions are as follows:

• We introduce SAGE, a self-improving agent for NPU kernel synthesis that enables frozen LLMs to accumulate and reorganize hardware-specific knowledge across tasks.

• We propose Adoption-Traced Utility estimation (ATU), an experience-level credit assignment mechanism that derives empirical utility estimates from adoption records.

• We propose Utility-Gated Consolidation (UGC), a utility-driven memory evolution mechanism that transforms reusable experiences into persistent knowledge.

• We evaluate SAGE across three backbones on NPUKernelBench, demonstrating consistent gains in kernel correctness and runtime performance.

References (31)