File size: 6,595 Bytes
bbe836b 0d8bf9d bbe836b 87bcc9f bbe836b 48928f0 bbe836b 0d8bf9d bbe836b 0d8bf9d bbe836b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | ---
license: apache-2.0
language:
- en
tags:
- code
- kernels
- benchmark
- arm
- aarch64
- sve
- sve2
- sme2
- ncnn
- llama.cpp
- kleidiai
- simd-loops
pretty_name: KernelShift
size_categories:
- n<1K
configs:
- config_name: tasks
data_files: viewer/tasks.parquet
default: true
- config_name: solutions
data_files: viewer/solutions.parquet
---
# KernelShift
Benchmark data for KernelShift: kernel optimization tasks for **Arm (AArch64)
CPUs** across four generations of vector and matrix extensions: Neon,
SVE (AWS Graviton3, 256-bit), SVE2 (AWS Graviton4, 128-bit) and SME2 (Apple M4). Each kernel *definition*
comes with *workloads*, a scalar *reference* that serves as the correctness
check and the agent's starting point, and an *expert baseline*: a candidate
kernel is checked against the reference and timed against the baseline.
Code, the agent environments and the evaluation scripts:
<https://github.com/cmu-l3/kernel-shift>. Project website:
<https://cmu-l3.github.io/kernel-shift/>.
## Contents
144 kernel definitions from four open-source projects, plus the matrix
multiplications of two LLMs; 99 of them form the evaluation set.
| Source | Definitions | Evaluation set | Op types | Expert baseline |
|------------|------------:|----------------:|-------------------------------------------------------------------|--------------------------------------|
| ncnn | 23 | 23 | conv2d, conv2d_depthwise, pooling | `baseline-ncnn` |
| llama.cpp | 26 | 26 | gemm, moe, mha, gqa, mla_decode, mla_prefill, rms_norm | `baseline-llamacpp` |
| SIMD Loops | 47 | 24 | one loop per definition | `baseline-simd-loop-{sve,sve2,sme2}` |
| KleidiAI | 30 | 6 SVE + 20 SME2 | gemm, conv2d, conv2d_depthwise, softmax | `baseline-kleidiai` |
| e2e | 18 | – | gemm on q4_K / q5_K / q6_K weights of Qwen3.5-4B and Llama-3.1-8B | `baseline-llamacpp` |
| **Total** | **144** | **99** | | |
- `expected_sets.json` lists the evaluation set: 79 kernels evaluated on
Graviton3 (`ncnn`, `llama.cpp`, `simd-loop`, and `kleidiai` for the six
KleidiAI kernels with an SVE expert) and, under `kleidiai-sme2`, the 20
KleidiAI kernels with an SME2 expert, evaluated on Apple M4. The other 23 SIMD
Loops definitions are not in it (see `TASKS.md`); for example, `loop_120`
and `loop_124` sort their input in place, so their timings are not valid.
- `subset_sve.json` and `subset_sme2.json`: a 32-kernel subset for the SVE and
SME2 tiers; they differ only in the KleidiAI GEMM.
- The 18 e2e definitions are the quantized matrix multiplications of
Qwen3.5-4B (11) and Llama-3.1-8B-Instruct (7) in llama.cpp, for the
end-to-end inference experiments. They carry an `e2e:<model>` tag.
- [`TASKS.md`](TASKS.md) lists every definition with its expert baseline on
each tier: whether it runs there and whether it is specialized for that
tier.
## Layout
```
definitions/<op_type>/<name>.json kernel spec: axes, inputs/outputs, PyTorch reference
workloads/<op_type>/<name>.jsonl one workload per line: axis values and how to build each input
solutions/<source>/<author>/... kernels, with their sources inlined in the JSON
tensors/gemm/<name>/*.npy recorded activations used by the e2e workloads
results/e2e-qwen3.5-4b.json end-to-end results for Qwen3.5-4B
viewer/tasks.parquet one row per definition, for the dataset viewer
viewer/solutions.parquet one row per solution, for the dataset viewer
```
The two `viewer/` tables are generated from the files above so the Hugging Face
dataset viewer can show them; the benchmark code reads the original files.
`tasks` has each definition's source, op type, evaluation-set and subset
membership, workload count, baselines and PyTorch reference (shapes as JSON
strings). `solutions` has each solution's author, description and main source
file (`kernel.cpp`, or `binding.cpp` for KleidiAI).
Solution authors:
- `reference-scalar`: scalar code, the correctness reference and the
starting point.
- `baseline-<source>`: the expert baselines. SIMD Loops has a separate one per
tier, `baseline-simd-loop-<isa>`.
- `autovec` (SIMD Loops): the loop compiled with the compiler's
auto-vectorizer.
- `claude-code-claude-fable-5-1` (llama.cpp): the agent-written kernels for
the 18 e2e definitions (next section); they are not baselines.
Definitions tagged `correctness:sqnr` (quantized and BF16 kernels) are
checked by signal-to-quantization-noise ratio instead of element-wise
tolerances.
## End-to-end results
For the end-to-end inference experiments, Claude Code with Claude Fable 5.1
wrote a kernel for each of the 18 e2e definitions (11 for Qwen3.5-4B, 7 for
Llama-3.1-8B-Instruct), in `solutions/llama.cpp/claude-code-claude-fable-5-1/`.
The kernels are substituted into llama.cpp and compared with stock llama.cpp,
which uses its repacked i8mm kernels, on AWS Graviton4.
`results/e2e-qwen3.5-4b.json` holds the Qwen3.5-4B results reported in the
paper: prefill and decode speedups at 1, 4 and 16 threads, the prompt-length
and micro-batch sweeps, perplexity on wikitext-2, and the speedup of the
kernels alone over the repacked kernels.
## Usage
```bash
git clone https://github.com/cmu-l3/kernel-shift
cd kernel-shift
pip install -r requirements.txt
hf download l3lab/KernelShift --repo-type dataset --local-dir bench-trace
python -m bench.cli bench --dataset simd-loop --isa sve \
--definition loop_001 --solution reference-scalar_loop_001
```
## Authors
Shuaiwei Huang\*, Weihua Du\*, Allen Wu\* (Carnegie Mellon University),
Ivan Fox, Manupa Karunaratne (Arm Ltd.),
Yiming Yang, Sean Welleck (Carnegie Mellon University).
\* Equal contribution.
## License
Released under the Apache-2.0 license. The baselines derive from or wrap
[ncnn](https://github.com/Tencent/ncnn) (BSD-3-Clause),
[llama.cpp / ggml](https://github.com/ggml-org/llama.cpp) (MIT),
[KleidiAI](https://gitlab.arm.com/kleidi/kleidiai) (Apache-2.0) and
[SIMD Loops](https://gitlab.arm.com/architecture/simd-loops) (BSD-3-Clause);
see each project for its license terms.
|