arXiv:2610.31034cs.AIOct 2026

Manuscript Offprint

arXiv:2610.31034

CANNBot-CAKE: Collaborative Agentic Kernel Evolution for Ascend NPU

Deng Pan, Xue-Jian Gao, Junyi Fan, Bin Du, Jiasheng Li, Xinxian Chen, Nok Yan Chang, Xinlin Li, Lingchao Zheng, Jun Li, Yuwei Fan

ABSTRACT

Efficient custom operators are essential for modern deep learning workloads, yet developing high-performance kernels for Ascend NPUs remains slow, expert-intensive, and difficult to automate. Although AI agents now approach expert performance on GPU kernel benchmarks, current models remain less capable of generating AscendC kernels for NPUs, potentially reflecting the relative scarcity of relevant training data. We thus present CAKE, a CANN-native system for deployable custom operators that combines adaptive multi-DSL routing, separate Generation and Evolution modes, and reviewed knowledge reuse through CAKE Book and a Self-Evolving Agent. On 53 CANN-Bench v1.1 operators on Ascend 950PR, CAKE's aggregated results achieve 100% case pass rate on the standard set (1,060/1,060) and 98.28% on the hidden set (4,167/4,240), with an overall mean score of 78.63 out of 100 and an average performance speedup of 1.334×1.334\times over the baseline. Evolution then pushes correct operators further: EngramGateFusion cuts aggregate device time by 46.6% over 20 rounds and roughly halves the mean roofline gap. These results offer a practical path toward closing Ascend's AI-for-kernel capability gap.

Keywords Agentic systems · Ascend NPU · CANN · AscendC · Kernel generation · Evolutionary optimization

1 Motivation and System Overview

An accelerator reaches its advertised throughput only when every operator in a model is backed by an efficient, hardware-tuned compute kernel. Kernel quality, not a chip's peak throughput, sets end-to-end performance, and writing these kernels by hand is slow and demands scarce low-level expertise. Automating that work has become an active research target.

Large language models have made that target newly reachable: coupled with execution feedback and search, they can generate correct and competitive GPU kernels. This progress rests on a favorable ecosystem. CUDA and Triton expose abundant open kernels, documented optimization idioms, and large public code corpora, so a model can recognize and adapt patterns it has effectively already seen. NPUs such as Ascend offer no comparable foundation; their vendor programming model, AscendC, appears only sparsely in public data. In published evaluations, general-purpose models succeed on essentially none of the complex AscendC kernels they attempt in a zero-shot setting [1], and one-shot AscendC pass rates remain at or below 2.1% where CUDA reaches 44.2–52.6% [2, 3]. These results motivate supplementing pretrained models with Ascend-specific programming knowledge and execution feedback.

∗^{*}These authors contributed equally: Deng Pan, Xue-Jian Gao.

†^{\dagger}gao.xuejian1@huawei.com

‡^{\ddagger}fanyuwei2@huawei.com

Ascend kernel development requires coordinating heterogeneous compute units over an explicitly managed on-chip memory hierarchy, with data movement, pipeline overlap, and synchronization all under program control (Appendix A describes the additional programming paths on Ascend 950). The consequence for a code-generating agent is that an Ascend operator is not a single kernel but a two-part artifact [3]: a host-side tiling program that decides how data are partitioned and moved, and a device-side kernel that decides how computation is scheduled. Performance is a property of the coordination between these two components: tiling determines the data available to each core, while the device kernel schedules computation and transfers.

In practice the bar is higher still. The unit an engineer can actually ship is neither a host program nor a device kernel in isolation, but a deployable CANN custom operator: one that builds, packages, installs, binds to Python, passes precision checks against a reference, and profiles on real hardware. Recent Ascend systems each automate one slice of this chain (Section 1.1 and Table 1)—training a model, transcompiling a domain-specific language (DSL), optimizing an existing kernel, or supplying curated domain knowledge to an evolutionary search. The last of these, AgenticCANN, is the closest prior system to ours and the one that most directly confronts the corpus problem: it organizes AscendC expertise into a six-level taxonomy, from hardware mental model down to verified kernel exemplars, and injects the levels selectively by evolutionary phase, raising the share of elementwise kernels it can synthesize from 57% to 86% on Ascend 910B [4]. This demonstrates the value of explicit domain knowledge. Its reported feasibility also varies by operator family: 90–100% on elementwise and normalization operators, but 56% on fusion, over a private 54-operator sample.

