betaFeedback

WorksComputer Science

KernelShift: Benchmarking Kernel Optimization Across Evolving Hardware

Abstract

Efficient AI computation depends on hardware that evolves over time, shifting the strategies needed to implement performant code. For CPU kernels, a key evolving factor is the set of available architectural extensions, which expose specialized hardware instructions that change the techniques used to optimize kernels. We study how effectively coding agents use these new, potentially unfamiliar extensions to write fast code. We introduce KernelShift, a benchmarking pipeline and a set of environments for evaluating coding agents in kernel optimization across evolving CPU architectures. Its agent-assisted, human-verified pipeline turns code repositories into benchmark instances, and its environments let agents optimize code with feedback from the target hardware. Using this pipeline, we construct 99 kernels from real-world, actively developed repositories (ncnn, llama.cpp, Arm SIMD Loops, and KleidiAI), including inference workloads derived from real model executions. KernelShift supports incorporating new kernels and hardware configurations as libraries and processors evolve. We evaluate agents with proprietary and open-weight models across progressively newer architectural extensions (Arm Neon, SVE, SVE2, and SME2), examining how performance changes as hardware evolves. On established extensions, agents beat the auto-vectorized compiler everywhere (2.4-19.8x) and exceed general-purpose libraries such as ncnn (getting up to 2.74x over its Neon kernels), but fall behind Arm's hand-tuned KleidiAI kernels (0.70x). In end-to-end inference of two LLMs, agent-written kernels achieve a 1.3-1.6x prefill speedup over llama.cpp's fast path. However, current agents do not yet reliably adapt to new extensions that require unfamiliar programming models, such as SME2's matrix tiles.

Introduction

Modern ML workloads run across an increasingly diverse range of hardware, from CPUs to GPUs with different architectures and capabilities [28]. As these platforms continue to evolve, the optimization strategies needed to use them efficiently evolve as well. Meanwhile, AI coding agents are increasingly being used to optimize performance-critical code. For example, frontier labs such as OpenAI report using AI models to autonomously rewrite and optimize production GPU kernels [16, 25]. As AI agents take on more performance-critical optimization, an important question is whether they can adapt their optimization strategies as the underlying hardware evolves over time.

In CPUs, hardware evolution often takes the form of new architectural extensions, which introduce new instructions and expose them to programmers through a new interface. Extensions can improve performance, but exploiting them often requires fundamentally restructuring a kernel’s implementation. For example, Arm’s matrix extensions support accumulating products directly into 2D matrix tiles, enabling implementations of matrix multiplication that differ from those based on earlier 1D vector instructions [8, 29]. An agent can therefore produce correct but suboptimal code if it relies on older vector instructions when newer matrix instructions would be advantageous.

To study kernel optimization under evolving hardware, we introduce KERNELSHIFT (Figure 1 (left)), a benchmarking pipeline and a set of environments for evaluating AI coding agents across evolving CPU architectures. The key idea is to evaluate how agents optimize matched kernels, where coverage permits, across successive architectural extensions that shift the space of performant implementations. Specifically, we evaluate agents across Arm’s vector and matrix extensions (i.e., Neon, SVE, SVE2, and SME2), which provide instructions for parallelizing computations common in machine learning workloads ([31, 8]). Our work builds on a growing literature on hardware-aware kernel optimization ([19, 37, 39]), with a specific focus on sequences of hardware changes that expose progressively newer programming interfaces.

Figure 1. Overview of KERNELSHIFT. (Left) Evolving hardware changes the space of performant kernel implementations, requiring both human engineers and coding agents to continually adapt their strategies. (Right) To study this adaptation, KERNELSHIFT constructs benchmark tasks from real-world sources and model executions using an agent-assisted, human-verified pipeline.

We design an agent-assisted, human-verified pipeline with source-specific adapters for transforming code repositories into benchmark instances (Figure 1 (right)), together with environments that let agents iteratively optimize code using compilation and performance feedback from the target hardware (Figure 2). Using this pipeline, we construct 99 kernel specifications from real-world, actively developed repositories, including workloads derived from real model executions. The pipeline and environments are designed to incorporate new kernels and hardware configurations as libraries and processors evolve.

Figure 2. Figure 2: Evaluation architecture of KERNELSHIFT. A unified server exposes the same tools and skills to all agent harnesses and routes their requests to evaluators running on the target hardware.

We evaluate coding agents with proprietary and open-weight models across progressively newer Arm architectural extensions. We measure both optimization performance and their use of newly available instructions, comparing their implementations against compiler-optimized code, production-library implementations, and expert kernels where available. Agents readily find headroom on established vector extensions: on SVE, they beat the auto-vectorized compiler in every source family and exceed general-purpose libraries such as ncnn (getting up to 2.74×2.74\times over its Neon kernels within 40 tool calls), but fall behind Arm’s hand-tuned KleidiAI kernels (0.70×0.70\times). However, this does not reliably carry over to newer programming models: on SME2, agents end up far slower than the expert kernels.

Our main contributions are:

  • KERNELSHIFT, a benchmarking pipeline and a set of environments to evaluate coding agents on evolving hardware and programming interfaces. The agent-assisted, human-verified pipeline supports adding kernels and hardware configurations as software libraries and processors evolve.

  • A benchmark of 99 real-world CPU kernels built with this pipeline, including workloads derived from real model executions.

  • An empirical study of coding agents across Arm architecture extensions, measuring both optimization performance and agents’ ability to exploit newly available hardware instructions.

KernelShift

Our goal is to evaluate agents’ ability to write performant code for evolving hardware. We introduce our problem setting, motivate our use of architectural extensions to distinguish stages of CPU hardware evolution, and describe our automated pipeline for collecting benchmark instances.

Hardware-aware kernel optimization. We consider the setting of hardware-aware kernel optimization. In this setting, a kernel is a program that performs a specific computation, such as a matrix multiplication. Each task consists of an initial kernel implementation xx, together with context cc. The context includes the function signature, symbolic tensor shapes, and data types. Concrete workload dimensions and input values remain hidden (Appendix § 9.§ 3).

The kernel is executed on target hardware, h=(I,m)h = (I, m). Here, II denotes the target instruction-set architecture (ISA), including base instructions and those introduced by supported architectural extensions. Programmers can access specialized instructions through intrinsics: compiler-supported operations exposed in C/C++. The microarchitecture mm is a concrete processor design that implements II on physical hardware. In general, the goal is to develop an agent AA that takes in an initial implementation, context, and hardware, and produces an optimized implementation x′=A(x,c,h)x' = A(x, c, h):

max⁡AE(x,c)∼D, h∼H[s(x,A(x,c,h))](1)\max_A \mathbb{E}_{(x,c)\sim\mathcal{D},\,h\sim\mathcal{H}} \left[s\left(x,A(x,c,h)\right)\right] \tag*{(1)}

where D\mathcal{D} is a distribution of optimization tasks and H\mathcal{H} is a distribution of hardware configurations.

