KernelShift / README.md
VanishD's picture
Shuaiwei Huang
Allen Wu
Weihua Du
README: describe the dataset as in the paper
87bcc9f verified
|
Raw History Blame Contribute Delete
6.6 kB
---
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.