These results motivate a workflow that carries generated code through packaging and deployment while reusing the results of previous runs. Such a workflow needs to retain intermediate artifacts for debugging, use evaluation outcomes to guide generation, and make useful lessons available to later tasks.

We present CANNBot-CAKE (hereafter CAKE), an open-source CANN-native agentic workflow released in CANNBot, Huawei's official repository for Ascend agents. 1^{1} CAKE generates and evolves deployable Ascend operators from either a natural-language requirement or an existing AscendC baseline. CAKE uses existing language models to coordinate these stages. A request becomes an operator contract, then a PyTorch reference, a functional form, a routed DSL baseline, host-side tiling, device AscendC code, a CANN package, a Python binding, and an evaluation record—each a durable object that can be inspected, validated, and reused. A multi-DSL router chooses among four code-generation tracks using the operator's structural features and previous evaluation scores. It also explores less-tested tracks that may perform better. Generation mode produces one deployable operator through generation, validation, and repair. A profiling assistant, the Advisor, diagnoses performance bottlenecks and suggests changes. Evolution mode (CAKE-evo) runs a multi-round campaign that reuses shared artifacts, spawns isolated variants, and ranks them by compilation, precision, and performance. Candidates are scored by automated evaluation on CAKE-Bench, a user-defined evaluation suite that we instantiate with the official CANN-Bench task set [5]; a self-evolving agent mines those measured runs to improve the router, skills, and repair templates; and a cross-user knowledge base, CAKE Book, accumulates verified lessons in interlinked wiki pages [6].

Figure 1 summarizes five components of CAKE. First, a CANN-native staged pipeline (CAKE-Agents) turns operator intent into a deployable custom operator through Generation and Evolution modes, exposing every stage—contract, reference, DSL, host tiling, kernel, package, binding, and evaluation—as an inspectable object. Second, the CAKE-Router makes DSL choice an explicit, measured decision over four code-generation tracks: a capability gate removes infeasible track-chip-operator-type combinations, a per-track item-response model turns past evaluated operators into ability estimates adjusted for operator difficulty, and an information-gated exploration rule allocates additional evaluations to tracks that could overtake the incumbent (Section 3). Third, a Skills harness of more than thirty typed lifecycle tools—for description, lowering, optimization, evaluation, and debugging—gives the agents a reusable substrate for operator engineering (Section 2.1). Fourth, CAKE Book accumulates verified CANN experience as a cross-user wiki, shared and updated across users and agents and queried before generation. Fifth, a self-evolving agent closes the loop: continuous automated evaluation on CAKE-Bench produces measured signals that an analysis module mines to trace, judge, and edit skills and to promote evidence-gated improvements.

1^{1}https://gitcode.com/cann/cannbot-skills

Figure

Figure 1: CAKE architecture. Four stacked layers cooperate to turn an operator request into a deployable, benchmark-validated Ascend operator. CAKE-Agents provides the controllers—generation, the evolution main and sub-agents, and automatic benchmark adaptation. The CAKE-Router gates each request on track-chip-operator-type feasibility, then scores the surviving code-generation tracks against the operator's eight-dimensional structural profile, while the Skills harness supplies typed lifecycle tools for description, lowering, optimization, evaluation, and debugging. The CAKE Book is a cross-user encyclopedia maintained as a shared wiki, and CAKE-Bench is a user-defined evaluation suite—operator task specifications, test cases, precision requirements, and scoring—so that evaluation feedback is not tied to any single benchmark. A Self-Evolving Agent observes all layers: it traces, judges, and edits skills, analyses evolution runs, writes verified experience back to CAKE Book, and closes the loop with measured operator results.

back into the router, prompts, repair templates, and CAKE Book. The evidence in this report combines aggregated standard- and hidden-set results on 53 CANN-Bench operators on Ascend 950PR, replayable Router decisions, and operational evidence from the CAKE Book write path. The EngramGateFusion case study demonstrates multi-round optimization of a generated kernel. Section 7 outlines further development of the workflow and its evaluation.

Table 1 contrasts CAKE with the closest Ascend-native systems by their generation, optimization, delivery, and knowledge-reuse mechanisms.

References (24)