For a fixed task and target hardware, the score s(x,x′)s(x, x') is the geometric mean speedup over the task’s optimized reference across nn hidden workloads, which specify input configurations such as matrix dimensions. That is, let tireft_i^{\mathrm{ref}} and ti′t_i' denote the runtimes of the optimized reference and the agent implementation on workload ii. The score is:

s=(∏i=1ntirefti′)1/n,(2)s = \left(\prod_{i=1}^{n} \frac{t_i^{\mathrm{ref}}}{t_i'}\right)^{1/n}, \tag*{(2)}

with s=0s = 0 if the agent implementation fails any correctness check (Appendix § 8.§ 3).

Evolving hardware. Rather than sampling hardware configurations to approximate Equation (1), we are interested in sequences of hardware configurations that introduce new functionality to a common base architecture,

h1⟶h2⟶⋯⟶hT.(3)h_1 \longrightarrow h_2 \longrightarrow\cdots\longrightarrow h_T. \tag*{(3)}

The kernel’s desired functionality remains fixed across the sequence, while the implementations that realize the functionality efficiently may change substantially.

Specifically, we primarily focus on changes to the available instruction set II through new extensions, since new extensions can introduce different ways to optimize computations and hence cause large shifts in the space of performant programs. For example, as illustrated in Figure 1, Arm’s Neon extension exposes fixed-width vector operations, while the later scalable vector extensions (SVE, SVE2) support code that adapts to different vector widths and provide additional vector operations. The more recent scalable matrix extension (SME) introduces dedicated matrix storage and instructions for accumulating vector outer products into matrix tiles, enabling new ways to implement matrix multiplication.

Motivated by these architectural shifts, we evaluate agents’ kernel optimization performance across such evolving extensions. In particular, we investigate whether the choice of extension impacts agent performance, and whether agents can effectively leverage newer intrinsics that are underrepresented in their training data. Therefore, we construct an automated benchmark framework that seamlessly accommodates new extensions as they arise. The benchmark design and automated generation techniques are detailed next.

Agent-Assisted Task Construction

Our construction framework turns performance-critical kernels from open-source projects into benchmark tasks. For each kernel, it constructs a portable C++ starting implementation xx, the context cc exposed to the agent, hidden workloads, and, when available, an optimized reference. Tasks are constructed by coding agents following fixed procedures backed by deterministic generation and validation scripts. Human input is limited to a few decisions: selecting kernels, approving workloads where no model execution can be traced, and reviewing the resulting expert references. Appendix § 8 documents the complete construction process.

Kernel and reference construction. For each source repository, a construction agent follows a fixed procedure (Appendix § 8.§ 1) to identify candidate kernel computations and extract their fixed configuration parameters and variable workload dimensions. It then constructs a portable C++ starting implementation using simple loop-based code. When the repository contains an optimized implementation of the same kernel, the agent also extracts it as the optimized reference.

Workload construction. To capture realistic workloads, we derive input configurations from real model executions whenever possible. For model-derived kernels, the construction agent first identifies the source model in which the kernel appears. Fixed configuration parameters then come from this model, while dimensions are collected from execution traces. For example, ncnn workloads come from vision-model executions, while llama.cpp workloads are collected during LLM inference on ShareGPT prompts ([30]). We keep the observed tensor shapes rather than the original activation values, under the assumption that kernel performance is driven primarily by tensor dimensions and operator configuration rather than the specific numerical values of the activations. We then deduplicate and subsample the collected shapes to form the hidden evaluation workloads. For kernels without a clearly identifiable source model, we instead synthesize workloads in two groups: correctness-oriented cases that cover corner cases, and performance-oriented cases that probe efficiency over representative problem sizes. More details appear in Appendix § 8.§ 2.

Finalizing benchmark tasks. Finally, we package the starting implementation, agent-visible context, evaluation workloads, and the optimized reference from the source library, when available, into a self-contained benchmark task. Each task is validated by compiling and running the starting implementation on the target hardware before it is included in KERNELSHIFT.

Benchmark Composition and Coverage

We apply the construction framework from § 2.1 to several widely used, performance-critical open-source repositories.

Composition. KERNELSHIFT currently contains kernel tasks derived from four sources (Table 1): ncnn ([32]), llama.cpp ([18]), Arm SIMD Loops ([7]), and KleidiAI ((Arm, 2024)). Together, they cover computer-vision and LLM inference kernels, general SIMD workloads, and vendor-optimized microkernels across a range of data types and optimization patterns. The ncnn and llama.cpp tasks are derived from 11 source models, providing kernel configurations representative of real model architectures. Appendix § 7 and Appendix § 7.§ 2 provide the full composition and per-generation coverage.

SourceOp typesPrecisionsExpert reference#Kernels
ncnnconv, dwconv, poolFP32, INT8 (w8a8ch)ncnn Neon23
llama.cppgemm, moe, attn, rmsnormFP32, BF16, q8_0, q4_K_Mggml26
SIMD Loopsloops (reduction, string, search, …)fp/int/uintArm SVE24
KleidiAIgemm, conv, dwconv (NHWC)FP32, FP16, BF16, INT8, INT4, INT2KleidiAI26 (6 SVE, 20 SME2)
Total99

Table 1. Composition of KERNELSHIFT. We apply our kernel collection pipeline to common or vendor-provided repositories, resulting in a wide range of kernels.

Workloads. KERNELSHIFT contains approximately 1.6K workloads across the 99 kernel specifications, constructed as described in § 2.1 and spanning a broad range of tensor dimensions and sequence lengths.

Hardware and reference coverage. The 99 kernels form the union across targets: every task can be instantiated on each target, but an optimized reference is not available for every source on every generation, so each generation uses the tasks that have one. For each task, the reference is a strong production or expert implementation available on the target (Appendix § 7.§ 2).

Evaluation Environment

KernelShift uses a centralized control plane to run agent harnesses and coordinate evaluation across distributed target machines (Figure 2).

Hardware-in-the-loop evaluation. Each target platform is backed by an evaluator running directly on its hardware. When an agent calls a tool, the request is routed to this evaluator, which compiles and executes the candidate on the target machine and returns the feedback, so that correctness and performance measurements reflect the hardware being evaluated. This design decouples the agent harness from target-specific execution, allowing the same agent setup to be used across hardware platforms. Appendix § 9 gives the deployment configurations.

Unified agent interface. To compare different agent systems under the same environment, KernelShift exposes a harness-agnostic interface through which all agents access the benchmark. The interface provides the same three benchmark tools to every harness: compile, evaluate, and disassemble. These tools allow agents to iteratively refine their solutions with correctness, performance, and low-level instruction feedback from the target hardware. Appendix § 9.§ 3 provides the complete prompts, skills, and tool schemas.

Measurement and integrity. Correctness is checked before performance is measured, and both agent implementations and comparison baselines are tested on the same target machine under the same timing protocol. We use wall-clock execution time as the common performance measure across platforms, since hardware cycle counters are not consistently available on all target systems. Performance is reported as the speedup of a kernel over its expert reference on the same machine. Measurements use repeated runs on a single core, and each evaluation runs in an isolated process to prevent interference between evaluations. We also reject implementations that violate the benchmark constraints, such as using multithreading. Full timing, isolation, and integrity details are provided in Appendix § 9.§ 4.

Experimental Setup

Models and harnesses. We evaluate six frontier language models: Claude Opus 4.8 [4] and Claude Sonnet 4.6 [5], GPT-5.6-sol and GPT-5.6-luna [16], DeepSeek-V4-Pro [13], and GLM-5.3 [42]. We pair these models with four harnesses: Claude Code [2], Codex [26], nanobot [20], and a minimal tool-call loop. We evaluate Claude Code and Codex with their own models, while nanobot provides a common harness across all six models to disentangle model and harness effects. The end-to-end study (§ 4.5) additionally uses Claude Fable 5.1 [3] with Claude Code. Appendix § 9.§ 3 contains full model and harness configurations.

Task sets. Our experiments draw from the 99-kernel benchmark, with generation-specific coverage: The SVE comparison contains 79 kernels (23 ncnn, 26 llama.cpp, 24 SIMD Loops, and 6 KleidiAI). We use a 32-kernel subset for ablations and controlled studies.

Hardware and budgets. We evaluate SVE on Graviton3 (AWS c7g), SVE2 on Graviton4 (AWS c8g), and SME2 on Apple M4. Each run receives a budget of T=40T = 40 tool calls, with compile, evaluate, and disassemble calls all counting toward the budget. For test-time scaling experiments, we extend the budget to 100 tool calls.

Metrics. Our primary metric, Speedup@40, is the score ss (§ 2) of the best correct implementation within 40 calls, averaged geometrically over kernels. We also report the fraction of kernels that beat the reference and compiler baselines, and performance versus budget.

Results

Agents find substantial speedups

Strong coding agents can exploit substantial optimization headroom in production kernels. On SVE, the best systems reach 2.74× the ncnn reference, 1.95× the llama.cpp reference, and 1.56× the SIMD Loops reference (Table 2). In contrast, compiler-based automatic optimization remains far behind expert references, with even −O3 and SVE reaching at most 0.47×. The −O3, SVE-enabled build is also the code that each agent starts from. Every system is faster than this −O3 reference across all four repositories (2.4–19.8×; Appendix § 10).

HarnessModelncnn (23)llama.cpp (26)SIMD Loops (24)KleidiAI (6)
Claude CodeClaude Opus 4.82.574 (96%)1.779 (73%)1.555 (96%)0.701 (33%)
Claude CodeClaude Sonnet 4.61.934 (83%)1.243 (46%)1.516 (100%)0.386 (33%)
CodexGPT-5.6-sol1.815 (78%)1.297 (62%)1.487 (96%)0.431 (17%)
CodexGPT-5.6-luna0.674 (35%)0.627 (27%)1.127 (79%)0.147 (0%)
nanobotClaude Opus 4.82.597 (91%)1.708 (73%)1.521 (96%)0.453 (17%)
nanobotClaude Sonnet 4.62.046 (87%)1.449 (62%)1.503 (96%)0.231 (0%)
nanobotGPT-5.6-sol2.156 (87%)1.334 (58%)1.543 (100%)0.319 (0%)
nanobotGPT-5.6-luna1.110 (57%)0.878 (31%)1.182 (79%)0.161 (0%)
nanobotDeepSeek-V4-Pro1.091 (57%)0.850 (46%)1.458 (88%)0.231 (17%)
nanobotGLM-5.32.743 (91%)1.954 (85%)1.545 (96%)0.499 (17%)
tool-call loopClaude Opus 4.82.308 (83%)1.828 (73%)1.480 (92%)0.496 (33%)
tool-call loopClaude Sonnet 4.62.043 (87%)1.915 (81%)1.521 (100%)0.297 (17%)
tool-call loopGPT-5.6-sol1.999 (91%)1.671 (81%)1.513 (96%)0.307 (33%)
tool-call loopGPT-5.6-luna0.955 (48%)0.854 (31%)1.245 (75%)0.164 (17%)
single-shot, no tools (Claude Opus 4.8)†0.577 (35%)0.324 (8%)0.852 (42%)0.152 (0%)
Reference tiers
scalar + -O2 (no vectorization)0.190 (0%)0.090 (8%)0.248 (0%)0.025 (0%)
scalar + -O2 (Neon auto-vectorized)0.191 (0%)0.117 (12%)0.398 (17%)0.031 (0%)
scalar + -O3, SVE enabled0.229 (9%)0.126 (15%)0.468 (25%)0.035 (0%)

Table 2. Results on SVE (Graviton3). Each cell reports the geometric mean over kernels of Speedup@40 against the source’s expert reference and, in parentheses, the fraction of kernels that beat references (>1). The best speedup in each column is in bold. Each row is an end-to-end system (harness and model) run under the same limits, so rows compare systems rather than models alone. †For correctness failures, we substitute the starter-kernel score.

Highly tuned vendor kernels remain substantially more competitive. On the six KleidiAI kernels with SVE expert references, no evaluated system matches the vendor implementations in geometric mean; the best, Claude Code with Claude Opus 4.8, reaches 0.70×, beating the reference on two kernels but falling behind on the other four. Agents exploit headroom in general-purpose production libraries, but matching specialized vendor kernels is harder.

Adapting to Evolving Hardware

Agents struggle more with the programming-model shift to SME2. The biggest drop appears on SME2, which introduces streaming mode and ZA matrix tiles instead of just adding more vector instructions. On the same KleidiAI kernels, performance relative to the expert reference falls from SVE to SME2 for three of the five models: the SME2-to-SVE ratios are 0.42, 0.46, and 0.41 for DeepSeek-V4-Pro, GLM-5.3, and GPT-5.6-luna, while the performance of the Claude models remains similar (Table 4). GLM-5.3, the strongest of the five models on SVE, falls to less than half, so doing well on SVE does not carry over when a new extension requires a different programming style.

ModelBeforeAfterRatio
KleidiAI: SVE (6) →\to SME2 (6)
Claude Opus 4.80.436±.020.436 \pm.020.562±.200.562 \pm.201.291.29
Claude Sonnet 4.60.258±.020.258 \pm.020.266±.020.266 \pm.021.031.03
DeepSeek-V4-Pro0.213±.030.213 \pm.030.091±.010.091 \pm.010.420.42
GLM-5.30.464±.050.464 \pm.050.213±.190.213 \pm.190.460.46
GPT-5.6-luna0.178±.040.178 \pm.040.073±.010.073 \pm.010.410.41
SIMD Loops: SVE (8) →\to SVE2 (8)
Claude Opus 4.81.859±.211.859 \pm.211.957±.021.957 \pm.021.051.05
Claude Sonnet 4.61.750±.181.750 \pm.181.752±.121.752 \pm.121.001.00
DeepSeek-V4-Pro1.587±.181.587 \pm.181.504±.161.504 \pm.160.950.95
GLM-5.31.929±.071.929 \pm.071.810±.191.810 \pm.190.940.94

Table 4. Cross-generation adaptation. Speedup@40 against the expert implementation of the older (Before) and newer (After) generation; Ratio = After / Before. Mean ±\pm s.d. of 3 seeds.

We also run the fixed-machine ladder on Apple M4, with GPT-5.6-luna as the base model and nanobot as harness. Over three seeds, exposing streaming SVE lowers Speedup@40 from 0.141 (Neon only) to 0.059, and exposing full SME2 recovers part of the loss, to 0.085 (Table 3). Neon > SME2 > streaming SVE holds in every seed. The performance gap mostly comes from the different optimization paths that the agent applied. With streaming SVE available, the agent almost abandons Neon and settles on streaming SVE or falls back to plain C if compilation or correctness errors repeatedly happen. With full SME2 available, the recovery over streaming SVE does not come from ZA outer products: the agent simply keeps a Neon kernel more often than with streaming SVE only (Appendix § 13). None of the final SME2-tier kernels use ZA outer products, and across all SME2 runs the agent writes ZA code only twice, with neither version passing. Streaming and ZA code also fail to compile more often: in the first seed, 13% of compiles fail on the Neon tier, 20% with streaming SVE and 24% with full SME2 (Appendix § 13).

ArmInstructions availableSpeedup@40
Graviton4, 32-kernel subset
L1Neon only1.105±.071.105 \pm.07
L2+ SVE0.953±.060.953 \pm.06
L3+ SVE21.101±.011.101 \pm.01
Apple M4, KleidiAI SME2 set (20 kernels)
L4Neon only0.141±.010.141 \pm.01
L5+ streaming SVE (no ZA)0.059±.0040.059 \pm.004
L6+ ZA / FMOPA0.085±.0060.085 \pm.006

Table 3. Instruction-set ladders on fixed hardware. Holding the machine and task set fixed, we progressively expose newer instructions; every arm is scored against the same reference. Speedup@40 of nanobot+GPT-5.6-luna, mean ±\pm s.d. of 3 seeds. Per-arm compile flags are in Appendix § 9.§ 2; failure analysis is in Appendix § 13.

SME2 Case Study. On gemm_bf16_n512_k512, Claude Opus 4.8 switches to streaming mode and uses MOPA/ZA accumulation, reaching 0.94×0.94\times the expert implementation. Claude Sonnet 4.6 and DeepSeek-V4-Pro, in contrast, stay with older vector-style implementations and reach only 0.06×0.06\times and 0.05×0.05\times. The same holds across kernels: nearly all final SVE solutions use SVE intrinsics, but of the 18 final SME2 solutions on the six KleidiAI kernels of Table 4 (three seeds), only 15 (Opus), 5 (Sonnet), 5 (GLM-5.3), and 1 (DeepSeek-V4-Pro) use the ZA tiles (Appendix § 12). Appendix § 11.§ 2 traces in detail a representative SME2 optimization trajectory.

Agents adapt more readily to incremental ISA extensions. By contrast, the move from SVE to SVE2 costs much less. On the eight SIMD Loops kernels whose expert SVE2 implementation needs SVE2-only instructions, the SVE2-to-SVE ratios are between 0.94 and 1.05 for every model (Table 4), and most final SVE2 solutions of the Claude models use the expert’s SVE2-only instructions (Appendix § 12). The fixed-machine instruction ladder on Graviton4 shows the same pattern: Neon and SVE2 reach 1.105×1.105\times and 1.101×1.101\times (Table 3). The main gap comes from how agents implement kernels on Graviton4’s 128-bit SVE vectors: about half of the gap comes from runs where the agent never got SVE code past the correctness check and fell back to scalar code. The other half comes from SVE code that is correct but slower, where the agent did not use the right SVE instructions (Appendix § 9.§ 2). This is a milder form of the SME2 failures above: when agents do not use a newer programming interface well, their kernels end up slower than plain Neon code.

Agent Gains Depend on Expert Headroom

Across the 79 SVE kernels, median agent Speedup@40 decreases as the expert reference becomes stronger relative to unvectorized scalar code (Spearman ρ=−0.69\rho= -0.69; ρ=−0.75\rho= -0.75 within llama.cpp; Figure 3). Thus, large Speedup@40 values often reflect under-optimized reference paths rather than unusually strong agent performance. This is clear in llama.cpp RMSNorm: the reference is only 1.3×1.3\times faster than scalar, while agents beat it by a median 6.0×6.0\times. Conversely, for q4_K_M GEMM and MoE, the expert implementations are already 2525–29×29\times faster than scalar, and agents reach only 0.570.57–0.69×0.69\times of the expert.

Figure 3. Agents gain more when expert kernels are less optimized. One point per kernel. xx: expert speedup over the scalar reference; yy: median Speedup@40 across harness–model cells. Dashed lines show constant agent speedup over scalar (3×3\times, 10×10\times, 30×30\times).

What Improves Agent Optimization?

As shown in Figure 4, most of the improvement is realized within the first 40 tool calls, but budget beyond 40 still pays off: Claude Sonnet 4.6 is 23–25% higher at 100 calls than at 40. This additional gain, however, comes mainly from a few kernels undergoing structural rewrites between roughly 40 and 60 calls, and past 60 calls the curves are largely converged.

Figure 4. Test-time scaling of agents. Best-so-far Speedup@tt against the expert reference as a function of the tool-call budget tt. Most agent progress is within 40 steps.

SettingSpeedup@40
SVE
Control1.074
+ Arm docs0.997
+ cross-kernel notepad0.974
− disassemble tool0.999
No intrinsics0.300
SME2, 20 KleidiAI kernels
Control0.083
+ Arm docs0.130
+ SME2 pitfalls in prompt0.167

Table 5. Ablations (nanobot + GPT-5.6-luna): SVE on the 32-kernel subset, SME2 on the 20 KleidiAI SME2 kernels.

Arm documentation does not improve performance on SVE. On SME2 it raises Speedup@40 (0.130 vs. 0.083), but not through better SME2 code: with the documentation, no best version uses streaming SVE (vs. 6 without it), 14 of the 20 use Neon (vs. 7), and compile errors drop from 102 to 54. Putting common SME2 pitfalls in the prompt, with failure examples, doubles Speedup@40 on the 20 KleidiAI SME2 kernels (0.083 to 0.167), but 5 of the 20 kernels get worse.

Some tools contribute little in practice. The cross-kernel notepad does not improve performance, while removing the disassembly tool does not lower performance. Inspection of agent trajectories shows that agents rarely use disassembly, while human experts frequently use it while designing advanced kernels. In contrast, forbidding SIMD intrinsics, so that agents must rely on compiler auto-vectorization, lowers performance from 1.074 to 0.300: most of the agents’ gains come from correctly using the provided intrinsics.

From Kernel Optimization to End-to-End Potential

To test whether kernel-level gains can translate into application-level improvements, we use Claude Code with Fable 5.1 to optimize 11 quantized matrix-multiplication kernels for Qwen3.5-4B and 7 kernels for Llama-3.1-8B-Instruct (both Q4_K_M), served with llama.cpp on Graviton4, and substitute the resulting shape-specialized implementations into the inference stack.

Compared with the original llama.cpp using its repacked i8mm fast path, the agent kernels speed up prefill by 1.301.30–1.57×1.57\times and decode by 1.041.04–1.10×1.10\times across 1–16 threads for both models (Table 6). Perplexity is unchanged on both models.

ThreadsQwen3.5-4B PrefillQwen3.5-4B DecodeLlama-3.1-8B-Instruct PrefillLlama-3.1-8B-Instruct Decode
11.3951.0451.5681.099
41.3481.0591.4541.069
161.2981.0481.3911.102

Table 6. End-to-end speedup from agent-optimized kernels. Qwen3.5-4B and Llama-3.1-8B-Instruct (Q4_K_M) on Graviton4, relative to original llama.cpp.

Gains come from adaptation to hardware. All 18 kernels use Graviton4’s i8mm instructions together with shape-specific tiling, layout, and prefetching. Individual kernels average 1.5×1.5\times faster than llama.cpp’s own repacked kernels if measured in isolation. Unlike llama.cpp’s general kernels, the agent-generated kernels are specialized to the target models’ shapes, so this shows the potential of automatic deployment-time specialization over expert libraries. Appendix § 11.§ 1 provides complete setup and detailed results.

Related Work

Kernel optimization across hardware. Recent work evaluates whether language models and coding agents can generate efficient kernels for a given hardware target or programming interface. KernelBench and TritonBench study GPU kernel generation [27, 21], while MobileKernelBench and SimdBench extend to mobile CPUs and SIMD intrinsics [43, 19]. Other benchmarks extend kernel evaluation across architectures and devices [22, 37, 39, 9]. These works primarily evaluate performance on a fixed target or a set of hardware targets. In contrast, KERNELSHIFT organizes hardware as a sequence of successive architectural extensions and evaluates matched kernel tasks across generations where coverage permits. This lets us study adaptation to new instructions and programming abstractions.

Coding agents for performance optimization. Recent coding agents improve programs through iterative execution and feedback [38, 35]. For kernel optimization, GPU Kernel Scientist and CudaForge use iterative search and hardware feedback, while AdaExplore combines execution-driven adaptation with diversity-preserving search [1, 40, 14]. More recent systems train kernel-optimization agents with reinforcement learning [12, 17]. These works show rapid progress in agentic kernel optimization. KERNELSHIFT provides both a controlled benchmark and a hardware-in-the-loop environment for testing whether such agents can adapt their optimization strategies as hardware evolves.

Automated program optimization. A broader line of work studies program optimization using learned cost models, reinforcement learning, and search [10, 41, 33, 11, 36, 23, 15, 25]. However, automated optimizers can still fall short of expert implementations when performance depends on hardware-specific transformations [24 Tschand] et al., 2026). This gap motivates coding agents that can optimize kernels through interaction with real hardware.

Conclusion

We introduced KernelShift, a benchmarking pipeline and set of environments to study how well coding agents optimize kernels as hardware evolves. Our results show that stronger agents can match or beat production kernels on established vector ISAs, but they struggle with programming-model shifts such as SME2. At the same time, the end-to-end speedups that agent-written kernels deliver on two LLMs highlight the potential of agent-driven kernel optimization in real deployments.

Limitations. Newer hardware is harder to evaluate because strong expert implementations are often not available, which limits how many kernels we can compare across generations; in particular, our SME2 evidence rests on the 20 KleidiAI kernels that have an SME2 expert reference. Our experiments also focus on Arm CPUs, so it remains to be seen whether the same trends hold for other architectures such as x86 or GPUs. Finally, our kernel-level evaluation is single-core and does not cover all effects that may appear in multi-core deployment.

AI Use Statement

AI agents are the primary subject of this study. We also used AI tools to assist with research code generation, benchmark data collection and synthesis, and wording refinement. All AI-generated code, benchmark instances, and paper refinements were reviewed and verified by the authors. The authors were responsible for the code, experiments, and manuscript.

Ethics Statement

KernelShift is constructed from open-source software, and all redistributed code follows the licenses of the original repositories: ncnn (BSD-3-Clause), llama.cpp (MIT), Arm SIMD Loops (BSD-3-Clause), and KleidiAI (Apache-2.0). The study does not involve human subjects.

Reproducibility Statement

The code for the benchmark, including the scripts for evaluating the coding agents, is available at https://github.com/cmu-l3/kernel-shift, and the dataset at https://huggingface.co/datasets/l3lab/KernelShift.

Acknowledgments

This work was supported in part by SoftBank Group Corp. and Arm. This program was made possible (in part) due to the generosity of SoftBank Group Corp. We thank our collaborators at Arm for their support and collaboration.

Benchmark Composition Details

Composition by source

KernelShift contains 99 kernel specifications in the evaluation set across four source families: 23 from ncnn ([32]), 26 from llama.cpp ([18]), 24 from Arm SIMD Loops ([7]), and 26 from KleidiAI ((Arm, 2024)). The KleidiAI inventory comprises six SVE tasks and 20 SME2 tasks.

Table 7 lists the operators each source contributes, their precisions, and where the workload shapes and the expert reference come from.

SourceKernelsPrecisionsWorkload shapesExpert reference#
ncnnconv2d (10), depthwise conv2d (8), pooling (5)FP32, INT8 (w8a8ch)6 vision models: ResNet50, MobileNetV3-Large, VGG16, GoogLeNet, AlexNet, SqueezeNet1.1ncnn Arm (Neon) layers23
llama.cppGEMM (15), MoE (6), attention: MHA, GQA, MLA prefill, MLA decode (4), RMSNorm (1)BF16, q8_0, q4_K_M, FP325 LLMs on ShareGPT prompts: Qwen1.5-MoE-A2.7B, OLMoE-1B-7B, DeepSeek-V3, Llama-3.1-8B, Mistral-7Bggml CPU kernels26
Arm SIMD Loopsreductions and dot products (9), element-wise arithmetic (4), complex arithmetic (4), convolution and correlation (2), string and pixel processing (2), search and conditional update (2), INT8 matrix–vector product (1)FP16–FP64, INT8–INT64edge-case and performance sizesArm’s hand-written SVE version of each loop24
KleidiAISVE: GEMM (5; FP32, INT8, INT4), conv2d 3×3 (1). SME2: GEMM (16; FP32, FP16, BF16, INT8, INT4, INT2), conv2d 3×3 (2), depthwise conv2d 3×3 (2)FP32, FP16, BF16, INT8, INT4, INT2edge-case and performance sizesKleidiAI SVE and SME2 micro-kernels6 + 20
Total99

Table 7. Kernel sources in KERNELSHIFT. Numbers in parentheses are kernel counts.

Task sets per experiment

Table 7 lists what the benchmark contains; Table 8 lists which kernels each experiment uses, on which machine, and against which reference. The main comparison uses the full SVE set, and the other experiments use subsets chosen so that every arm or generation being compared has the same kernels and valid reference baselines.

ExperimentWhereMachineHarness, modelKernelsReference
Main comparisonTab. 2G3all 14 pairs23 / 26 / 24 / 6 (79)expert
ISA ladder L1–L3Tab. 3G4nanobot, GPT-5.6-luna32-subset: 10 / 9 / 12 / 1expert, same in every arm
ISA ladder L4–L6Tab. 3M4nanobot, GPT-5.6-lunaKleidiAI SME2: 20expert, same in every arm
KleidiAI SVE→SME2Tab. 4G3→M4nanobot, 5 modelsKleidiAI: 6 → 6KleidiAI SVE → SME2
SIMD Loops SVE→SVE2Tab. 4G3→G4nanobot, 4 modelsSIMD Loops: 8Arm SVE → SVE2 versions
Ablations, SVETab. 5G3nanobot, GPT-5.6-luna32-subset: 10 / 9 / 12 / 1expert
Ablations, SME2Tab. 5M4nanobot, GPT-5.6-luna32-subset (SME2 version): 10 / 9 / 12 / 1expert
Test-time scalingFigure 4G3nanobot, GPT-5.6-luna; Claude Sonnet 4.611 / 8 / 0 / 0 (19)expert
End-to-endApp. E.1G4Claude Code, Claude Fable 5.111 Qwen3.5-4B and 7 Llama-3.1-8B-Instruct GEMMsggml; original llama.cpp

Table 8. Task set of each experiment. Kernel counts are ncnn / llama.cpp / SIMD Loops / KleidiAI. G3, G4: Graviton3, Graviton4.

32-kernel subset. A dtype-balanced sample of the benchmark. FP32 and w8a8ch versions of depthwise 3×3 and 5×5 (stride 1), conv2d 3×3 (stride 1) and 7×7 (stride 2), global average pooling, and 3×3 max pooling (stride 2). llama.cpp: GEMM BF16, q4_K_M and q8_0 (N=K=2048N=K=2048), GEMM q8_0 (N=1408N=1408), MHA, and MoE BF16, q4_K_M and q8_0 (OLMoE). SIMD Loops: loop_001, 002, 003, 024, 027, 035, 037, 105, 108, 113, 126, 127. KleidiAI: FP32 GEMM, in its SVE version on Graviton and its SME2 version on M4.

SIMD Loops across generations. loop_103, 105, 108, 109, 110, 112, 113, and 114: loops whose Arm SVE2 implementation does not compile without SVE2 (i.e., it uses SVE2-only instructions such as svcdot, svcmla, or svmatch). Table 4 reports the mean of three seeds.

Test-time scaling subset. 19 ncnn and llama.cpp kernels, mostly from the 32-kernel subset. The Claude Sonnet 4.6 curves use the main-comparison runs restricted to these kernels.

End-to-end kernels. The 11 quantized GEMM shapes of Qwen3.5-4B, given as (NN, KK): q4_K at (1024, 2560), (2560, 4096), (2560, 9216), (4096, 2560), (8192, 2560), and (9216, 2560); q5_K at (2560, 4096) and (8192, 2560); q6_K at (1024, 2560), (248320, 2560), and (2560, 9216); and 7 quantized GEMM shapes of Llama-3.1-8B-Instruct, given as (NN, KK): q4_K at (1024, 4096), (4096, 4096), (4096, 14336), and (14336, 4096); q6_K at (1024, 4096), (4096, 14336), and (128256, 4096).

Kernel inventory

Most kernels in KERNELSHIFT are instances of a few operator families that vary in precision and in fixed operator attributes. Table 9 lists all 99 kernels in this compact form: each row is an operator family, and its variants expand to the listed number of kernels. Unless stated otherwise, convolution variants are written as kernel size and stride, GEMM variants as (N,K)(N, K), and every kernel runs on SVE.

SourceFamilyVariants#
ncnnconv2d{FP32, w8a8ch} ×\times {1×\times1 s1, 1×\times1 s2, 3×\times3 s1, 3×\times3 s2, 7×\times7 s2}10
depthwise conv2d{FP32, w8a8ch} ×\times {3×\times3, 5×\times5} ×\times {s1, s2}8
pooling (FP32)global average; max 2×\times2 s2; max 3×\times3 s1; max 3×\times3 s2 with and without padding5
llama.cppGEMM{BF16, q8_0, q4_K_M} ×\times {(1024, 2048), (1408, 2048), (2048, 1024), (2048, 1408), (2048, 2048)}; q4_K_M uses K=1536K=1536 in place of 140815
MoE{BF16, q8_0, q4_K_M} ×\times {Qwen: 60 experts, top-4; OLMoE: 64 experts, top-8}6
attention (BF16)MHA (Qwen); GQA, 32 query and 8 KV heads (Llama-3.1-8B, Mistral-7B); MLA prefill and MLA decode (DeepSeek-V3)4
RMSNorm (FP32)hidden size 2048 (Qwen)1
SIMD Loopsreductions, dot products001, 002, 003, 004, 008, 024, 033, 105, 1139
element-wise arithmetic027, 028, 029, 0354
complex arithmetic037, 109, 110, 1124
convolution, correlation038, 1142
string, pixel processing103, 1082
search, conditional126, 1272
matrix–vector219 (INT8)1
KleidiAIGEMM, SVEFP32 (512, 512); INT8 and INT4 weights (512, 512); INT4 weights with INT8 activations, FP16 or BF16 block scales (256, 512)5
conv2d, SVEFP32 NHWC 3×\times3 s1, 32→\to64 channels1
GEMM, SME2{FP32, FP16, BF16} (512, 512); at (256, 512): INT8, INT4, and INT2 weights with FP32 activations (7), INT8 and INT4 weights with FP16 activations (4), UINT8 inputs (2)16
conv2d, SME2{FP16 valid, FP32 s1} NHWC 3×\times3, 32→\to64 channels2
depthwise conv2d, SME2{FP32, FP16} NHWC 3×\times3 s12
Total99

Table 9. All 99 kernels by operator family. ×\times: cross product; s: stride; SIMD Loops are given by loop number. Qwen: Qwen1.5-MoE-A2.7B; OLMoE: OLMoE-1B-7B.

Inclusion criteria. A constructed kernel enters the benchmark only if it has a usable expert reference to measure the agent’s relative performance. After a task is constructed, we build and run the expert implementation on the target machine and flag the kernel if (i) no expert implementation could be obtained from the source, (ii) the expert implementation fails to build or does not pass the correctness check on the task’s workloads, or (iii) it is 2x2x slower than the compiler auto-vectorized version of the scalar starting point, in which case it does not represent expert performance. Flagged kernels are inspected and removed, and the remaining kernels form the inventory in Table 9. The released dataset contains 144 kernel definitions, containing the 99 evaluated kernels and the 18 GEMMs of the end-to-end study (§ 4.5).

Task Construction

Construction skills and validation scripts

Task construction is carried out by a coding agent that follows written procedures, which we call construction skills. Each skill is a document that the agent loads on demand. It states what to extract from the request and the given resources, the artifact to produce and its schema, the checks to run afterwards, and a list of known failure modes. Each skill calls deterministic scripts for the mechanical steps, such as capturing workload shapes and building and running a task. The agent supplies the judgment these scripts cannot, such as which dimensions are fixed per kernel, how to call the source library, and which workloads fill a coverage gap, and it runs the validation on the target machine. For the entire generation pipeline, we use Claude Code with sonnet-5 as the base model.

Four skills cover the benchmarking pipeline of § 2.1. gen-definition writes the kernel specification (Figure 5), gen-workload collects its workloads (Figure 6), gen-candidate-solution renders the scalar starting implementation (Figure 7), and gen-baseline-solution wraps the source library’s kernel as the expert reference (Figure 8).

!Construction Skill: gen-definition. Task Description. Design and write a Definition JSON for a new operator. This skill writes the structural schema only; concrete tensor sizes are added afterwards by gen-workload. The reference function inside the definition is a correctness oracle, not a workload. What to Extract from the Request. * Op name and what it computes (enough to write a reference function). * Axes: which are fixed per kernel configuration (const) and which vary per workload (var). * Input and output tensors: names, shapes (as lists of axis names), and dtypes. * Constraints expressing derived output axes in terms of other axes. * A reference implementation in NumPy or PyTorch. If the request is underspecified in any of these areas, ask before generating. Workflow. 0. If the op comes from a real model, extract its shapes from the Hugging Face config.json or from torchvision forward hooks (no weights are downloaded), and record the source as a model:<name> tag. 1. Read one or two existing definitions of the closest operator family. 2. Elicit the design from the user until it is unambiguous, including which framework supplies the expert reference (baseline-solution:<framework> tag). Always ask; do not infer it from the model or the dtype. 3. Present the complete definition and its output path. Wait for explicit confirmation before writing. 4. Write the JSON, then check that every axis used in a shape or constraint is declared, every const axis has an integer value, every derived var axis has a constraint, and the reference function uses integer literals rather than axis names. 5. Verify that the benchmark loads the definition; diagnose and fix any error before declaring success. [. . . conventions and known failure modes omitted . . .] bbox=0.18,0.10,0.83,0.50

Figure 5. Construction skill for kernel definitions, condensed from the skill document given to the construction agent (about 1,900 words). Command lines, file paths, and the table of known failure modes are omitted.

Construction skill for workloads

Figure 6. Construction skill for workloads, condensed from the skill document (about 1,500 words).

Construction Skill: gen-candidate-solution

Task Description

Generate the scalar starting implementation for the definitions of an operator. Each solution embeds three sources: a header holding the harness contract with the definition’s const axes baked in as constexpr, a binding that implements the common entry symbol kernelshift_entry_<op_type>, and a kernel file with plain scalar loops, which is the file the optimizing agent later replaces. Everything is derived from the definition; there is no configuration file.

What to Extract from the Request

  • Op type, and whether to target one definition or all of them

  • Variant: plain FP32 or a quantized scheme, read from the definition’s input dtypes

  • Mode: a new operator or variant, or regeneration of existing solutions

Workflow

  1. Check the definition’s baseline-solution tag and generate only for definitions of the matching source.

  1. Classify the definition: const axes become constexpr; var axes become entry parameters; a scalar input is baked only if it has the same value in every workload of the definition, which is checked against the workload file, and the definition is skipped otherwise.

  1. Derive the entry signature from the definition: tensor pointers in declaration order with the output second, each typed by its declared dtype, followed by the var dimensions deduplicated across all tensor shapes in first-seen order.

  1. Write the header, binding, and scalar kernel templates. For a quantized kernel, match the definition’s Python reference: accumulate in 64-bit integers, then apply the dequantization scales and bias in double precision.

  1. Generate the solutions (dry run first), then compile and run each on every workload on the target machine.

[… rules, command lines, template file layout, and known failure modes omitted …]

Figure 7. Construction skill for the scalar starting implementation, condensed from the skill document (about 1,800 words).

Construction Skill: gen-baseline-solution

Task Description

Generate the expert-reference solution for the definitions of an operator by wrapping the source library’s kernel. The solution has the same three sources as the starting implementation, but its kernel file delegates to the library (for ncnn, the Arm layer classes linked from the static library). One generator serves every source library; a new library is described by parameters, not by a new script.

What to Extract from the Request

  • Op type and scope (one definition or all definitions tagged for this library)

  • Library: if it is not an existing one, this is new-library setup; confirm the scope with the user

  • Mode: a new operator or regeneration after the definitions changed

Workflow

  1. Nothing needs registering: definitions are discovered from the definition directory, and every template value is derived from the definition itself.

  1. Learn the library API for this operator by reading the library’s real headers rather than assuming it from another operator.

  1. Write the header, binding, and kernel templates. Bake only const axes and workload-invariant scalars; derive every var dimension at run time from the tensor shapes. A template with an unresolved placeholder is the wrong template for that definition, and the definition is skipped.

  1. Generate the solutions, verify that the benchmark loads them, then collect the baselines on the target machine to confirm that they compile and pass correctness.

[… rules, command lines, per-layer API notes, and known failure modes omitted …]

Figure 8. Construction skill for the expert reference, condensed from the skill document (about 2,800 words). The omitted per-layer notes document initialization pitfalls of individual ncnn layer classes.

The figures show condensed versions; the complete skill documents are released with the benchmark. The skills stop for human input only at a few fixed points, described next.

Human involvement. Humans make three kinds of decisions. They select kernels, approving each definition that gen-definition proposes and, for large libraries such as KleidiAI with hundreds of micro-kernels, choosing a representative subset. They approve the agent-proposed workloads of Arm SIMD Loops and KleidiAI (Appendix § 8.§ 2). They review each expert reference after its first evaluation, since a correct wrapper can still underperform the library. If such a wrapper cannot be fixed, the kernel is excluded (Appendix § 7.§ 3). The scalar starting implementations need no human input. Appendix § 8.§ 4 shows what humans did in one extension.

Workloads

Workloads for ncnn and llama.cpp kernels come from model executions: in ncnn, operator shapes observed in ResNet50 and MobileNetV3-Large at 11 input resolutions, and in llama.cpp inference on 200 ShareGPT prompts (ShareGPT, [30]) of 10–150 words with a context of up to 4096 tokens. The collected shapes are deduplicated and subsampled to about 20 per kernel (Figure 6). Arm SIMD Loops and KleidiAI have no model execution to trace; their workloads are proposed by the agent and approved by humans, and combine small edge-case sizes for correctness with large sizes for performance.

Only shapes are kept from the executions. Input tensors are generated deterministically based on each workload’s ID, and quantization scales are drawn from fixed ranges, so every evaluation of a workload sees the same inputs. Across the 99 kernels, the benchmark has 1,582 workloads.

Correctness criteria

An output element matches if it is within both an absolute and a relative tolerance of the reference value; positions where the reference itself is not finite are ignored. A workload passes if the fraction of matching elements reaches the required match ratio, and a candidate is correct only if it passes every workload. Kernels whose error is dominated by quantization or low-precision accumulation are instead checked with the signal-to-quantization-noise ratio, SQNR⁡=10log⁡10(∑iri2/∑i(yi−ri)2)\operatorname{SQNR}=10\log_{10}\left(\sum_i r_i^2/\sum_i(y_i-r_i)^2\right), against a minimum. Table 10 lists the thresholds.

KernelsAbsolute tol.Relative tol.Match ratio
Default (convolution, pooling, RMSNorm, SIMD Loops)10−310^{-3}10−310^{-3}1.00
GEMM2×10−32 \times10^{-3}10−210^{-2}0.98
MoE10−210^{-2}5×10−25 \times10^{-2}0.95
MHA10−310^{-3}10−310^{-3}0.98
GQA, MLA prefill5×10−35 \times10^{-3}10−310^{-3}0.98
MLA decode3×10−23 \times10^{-2}10−210^{-2}0.98
KleidiAI FP16 depthwise conv2d10−310^{-3}10−310^{-3}0.95
KleidiAI requantized INT8 GEMM (SME2)0.510−210^{-2}0.99
KleidiAI UINT8 GEMM, FP32 output (SME2)10−310^{-3}10−510^{-5}1.00
Minimum SQNR
llama.cpp q4_K_M GEMM and MoE; q8_0 MoE20 dB
KleidiAI INT4 GEMM (SVE)30 dB
KleidiAI INT4 GEMM (SME2)40 dB
KleidiAI BF16 GEMM (SME2)45 dB
Other KleidiAI INT8, INT4, and INT2 GEMMsexpert’s SQNR on the workload − 1 dB

Table 10. Correctness thresholds. Kernels not listed use the default.

Human effort in one extension

To show what extending the benchmark asks of humans, we logged one extension of the end-to-end task set (Appendix § 11.§ 1): rebuilding the workloads of the Qwen3.5-4B and Llama-3.1-8B-Instruct GEMM tasks from model runs, and collecting workloads for two OLMoE GEMM tasks. The construction agent, Claude Code with Claude Sonnet 5.5, ran every step through qwen, the command-line tool that bundles the scripts of Appendix § 8.§ 1 in the released code. Table 11 lists what the agent and the humans did at each step. The timed commands took about 23 minutes, and the Graviton instances were held for about 4.5 hours, including setup, model downloads, and reruns.

The human sent 37 messages during the session. 17 changed the course of the work: 14 decisions and 3 corrections. The rest were questions. The decisions fall into two kinds: choosing what build, such as covering both quantization formats and splitting definitions by format, and choosing/approving machines.

Evaluation Infrastructure

Target machines

For each run, the control plane provides a dedicated target machine (an AWS Graviton instance, or a mac-m4.metal host for M4), evaluates the tasks sequentially with retries on failure, and col-

StepAgentHuman
Scope and definitionsWrites one definition per shape and quantization formatChooses the models and formats; corrects two shapes the agent got wrong
Workloads (collect, add)Runs each model, records the shapes every GEMM sees, selects and registers workloads—
Inputs (capture)Stores the activations reaching each GEMM as workload inputs—
Calibration (calibrate)Measures the SQNR of ggml’s own arithmetic on every workload—
MachinesProvisions instances, sets them up, reruns failed stepsChooses the instance type and approves each launch

caption: Division of work in one extension of the end-to-end GEMM tasks.

:::

lects each task’s trajectory. Table 12 lists the environment of each hardware generation. No hardware documentation is given to the agent in the main runs, and the documentation ablation adds the Arm Neoverse V1/V2 optimization guides and an SVE intrinsics summary on SVE, and SME programming notes on SME2. On M4, performance and efficiency cores cannot be selected separately, so comparisons between Neon and SME2 use the same M4 host. Cross-generation comparisons use only shared kernels.

Gen.MachineCore, vector widthOS / compilerTarget flagCPU pinningCounter feedback
SVEGraviton3, AWS c7g.xlargeNeoverse V1, 256-bit SVEUbuntu 22.04, clang-18-march=armv8.2-a+sveCPU 0cycles, instructions, cache misses
SVE2Graviton4, AWS c8g.xlargeNeoverse V2, 128-bit SVE2Ubuntu 22.04, clang-18-march=armv9-a+sve2CPU 0cycles, instructions, cache misses
SME2Apple M4, AWS mac-m4.metal512-bit, streaming SVE onlymacOS, Apple clang-mcpu=apple-m4nonenone

Table 12. Evaluation environment per hardware generation. Counter feedback lists the counters returned by evaluate; reported speedups use wall-clock time.

Instruction-set ladders

Table 13 gives the configuration of each arm of the instruction-set ladder experiment (Table 3). On Graviton4, an arm is set by the compile target. On Apple M4, no compiler flag separates streaming SVE from ZA, because enabling SME also enables ZA. The Neon-only and streaming-SVE arms are therefore enforced by rejecting disallowed constructs in the submitted source and disallowed instructions in the disassembly of the compiled kernel. Within a machine, every arm is scored against the same expert reference, so differences between arms reflect only the instructions available to the agent. The task set for each ladder is listed in Table 8.

ArmMachineCompile targetAdditionally rejected
L1: Neon onlyGraviton4-march=armv8-a— (SVE intrinsics do not compile)
L2: + SVEGraviton4-march=armv8.2-a+sve— (SVE2 intrinsics do not compile)
L3: + SVE2Graviton4-march=armv9-a+sve2—
L4: Neon onlyApple M4-mcpu=apple-m4+nosmeSource: SVE and SME headers and types, streaming attributes, smstart. Binary: smstart, SVE and ZA/ZT0 registers.
L5: + streaming SVEApple M4-mcpu=apple-m4Source: ZA/ZT0 attributes and intrinsics, smstart za. Binary: smstart without sm, outer products (MOPA/MOPS), ZA/ZT0 registers.
L6: + ZA (full SME2)Apple M4-mcpu=apple-m4—

Table 13. Configuration of the instruction-set ladder arms (Table 3).

Agent interface, harnesses, and prompts

What the agent sees. For each task, the agent receives the kernel specification in code form: the definition name and operator type, including the constant attributes (e.g., kernel size and stride, or NN and KK of a GEMM), and the scalar starting implementation. It does not receive the workloads: the values of the variable dimensions (e.g., channel counts, spatial sizes, or token counts), the number of workloads, and the input tensors are never shown. The kernel receives the variable dimensions as run-time arguments, so a candidate must be correct for every size that the specification allows. Feedback is aggregated over the hidden workloads: evaluate reports the maximum errors, the geometric-mean speedup, and hardware counters where available, and after a failure only the identifier of the first failing workload and an error message. The agent also sees the results of its own earlier calls. Every compile, evaluate, and disassemble call counts toward the 40-call budget. A run counts as complete only after at least 15 calls, and the best correct candidate is retained.

All harnesses receive the same task skill. Claude Code and Codex run in a fresh, empty working directory with shell and web tools disabled and auto-memory off. Nanobot uses temperature 0.1, reasoning effort xhigh, and a 200k-token context, with shell and web tools disabled and file access limited to the task’s workspace. The tool-call loop uses temperature 0.2 if available. In long runs, the tool-call loop replaces earlier kernel versions with a summary of the versions that passed, and nanobot compacts older tool results when its context fills up.

Figure 9 shows the prompt given to the agent and Table 14 the tools it can call.

ToolArgumentsWhat it doesReturns
check_progressdefinitionLooks up the best result so far on this definition.Its version, metrics, and code.
compiledefinition, codeCompiles the agent’s kernel.cpp; the harness and binding files are added automatically.A version number, or the compiler error.
evaluatedefinition, versionChecks correctness on all workloads, stopping at the first failure; if correct, times the kernel. A new best result is saved immediately.Errors, speedups, and counters; or the failing workload’s ID and a log.
disassembledefinition, version, optional fnDisassembles the kernel entry symbol, or fn.Up to 300 lines of AArch64 assembly.

Table 14. Agent tools, condensed from their schemas. definition and version must match the last compile.

Agent Prompt. System (kernel-session skill, condensed): Ground Rules. * Work on one definition at a time; `evaluate` and `disassemble` must name the definition and version of your last `compile`. * Stay on the target ISA; do not fall back to an older one. * Never use OpenMP or other parallelization. Kernels always run on the remote target, which has every dependency installed. * Use `disassemble` to check whether SIMD is really helping and to find bottlenecks. Workflow 0. Call `check_progress` to look up the best result so far. If one exists, compile and evaluate it first, then continue from it. 1. Read the `reference-scalar-kernel.cpp` resource, compile it unchanged (this becomes v1), and evaluate it to record the starting point. 2. Iterate: compile an attempt; evaluate it (correctness and timing in one call; the best version is saved automatically); disassemble when IPC is low or the speedup is unexpectedly poor. Re-read earlier versions and the trajectory instead of re-evaluating them. Metrics from evaluate * `max_absolute_error`, `max_relative_error`; `time_speedup_geomean` and `cycle_speedup_geomean` against the expert baseline (geometric mean over workloads); `ipc_mean`; `cache_misses_mean`. * On failure, `failed_workload` and `log` say which workload failed and why. User (task prompt): Optimize the “<definition>” kernel definition (dataset: <source>, baseline solution source: <expert>) in ISA <isa>. You must spend at least 15 tool calls but not exceed 40 tool calls to explore genuinely different optimization attempts before you are allowed to submit. Once you hit that ceiling, stop iterating and submit your best version immediately, since every iteration spends real model API budget. Follow the ground rules and workflow in your system prompt.

Figure 9. Agent prompt. The skill (about 1,100 words) is condensed; the task prompt is verbatim.

Measurement protocol and integrity

Each workload is first run for correctness and then timed in 50 samples after 10 warmup samples, and the primary metric is the minimum sample. On every target, each sample repeats the kernel until it lasts at least 10 ms, timed with a nanosecond-resolution clock, and a candidate uses the same repetition count and settings as the baseline. On Linux, the timed process is pinned to one CPU. When available, hardware counters are also collected. Expert baselines are measured on the same machine before agent evaluation. Per-workload speedup is expert-reference time divided by candidate time, and task speedup is the geometric mean over workloads. Each evaluate call runs in a fresh subprocess and is stopped if checking and timing all workloads takes longer than 1200 s. Re-measuring selected kernels on new instances changes a kernel’s speedup by a median of about 1% and does not change the ranking beyond ties.

Across three seeds of nanobot with GPT-5.6-luna on Graviton4, on the 32-kernel subset, Speedup@40 varies by 4.5%, and per-kernel Speedup@40 by a median of 9.7%. Re-timing the same fixed code varies by only 0.2%, so run-to-run variation comes from agent stochasticity rather than from measurement. Over three seeds, a column’s geometric mean in Table 2 varies by 3–5% (one s.d.), so rows within this margin are tied.

Table 15 gives bootstrap 95% confidence intervals over kernels for every cell of Table 2. They agree with the seed variation: in paired comparisons with the best system of each column, 2, 5, 8, and 0 of the other 13 systems are not separable on ncnn, llama.cpp, SIMD Loops, and KleidiAI.

HarnessModelncnn (23)llama.cpp (26)SIMD Loops (24)KleidiAI (6)
Claude CodeClaude Opus 4.82.574 [1.96, 3.40]1.779 [1.26, 2.61]1.555 [1.24, 2.09]0.701 [0.45, 0.98]
Claude CodeClaude Sonnet 4.61.934 [1.50, 2.55]1.243 [0.88, 1.82]1.516 [1.20, 2.06]0.386 [0.20, 0.75]
CodexGPT-5.6-sol1.815 [1.37, 2.39]1.297 [0.94, 1.82]1.487 [1.19, 1.96]0.431 [0.23, 0.74]
CodexGPT-5.6-luna0.674 [0.47, 0.97]0.627 [0.38, 1.02]1.127 [0.89, 1.45]0.147 [0.06, 0.36]
nanobotClaude Opus 4.82.597 [2.01, 3.38]1.708 [1.22, 2.48]1.521 [1.21, 2.02]0.453 [0.24, 0.83]
nanobotClaude Sonnet 4.62.046 [1.53, 2.78]1.449 [1.01, 2.12]1.503 [1.21, 1.97]0.231 [0.12, 0.48]
nanobotGPT-5.6-sol2.156 [1.62, 2.89]1.334 [0.96, 1.91]1.543 [1.22, 2.09]0.319 [0.17, 0.59]
nanobotGPT-5.6-luna1.110 [0.79, 1.55]0.878 [0.59, 1.36]1.182 [0.93, 1.49]0.161 [0.07, 0.39]
nanobotDeepSeek-V4-Pro1.091 [0.77, 1.55]0.850 [0.53, 1.36]1.458 [1.15, 1.97]0.231 [0.09, 0.59]
nanobotGLM-5.32.743 [2.05, 3.68]1.954 [1.38, 2.85]1.545 [1.21, 2.14]0.499 [0.25, 0.85]
tool-call loopClaude Opus 4.82.308 [1.71, 3.18]1.828 [1.34, 2.62]1.480 [1.22, 1.86]0.496 [0.27, 0.86]
tool-call loopClaude Sonnet 4.62.043 [1.54, 2.78]1.915 [1.41, 2.66]1.521 [1.20, 2.09]0.297 [0.12, 0.72]
tool-call loopGPT-5.6-sol1.999 [1.51, 2.72]1.671 [1.24, 2.32]1.513 [1.19, 2.09]0.307 [0.15, 0.65]
tool-call loopGPT-5.6-luna0.955 [0.68, 1.35]0.854 [0.57, 1.31]1.245 [1.02, 1.55]0.164 [0.06, 0.47]

Table 15. Bootstrap 95% confidence intervals (10,000 resamples of the kernels) of the geometric means in Table 2. KleidiAI has six kernels, so its intervals are wide.

Speedup over the Starting Point and Fraction of Hardware Peak

Every agent starts from the scalar reference compiled with −O3 and auto-vectorization for SVE (the “scalar + −O3, SVE enabled” row of Table 2). Table 16 reports every cell of Table 2 against this starting point instead of the expert. Every system is faster than its starting point in every column (2.4–19.8×), while the experts are 2.1–28.2× faster.

HarnessModelncnn (23)llama.cpp (26)SIMD Loops (24)KleidiAI (6)
Claude CodeClaude Opus 4.811.24 (100%)14.18 (100%)3.32 (92%)19.77 (100%)
Claude CodeClaude Sonnet 4.68.44 (100%)9.91 (100%)3.24 (92%)10.88 (100%)
CodexGPT-5.6-sol7.92 (100%)10.34 (100%)3.18 (88%)12.14 (100%)
CodexGPT-5.6-luna2.94 (100%)5.00 (100%)2.41 (79%)4.15 (100%)
nanobotClaude Opus 4.811.34 (100%)13.62 (100%)3.25 (88%)12.77 (100%)
nanobotClaude Sonnet 4.68.93 (100%)11.55 (100%)3.21 (92%)6.52 (100%)
nanobotGPT-5.6-sol9.41 (100%)10.63 (100%)3.30 (92%)8.98 (100%)
nanobotGPT-5.6-luna4.85 (100%)7.00 (100%)2.53 (88%)4.54 (100%)
nanobotDeepSeek-V4-Pro4.76 (100%)6.77 (100%)3.12 (92%)6.52 (100%)
nanobotGLM-5.311.97 (100%)15.57 (96%)3.30 (92%)14.06 (100%)
tool-call loopClaude Opus 4.810.07 (100%)14.57 (100%)3.16 (92%)13.98 (100%)
tool-call loopClaude Sonnet 4.68.92 (100%)15.26 (100%)3.25 (92%)8.38 (100%)
tool-call loopGPT-5.6-sol8.73 (100%)13.32 (100%)3.23 (88%)8.67 (100%)
tool-call loopGPT-5.6-luna4.17 (100%)6.80 (100%)2.66 (88%)4.62 (100%)
Expert reference4.377.972.1428.20

Table 16. Speedup over the starting point (scalar reference, −O3-O3, SVE enabled) on Graviton3, geometric mean over kernels and, in parentheses, the fraction of kernels faster than the starting point. Same runs and task sets as Table 2.

Table 17 gives the fraction of the theoretical limit, tfloor/tmeasuredt_{\mathrm{floor}}/t_{\mathrm{measured}} per workload with tfloor=max⁡(W/P,Q/B)t_{\mathrm{floor}} = \max(W/P, Q/B): WW operations at the measured peak PP of the fastest instruction for the data type, or QQ bytes at the bandwidth BB of the cache level that holds the data. The ncnn and llama.cpp experts reach 7–8% of the limit and the frontier agents two to three times that, while the KleidiAI experts (43%) stay ahead of every agent. Therefore, a speedup above 1 shows headroom in the reference, not that the agent is near the hardware limit.

HarnessModelncnn (23)llama.cpp (26)SIMD Loops (21)KleidiAI (6)
Claude CodeClaude Opus 4.817.4%14.2%50.0%30.1%
Claude CodeClaude Sonnet 4.613.1%9.9%48.9%16.5%
CodexGPT-5.6-sol12.3%10.4%48.2%18.5%
CodexGPT-5.6-luna4.6%5.0%38.4%6.3%
nanobotClaude Opus 4.817.6%13.7%49.0%19.4%
nanobotClaude Sonnet 4.613.9%11.6%48.6%9.9%
nanobotGPT-5.6-sol14.6%10.7%49.3%13.7%
nanobotGPT-5.6-luna7.5%7.0%39.7%6.9%
nanobotDeepSeek-V4-Pro7.4%6.8%46.3%9.9%
nanobotGLM-5.318.6%15.6%49.0%21.4%
tool-call loopClaude Opus 4.815.6%14.7%49.4%21.3%
tool-call loopClaude Sonnet 4.613.8%15.3%48.2%12.7%
tool-call loopGPT-5.6-sol13.5%13.3%47.7%13.2%
tool-call loopGPT-5.6-luna6.5%6.8%41.5%7.0%
Starting point (−O3, SVE)1.6%1.0%17.4%1.5%
Expert reference6.8%8.0%37.4%42.9%

Table 17. Fraction of the theoretical hardware limit reached on Graviton3 (single core), geometric mean over workloads and kernels; only the expert is timed, and the other rows scale by their speedups. SIMD Loops: the 21 kernels with a defined operation count. KleidiAI: the six kernels, with the expert and the cache bandwidths measured again on Graviton3.

Case Studies

End-to-end optimization with agent-written kernels

Setup. The main experiments measure adaptation one kernel at a time. To test whether these gains transfer to an application, we test two popular open-weight models, Qwen3.5-4B and Llama-3.1-8B-Instruct (both Q4_K_M), served with llama.cpp on Graviton4. 11 individual quantized matrix-multiplication kernels from the Qwen model and 7 matrix-multiplication kernels from the Llama model are turned into benchmark tasks. We substitute the resulting agent-written kernels into the inference stack and compare against original llama.cpp on the same hardware.

Model selection. Qwen3.5-4B is a recent hybrid model (Gated DeltaNet and attention); Llama-3.1-8B-Instruct is a standard dense transformer widely used for CPU inference. Both use 4-bit quantization, the standard for CPU inference in llama.cpp.

End-to-end performance and quality. Table 18 reports the speedup across different thread counts and quantizations relative to llama.cpp for Qwen3.5-4B, and Table 19 reports speedup across prompt length and micro-batch size for both models. For Qwen3.5-4B, the adapted kernels speed up prefill by 1.30×1.30\times at 16 threads and by 1.351.35–1.39×1.39\times at 1–4 threads. Decode improves by 1.041.04–1.06×1.06\times, consistent with its greater sensitivity to memory bandwidth and to operators that are not replaced. Perplexity is unchanged relative to the Q4_K_M model (9.504 vs. 9.506). For Llama-3.1-8B-Instruct, the agent kernels speed up prefill by 1.391.39–1.57×1.57\times and decode by 1.071.07–1.10×1.10\times across 1–16 threads (Table 6), and perplexity is unchanged (7.879 in both builds).

ThreadsPrefillDecode
Agent kernels
11.3951.045
41.3481.059
161.2981.048
Original without repack
10.4600.758
40.4650.744
160.5210.879
ModelPerplexityΔ\Delta
BF169.384−1.3%
Q6_K9.436−0.7%
Q4_K_M9.506—
Q4_K_M (agent kernels)9.5040.0%
Q3_K_M9.846+3.6%

Table 18. End-to-end speedup and perplexity for Qwen3.5-4B (Claude Code + Claude Fable 5.1), relative to original llama.cpp.

SettingQwen3.5-4BLlama-3.1-8B
Prompt length
5121.2981.393
20481.2811.322
40961.2601.255
81921.2261.184
Micro-batch size
11.0531.090
21.2701.598
81.1641.479
641.0610.989
5121.2981.397

Table 19. Prefill speedup by prompt length and micro-batch at 16 threads, relative to original llama.cpp.

Serving regimes. The prefill gain persists across prompt lengths and micro-batch sizes (Table 19). It declines with prompt length as the share of work in unreplaced operators, mainly attention, grows, and batch size 1 behaves like decode.

Adaptation to the hardware. All 18 kernels use Graviton4’s i8mm matrix-multiply instructions. The agent enables these instructions per function and combines them with shape-specific tiling, layout, and prefetching. Measured alone, agent kernels are 1.45×1.45 \times faster for Qwen and 1.62×1.62 \times for Llama than llama.cpp’s repacked kernels. Each generated kernel serves one fixed shape, whereas a general-purpose library implementation must cover a broader shape distribution. We note that this is not a general claim that agents out-engineer expert libraries end-to-end, but rather demonstrates the potential of hardware-specific kernel generation.

Learning SME2 at test time

Table 20 lists every counted tool call of one run: nanobot with Claude Opus 4.8 on KleidiAI’s BF16 GEMM on Apple M4, the run behind the 0.94×0.94 \times result in § 4.2.

CallsWhat the agent doesResult
1–2compile and evaluate the given scalar code0.004×0.004 \times
3first BFMOPA kernel, operands gathered inside streaming modecompile error
4–7pack operands to BF16 outside streaming mode; one ZA tile; fix load predicatesincorrect (twice)
8–916-bit governing predicates for BFMOPA0.370×0.370 \times
10–112×22 \times2 blocking over all four FP32 ZA tiles0.799×0.799 \times
12–20Neon packing of BB, disassembly, alternative packing of AA, KK unrolling1 compile error; 0.5070.507–0.799×0.799 \times
21–25multi-slice ZA reads in the output store1 compile error; 0.8380.838–0.839×0.839 \times
26–29cache-blocked Neon packing of AA, wider packing of BB (best)0.935×0.935 \times
30–35wider loads, branch hoisting, loop reordering0.9250.925–0.935×0.935 \times
36one more packing variant, compiled but not evaluated before the run ends—

Table 20. Tool calls of one SME2 run (KleidiAI gemm_bf16_n512_k512, nanobot with Claude Opus 4.8, Apple M4). Speedups are relative to the KleidiAI SME2 kernel.

The agent starts from the scalar implementation (0.004×0.004 \times the KleidiAI SME2 kernel) and targets the matrix engine directly, planning a BFMOPA outer-product kernel that accumulates into the ZA array. Its first attempt does not compile because it gathers operands inside streaming mode, where gather loads are unavailable, so the agent packs both operands to BF16 in non-streaming code. The next two kernels run but are incorrect, until the agent works out that the governing predicates of BFMOPA are defined over the 16-bit source elements rather than the 32-bit outputs. Six calls thus pass before the first correct SME2 kernel (0.37×0.37 \times). Blocking the output over all four FP32 ZA tiles then more than doubles the speedup (0.80×0.80 \times). The remaining calls are ordinary performance engineering: the agent finds that packing the operands, not the outer products, limits performance, and cache-blocked Neon packing brings the kernel to 0.935×0.935 \times at call 29.

Use of Target-Specific Intrinsics

We check whether agents actually use the instructions of the target extension. For each run, the final solution is the version whose result is reported as Speedup@40. A final solution counts as using SVE if it calls at least one SVE intrinsic, and as using SME2 if its disassembled binary contains at least one ZA instruction, which also covers instructions used through inline assembly. Every solution we count as using an extension also has that extension’s instructions in its binary. Table 21 reports the nanobot runs of the four models: the SVE kernels of Table 2, the SVE2 loops of Table 4, and the six KleidiAI SME2 kernels of the same table in each of its three seeds. Nearly all final SVE solutions use SVE instructions, but on SME2 only Claude Opus 4.8 uses the matrix tiles in most of its final solutions. This is consistent with the drop from SVE to SME2 in Table 4. On the eight SIMD Loops kernels of the SME2 comparison, a solution counts as using SVE2 if it does not compile without SVE2, the test used to select these loops. Most Claude solutions do, and in 13 of the 14 cases the solution uses the same SVE2 instruction as the expert.

TargetClaude Opus 4.8Claude Sonnet 4.6DeepSeek-V4-ProGLM-5.3
SVE79/79 (100%)75/79 (95%)71/79 (90%)78/79 (99%)
SVE26/8 (75%)8/8 (100%)4/8 (50%)3/8 (38%)
SME215/18 (83%)5/18 (28%)1/18 (6%)5/18 (28%)

Table 21. Final solutions that use intrinsics of the target extension (nanobot): SVE intrinsics on SVE (79 kernels), SVE2-only instructions on SVE2 (8 SIMD Loops kernels), ZA instructions in the binary on SME2 (6 KleidiAI kernels, 3 seeds).

SIMD class of the SME2 kernels on Apple M4

This section examines which SIMD class the agent uses on the 20 KleidiAI SME2 kernels on Apple M4. A version is ZA if it uses ZA tile intrinsics (svmopa, _za intrinsics or __arm_new), streaming SVE if it uses __arm_streaming or __arm_locally_streaming without ZA, Neon if it uses Neon intrinsics outside streaming mode, and plain C otherwise. The final kernel of a run is its best passing version within the first 40 tool calls.

Table 22 classifies the final kernel of every (kernel, seed) run on the ladder of Table 3, normalized by the same kernel on the Neon-only tier (its speedup over the expert divided by its mean over the three Neon-only seeds). On the streaming-SVE tier, the agent keeps Neon in only 1 of 60 runs, and its streaming-SVE and plain-C kernels reach only 0.37 and 0.42 of Neon-only. For the full-SME2 tier, across its 60 runs the agent writes ZA in only two versions, and neither passes. Compile errors also grow with the exposed ISA: on the first seed, 48 of 374 compiles fail (13%) on the Neon-only tier, 82 of 405 (20%) on the streaming-SVE tier, and 102 of 419 (24%) with full SME2.

TierSIMD class of final kernel# final kernels (of 60)Relative to Neon only
Neon onlyNeon590.99
Neon onlyplain C10.16
Streaming SVEstreaming SVE250.37
Streaming SVEplain C340.42
Streaming SVENeon10.76
Full SME2Neon230.75
Full SME2streaming SVE170.40
Full SME2plain C200.59
Full SME2ZA0–

Table 22. Final kernels on the M4 ladder by SIMD class (20×320 \times3 seeds per tier). Last column: geometric mean of the normalized speedup.

Contamination Statement

Because ncnn, llama.cpp, SIMD Loops, and KleidiAI are public, expert code may exist in models’ training data. However, on most ncnn, llama.cpp, and SIMD Loops kernels, agents exceed the expert code rather than reproducing it, and use intrinsics not in library code and different algorithm structures. Further, the task setup does not match the library: agents start from portable scalar code with benchmark-specific interfaces. Finally, KleidiAI’s SME2 expert kernels are also public, yet agents fall far short of them. As a direct test, on the 20 KleidiAI SME2 kernels of Table 3 (full SME2 arm), the 6 whose expert micro-kernels were added to KleidiAI after the knowledge cutoff of GPT-5.6-luna (2026-02-16) score about the same as the 14 older ones (geometric-mean Speedup@40 0.088 vs. 0.082). The workloads used for the correctness check and for timing are also hidden from the agents.

References

  1. [1]Martin Andrews and Sam Witteveen. GPU kernel scientist: An LLM-driven framework for iterative kernel optimization. In ES-FoMo Workshop at ICML, 2025.arxiv.org/abs/2506.20807
  2. [2]Anthropic. (2025). Claude Code. <a href="https://doi.org/https://github.com/anthropics/claude-code" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/anthropics/claude-code</a>
  3. [3]Anthropic. (n.d.). Introducing Claude Fable 5.1 and Claude Mythos 5.1. <a href="https://doi.org/https://www.anthropic.com/claude-fable-and-mythos-5-1" rel="noopener noreferrer" target="_blank">https://doi.org/https://www.anthropic.com/claude-fable-and-mythos-5-1</a>
  4. [4]Anthropic. (n.d.). Introducing Claude Opus 4.8. <a href="https://doi.org/https://www.anthropic.com/news/claude-opus-4-8" rel="noopener noreferrer" target="_blank">https://doi.org/https://www.anthropic.com/news/claude-opus-4-8</a>
  5. [5]Anthropic. (n.d.). Introducing Claude Sonnet 4.6. <a href="https://doi.org/https://www.anthropic.com/news/claude-sonnet-4-6" rel="noopener noreferrer" target="_blank">https://doi.org/https://www.anthropic.com/news/claude-sonnet-4-6</a>
  6. [7]Arm. (2025). SIMD Loops.
  7. [8]Arm. (2026). Arm C Language Extensions.
  8. [9]Siyuan Chen, Zhichao Lu, and Qingfu Zhang. Evolution of kernels: Automated RISC-V kernel optimization with large language models. arXiv preprint arXiv:2509.14265, 2025.arXiv
  9. [10]Tianqi Chen, Thierry Moreau, Ziheng Jiang, Lianmin Zheng, Eddie Yan, Meghan Cowan, Haichen Shen, Leyuan Wang, Yuwei Hu, Luis Ceze, Carlos Guestrin, and Arvind Krishnamurthy. TVM: An automated end-to-end optimizing compiler for deep learning. In 13th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2018.arxiv.org/abs/1802.04799
  10. [11]Chris Cummins, Bram Wasti, Jiadong Guo, Brandon Cui, Jason Ansel, Sahir Gomez, Somya Jain, Jia Liu, Olivier Teytaud, Benoit Steiner, Yuandong Tian, and Hugh Leather. CompilerGym: Robust, performant compiler optimization environments for AI research. In IEEE/ACM International Symposium on Code Generation and Optimization (CGO), pp. 92–105, 2022.arxiv.org/abs/2109.08267
  11. [12]Weinan Dai, Hanlin Wu, Qiying Yu, Huan-ang Gao, Jiahao Li, Chengquan Jiang, Weiqiang Lou, Yufan Song, Hongli Yu, Jiaze Chen, Wei-Ying Ma, Ya-Qin Zhang, Jingjing Liu, Mingxuan Wang, Xin Liu, and Hao Zhou. CUDA agent: Large-scale agentic RL for high-performance CUDA kernel generation. arXiv preprint arXiv:2602.24286, 2026.arXiv
  12. [13]DeepSeek-AI. (2026). DeepSeek-V4 model card.
  13. [14]Du, W., Zhuo, J., Dong, Y., He, A. W., Sun, W., Zheng, Z., Karunaratne, M., Fox, I., Dettmers, T., Chen, T., Yang, Y., & Welleck, S. (2026). AdaExplore: Failure-driven adaptation and diversity-preserving search for efficient kernel generation. 2604.16625
  14. [15]Alhussein Fawzi, Matej Balog, Aja Huang, Thomas Hubert, Bernardino Romera-Paredes, Mohammadamin Barekatain, Alexander Novikov, Francisco J. R. Ruiz, Julian Schrittwieser, Grzegorz Swirszcz, David Silver, Demis Hassabis, and Pushmeet Kohli. Discovering faster matrix multiplication algorithms with reinforcement learning. Nature, 610(7930):47–53, 2022.DOI
  15. [16]Ferrari, M., Tillet, P., Ibrahim, A., Gershenson, J., & Coffey, S. (2026). How GPT-5.6 fuses frontier intelligence with frontier efficiency. OpenAI. <a href="https://doi.org/https://openai.com/index/gpt-5-6-frontier-intelligence-efficiency/" rel="noopener noreferrer" target="_blank">https://doi.org/https://openai.com/index/gpt-5-6-frontier-intelligence-efficiency/</a>
  16. [17]Dayuan Fu, Mohan Jiang, Tongyu Wang, Dian Yang, Jiarui Hu, Liming Liu, Jinlong Hou, and Pengfei Liu. daVinci-kernel: Co-evolving skill selection, summarization, and utilization via RL for GPU kernel optimization. arXiv preprint arXiv:2606.16497, 2026.arXiv
  17. [18]Gerganov, G., & contributors, . ggml .-. org . (2023). llama.cpp: LLM inference in C/C++. <a href="https://doi.org/https://github.com/ggml-org/llama.cpp" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/ggml-org/llama.cpp</a>
  18. [19]Yibo He, Shuoran Zhao, Jiaming Huang, Yingjie Fu, Hao Yu, Cunjian Huang, and Tao Xie. Simd-Bench: Benchmarking large language models for SIMD-intrinsic code generation. arXiv preprint arXiv:2507.15224, 2025.arXiv
  19. [20]HKUDS. (2025). nanobot: Ultra-lightweight open-source personal AI agent framework. <a href="https://doi.org/https://github.com/HKUDS/nanobot" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/HKUDS/nanobot</a>
  20. [21]Jianling Li, Shangzhan Li, Zhenye Gao, Qi Shi, Yuxuan Li, Zefan Wang, Jiacheng Huang, Haojie Wang, Jianrong Wang, Xu Han, Zhiyuan Liu, and Maosong Sun. TritonBench: Benchmarking large language model capabilities for generating Triton operators. In Findings of the Association for Computational Linguistics: ACL 2025, 2025.arxiv.org/abs/2502.14752
  21. [22]Jie Li, Wenzhao Wu, Junqi Hu, Qinrui Zheng, Bowen Wu, Juepeng Zheng, Yutong Lu, and Hao-huan Fu. CodegenBench: Can LLMs write efficient code across architectures? arXiv preprint arXiv:2606.04023, 2026.arXiv
  22. [23]Daniel J. Mankowitz, Andrea Michi, Anton Zhernov, Marco Gelmi, Marco Selvi, Cosmin Paduraru, Edouard Leurent, Shariq Iqbal, Jean-Baptiste Lespiau, Alex Ahern, Thomas Köppe, Kevin Millikin, Stephen Gaffney, Sophie Elster, Jackson Broshear, Chris Gamble, Kieran Milan, Robert Tung, Minjae Hwang, Taylan Cemgil, Mohammadamin Barekatain, Yujia Li, Amol Mandhane, Thomas Hubert, Julian Schrittwieser, Demis Hassabis, Pushmeet Kohli, Martin Riedmiller, Oriol Vinyals, and David Silver. Faster sorting algorithms discovered using deep reinforcement learning. Nature, 618(7964):257–263, 2023.DOI
  23. [24]Charith Mendis, Ajay Jain, Paras Jain, and Saman Amarasinghe. Revec: Program rejuvenation through revectorization. In Proceedings of the 28th International Conference on Compiler Construction (CC), 2019.DOI
  24. [25]Alexander Novikov, Ngân Vu, Marvin Eisenberger, Emilien Dupont, Po-Sen Huang, Adam Zsolt Wagner, Sergey Shirobokov, Borislav Kozlovskii, Francisco J. R. Ruiz, Abbas Mehrabian, M. Pawan Kumar, Abigail See, Swarat Chaudhuri, George Holland, Alex Davies, Sebastian Nowozin, Pushmeet Kohli, and Matej Balog. AlphaEvolve: A coding agent for scientific and algorithmic discovery. arXiv preprint arXiv:2506.13131, 2025.arXiv
  25. [26]OpenAI. (2025). OpenAI Codex CLI. <a href="https://doi.org/https://github.com/openai/codex" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/openai/codex</a>
  26. [27]Anne Ouyang, Simon Guo, Simran Arora, Alex L. Zhang, William Hu, Christopher Ré, and Azalia Mirhoseini. KernelBench: Can LLMs write efficient GPU kernels? In International Conference on Machine Learning (ICML), 2025.arxiv.org/abs/2502.10517
  27. [28]Vijay Janapa Reddi, Christine Cheng, David Kanter, Peter Mattson, Guenther Schmuelling, Carole-Jean Wu, Brian Anderson, Maximilien Breughe, Mark Charlebois, William Chou, Ramesh Chukka, Cody Coleman, Sam Davis, Pan Deng, Greg Diamos, Jared Duke, Dave Fick, J. Scott Gardner, Itay Hubara, Sachin Idgunji, Thomas B. Jablin, Jeff Jiao, Tom St. John, Pankaj Kanwar, David Lee, Jeffery Liao, Anton Lokhmotov, Francisco Massa, Peng Meng, Paulius Micikevicius, Colin Osborne, Gennady Pekhimenko, Arun Tejusve Raghunath Rajan, Dilip Sequeira, Ashish Sirasao, Fei Sun, Hanlin Tang, Michael Thomson, Frank Wei, Ephrem Wu, Lingjie Xu, Koichi Yamada, Bing Yu, George Yuan, Aaron Zhong, Peizhao Zhang, and Yuchen Zhou. MLPerf inference benchmark. In 2020 ACM/IEEE 47th Annual International Symposium on Computer Architecture (ISCA), pp. 446–459, 2020. doi: 10.1109/ISCA45697.2020.00045.DOI
  28. [29]Stefan Remke and Alexander Breuer. Hello SME! Generating fast matrix multiplication kernels using the Scalable Matrix Extension. In SC24-W: Workshops of the International Conference for High Performance Computing, Networking, Storage and Analysis, pp. 1443–1454, 2024. doi: 10.1109/SCW63240.2024.00185.DOI
  29. [30]ShareGPT. (2023). ShareGPT_Vicuna_unfiltered. <a href="https://doi.org/https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered" rel="noopener noreferrer" target="_blank">https://doi.org/https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered</a>
  30. [31]Stephens, N., Biles, S., Boettcher, M., Eapen, J., Eyole, M., Gabrielli, G., Hornsell, M., Magklis, G., Martinez, A., Premillieu, N., Reid, A., Rico, A., & Walker, P. (2017). The ARM Scalable Vector Extension. IEEE Micro, 37(2), 26–39.
  31. [32]Tencent. (2017). ncnn: A high-performance neural network inference framework optimized for the mobile platform. <a href="https://doi.org/https://github.com/Tencent/ncnn" rel="noopener noreferrer" target="_blank">https://doi.org/https://github.com/Tencent/ncnn</a>
  32. [33]Mircea Trofin, Yundi Qian, Eugene Brevdo, Zinan Lin, Krzysztof Choromanski, and David Li. MLGO: a machine learning guided compiler optimizations framework. arXiv preprint arXiv:2101.04808, 2021.arXiv
  33. [35]Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu, Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi Song, Bowen Li, Jaskirat Singh, Hoang H. Tran, Fuqiang Li, Ren Ma, Mingzhang Zheng, Bill Qian, Yanjun Shao, Niklas Muennighoff, Yizhe Zhang, Binyuan Hui, Junyang Lin, Robert Brennan, Hao Peng, Heng Ji, and Graham Neubig. OpenHands: An open platform for AI software developers as generalist agents. In International Conference on Learning Representations (ICLR), 2025.arxiv.org/abs/2407.16741
  34. [36]Anjiang Wei, Tarun Suresh, Huanmi Tan, Yinglun Xu, Gagandeep Singh, Ke Wang, and Alex Aiken. SuperCoder: Assembly program superoptimization with large language models. arXiv preprint arXiv:2505.11480, 2025.arxiv.org/abs/2505.11480
  35. [37]Zhongzhen Wen, Yinghui Zhang, Zhong Li, Zhongxin Liu, Linna Xie, and Tian Zhang. MultiKernelBench: A multi-platform benchmark for kernel generation. arXiv preprint arXiv:2507.17773, 2025.arxiv.org/abs/2507.17773
  36. [38]John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, and Ofir Press. SWE-agent: Agent-computer interfaces enable automated software engineering. In Advances in Neural Information Processing Systems (NeurIPS), 2024.arxiv.org/abs/2405.15793
  37. [39]Peiyu Zang, Jian Tao, Jialing Zhang, Yichen Yuan, Wentao Zhang, Guang Liu, and Yonghua Lin. KernelGenBench: Can LLMs and agents write efficient kernels across operator sources and hardware platforms? arXiv preprint arXiv:2607.27231, 2026.arxiv.org/abs/2607.27231
  38. [40]Zijian Zhang, Rong Wang, Shiyang Li, Yuebo Luo, Mingyi Hong, and Caiwen Ding. CudaForge: An agent framework with hardware feedback for CUDA kernel optimization. arXiv preprint arXiv:2511.01884, 2025.arxiv.org/abs/2511.01884
  39. [41]Lianmin Zheng, Chengfan Jia, Minmin Sun, Zhao Wu, Cody Hao Yu, Ameer Haj-Ali, Yida Wang, Jun Yang, Danyang Zhuo, Koushik Sen, Joseph E. Gonzalez, and Ion Stoica. Ansor: Generating high-performance tensor programs for deep learning. In 14th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2020.arxiv.org/abs/2006.06762
  40. [42]AI, Z. (2026). GLM-5.3. <a href="https://doi.org/https://huggingface.co/zai-org/GLM-5.3" rel="noopener noreferrer" target="_blank">https://doi.org/https://huggingface.co/zai-org/GLM-5.3</a>
  41. [43]Xingze Zou, Jing Wang, Yuhua Zheng, Xueyi Chen, Haolei Bai, Lingcheng Kong, Syed A. R. Abu-Bakar, Zhaode Wang, Chengfei Lv, Haoji Hu, and Huan Wang. MobileKernelBench: Can LLMs write efficient kernels for mobile devices? arXiv preprint arXiv:2603.11935, 2026.arxiv.org/abs/2603.11935

Paper details

vlnc:W_kzkkgcc8
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

AI tools

View statement
Looking for related papers…
Contents