KernelShift / TASKS.md
VanishD's picture
shuaiwei huang
allen wu
weihua du
KernelShift dataset
bbe836b
|
Raw History Blame Contribute Delete
19.7 kB

Tasks and baselines

Every definition in this dataset, with the expert baseline it is scored against on each hardware tier: whether it runs there, and whether it is specialized for that tier. The marks come from the dataset, the recorded runs and a check of each baseline's code. loop_120 and loop_124 are not in the Eval set (see the notes on ✗). 7 KleidiAI definitions have an SVE expert, among them gemm_qai8dxp_qs4c32_n256_k512 (the Graviton3 twin of gemm_qai8dxp_qs4c32_sme2_n256_k512) and softmax_fp32.

Mark Meaning
★ Runs on that machine, and its code is specialized for the tier: it uses SVE on Graviton3, SVE2-only instructions on Graviton4, SME (ZA) on M4
✓ Runs on that machine as optimized code (hand-written or vendor), but not specialized for the tier, e.g. NEON code, or SVE code on Graviton4 or in streaming mode on M4 (streaming SVE counts as ✓, not ★). It does not fall back to compiler-vectorized scalar code
? A baseline exists for this tier but has not been confirmed on the machine yet
✗ Tried and fails on the machine (see the notes at the end)
— No baseline for this tier

Tiers: SVE = Graviton3 (c7g), SVE2 = Graviton4 (c8g), SME2 = Apple M4 (mac-m4.metal). "Runs" means a recorded run on that machine computed speedups against the baseline; for SIMD Loops on M4, the baseline was also run on every workload.

How each source's baseline is chosen and marked is explained under Notes on the baselines at the end.

Eval set = the 99 evaluated kernels listed in expected_sets.json: 79 on Graviton3 (23 ncnn, 26 llama.cpp, 24 SIMD Loops, 6 KleidiAI with an SVE expert; softmax_fp32 is not in it) and, under kleidiai-sme2, the 20 KleidiAI kernels with an SME2 expert, evaluated on M4. Subset = the 32-kernel subset; subset_sve.json and subset_sme2.json differ only in the KleidiAI GEMM (gemm_fp32_n512_k512 vs gemm_fp32_sme2_n512_k512), so 33 rows carry the mark.

Summary

Source Definitions SVE ★ / ✓ / ? / ✗ / — SVE2 ★ / ✓ / ? / ✗ / — SME2 ★ / ✓ / ? / ✗ / —
ncnn 23 0 / 23 / 0 / 0 / 0 0 / 23 / 0 / 0 / 0 0 / 23 / 0 / 0 / 0
llama.cpp 26 0 / 26 / 0 / 0 / 0 0 / 26 / 0 / 0 / 0 0 / 26 / 0 / 0 / 0
SIMD Loops 47 25 / 0 / 0 / 5 / 17 10 / 17 / 0 / 9 / 11 7 / 16 / 0 / 8 / 16
KleidiAI 30 7 / 3 / 0 / 0 / 20 0 / 7 / 1 / 0 / 22 20 / 0 / 0 / 0 / 10
e2e (llama.cpp GEMMs) 18 0 / 18 / 0 / 0 / 0 0 / 18 / 0 / 0 / 0 0 / 18 / 0 / 0 / 0
All 144 32 / 70 / 0 / 5 / 37 10 / 91 / 1 / 9 / 33 27 / 83 / 0 / 8 / 26

ncnn (23)

Definition Op Workloads Eval set Subset SVE SVE2 SME2
conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1 conv2d_depthwise 20 ✓ ✓ ✓ ✓ ✓
conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1 conv2d_depthwise 20 ✓ ✓ ✓ ✓
conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2 conv2d_depthwise 20 ✓ ✓ ✓ ✓ ✓
conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2 conv2d_depthwise 20 ✓ ✓ ✓ ✓
conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1 conv2d_depthwise 20 ✓ ✓ ✓ ✓ ✓
conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1 conv2d_depthwise 20 ✓ ✓ ✓ ✓
conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2 conv2d_depthwise 20 ✓ ✓ ✓ ✓ ✓
conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2 conv2d_depthwise 20 ✓ ✓ ✓ ✓
conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0 conv2d 20 ✓ ✓ ✓ ✓
conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0 conv2d 20 ✓ ✓ ✓ ✓
conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1 conv2d 20 ✓ ✓ ✓ ✓ ✓
conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1 conv2d 20 ✓ ✓ ✓ ✓
conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3 conv2d 11 ✓ ✓ ✓ ✓ ✓
conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0 conv2d 20 ✓ ✓ ✓ ✓
conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0 conv2d 20 ✓ ✓ ✓ ✓
conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1 conv2d 20 ✓ ✓ ✓ ✓ ✓
conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1 conv2d 20 ✓ ✓ ✓ ✓
conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3 conv2d 11 ✓ ✓ ✓ ✓ ✓
pooling_fp32_global_avg pooling 20 ✓ ✓ ✓ ✓ ✓
pooling_fp32_max_kh2_kw2_sh2_sw2_p0 pooling 6 ✓ ✓ ✓ ✓
pooling_fp32_max_kh3_kw3_sh1_sw1_p1 pooling 6 ✓ ✓ ✓ ✓
pooling_fp32_max_kh3_kw3_sh2_sw2_p0 pooling 6 ✓ ✓ ✓ ✓
pooling_fp32_max_kh3_kw3_sh2_sw2_p1 pooling 11 ✓ ✓ ✓ ✓ ✓

llama.cpp (26)

Definition Op Workloads Eval set Subset SVE SVE2 SME2
gemm_bf16_n1024_k2048 gemm 24 ✓ ✓ ✓ ✓
gemm_bf16_n1408_k2048 gemm 24 ✓ ✓ ✓ ✓
gemm_bf16_n2048_k1024 gemm 24 ✓ ✓ ✓ ✓
gemm_bf16_n2048_k1408 gemm 24 ✓ ✓ ✓ ✓
gemm_bf16_n2048_k2048 gemm 24 ✓ ✓ ✓ ✓ ✓
gemm_q4_k_m_n1024_k2048 gemm 24 ✓ ✓ ✓ ✓
gemm_q4_k_m_n1408_k2048 gemm 24 ✓ ✓ ✓ ✓
gemm_q4_k_m_n2048_k1024 gemm 24 ✓ ✓ ✓ ✓
gemm_q4_k_m_n2048_k1536 gemm 24 ✓ ✓ ✓ ✓
gemm_q4_k_m_n2048_k2048 gemm 24 ✓ ✓ ✓ ✓ ✓
gemm_q8_0_n1024_k2048 gemm 24 ✓ ✓ ✓ ✓
gemm_q8_0_n1408_k2048 gemm 24 ✓ ✓ ✓ ✓ ✓
gemm_q8_0_n2048_k1024 gemm 24 ✓ ✓ ✓ ✓
gemm_q8_0_n2048_k1408 gemm 24 ✓ ✓ ✓ ✓
gemm_q8_0_n2048_k2048 gemm 24 ✓ ✓ ✓ ✓ ✓
gqa_bf16_h32_d128_kvh8 gqa 20 ✓ ✓ ✓ ✓
mha_bf16_h16_d128_kvh16 mha 20 ✓ ✓ ✓ ✓ ✓
mla_decode_bf16_h16_lora512_rope64_v128 mla_decode 20 ✓ ✓ ✓ ✓
mla_prefill_bf16_h16_qk192_vo128 mla_prefill 20 ✓ ✓ ✓ ✓
moe_bf16_e60_k4_d2048_ff1408 moe 20 ✓ ✓ ✓ ✓
moe_bf16_e64_k8_d2048_ff1024 moe 20 ✓ ✓ ✓ ✓ ✓
moe_q4_k_m_e60_k4_d2048_ff1536 moe 20 ✓ ✓ ✓ ✓
moe_q4_k_m_e64_k8_d2048_ff1024 moe 20 ✓ ✓ ✓ ✓ ✓
moe_q8_0_e60_k4_d2048_ff1408 moe 20 ✓ ✓ ✓ ✓
moe_q8_0_e64_k8_d2048_ff1024 moe 20 ✓ ✓ ✓ ✓ ✓
rms_norm_fp32_d2048 rms_norm 24 ✓ ✓ ✓ ✓ ✓

SIMD Loops (47)

Loops without the Eval set mark are in the dataset but not in the main results. loop_005, 006, 034, 128 and the matrix loops 216–223 (except 219) have no expert baseline yet.

Definition Op Workloads Eval set Subset SVE SVE2 SME2
loop_001 10 ✓ ✓ ★ ✓ ✓
loop_002 10 ✓ ✓ ★ ✓ ✗
loop_003 10 ✓ ✓ ★ ✓ ✓
loop_004 10 ✓ ★ ✓ ✓
loop_008 10 ✓ ★ ✓ —
loop_024 10 ✓ ✓ ★ ✓ ✓
loop_027 10 ✓ ✓ ★ ✓ ✗
loop_028 10 ✓ ★ ✓ ✗
loop_029 10 ✓ ★ ✓ ✓
loop_033 10 ✓ ★ ✓ ✓
loop_035 10 ✓ ✓ ★ ✓ ✓
loop_037 10 ✓ ✓ ★ ✓ ✓
loop_038 10 ✓ ★ ✓ ✗
loop_103 10 ✓ ★ ★ —
loop_105 10 ✓ ✓ ★ ★ ✓
loop_108 10 ✓ ✓ ★ ★ ✓
loop_109 10 ✓ ★ ★ ✓
loop_110 10 ✓ ★ ★ ✓
loop_112 10 ✓ ★ ★ ✓
loop_113 10 ✓ ✓ ★ ★ ✓
loop_114 10 ✓ ★ ★ ✗
loop_120 10 ✗ ✗ —
loop_124 10 ✗ ✗ —
loop_126 10 ✓ ✓ ★ ✓ ✓
loop_127 10 ✓ ✓ ★ ✓ ✗
loop_219 10 ✓ ★ ✓ ★
loop_005 10 — — —
loop_006 10 — — —
loop_010 10 ★ ✓ ✗
loop_032 10 ✗ ✗ —
loop_034 10 — — —
loop_101 10 — ★ ✓
loop_102 10 — ★ —
loop_104 10 — ✗ —
loop_106 10 — ✗ —
loop_121 10 ✗ ✗ —
loop_122 10 ✗ — —
loop_123 10 — ✗ —
loop_128 10 — — ✗
loop_130 10 — ✗ —
loop_135 10 — ✗ —
loop_216 10 — — ★
loop_217 10 — — ★
loop_218 10 — — ★
loop_220 10 — — ★
loop_221 10 — — ★
loop_223 10 — — ★

KleidiAI (30)

Definition Op Workloads Eval set Subset SVE SVE2 SME2
conv2d_depthwise_f16_nhwc_kh3_kw3_s1_p1 conv2d_depthwise 20 ✓ — — ★
conv2d_depthwise_fp32_nhwc_kh3_kw3_s1_p1 conv2d_depthwise 20 ✓ — — ★
conv2d_f16_nhwc_kh3_kw3_valid_c32_c64 conv2d 20 ✓ — — ★
conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64 conv2d 16 ✓ ★ ✓ —
conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2 conv2d 16 ✓ — — ★
gemm_bf16_n512_k512 gemm 15 ✓ — — ★
gemm_f16_n512_k512 gemm 13 ✓ — — ★
gemm_f16_qai4c32_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_f16_qs4cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_f16_qs8cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_f16act_qs4c32_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_f32_bf16_n512_k512 gemm 13 ✓ ✓ —
gemm_fp32_n512_k512 gemm 13 ✓ ✓ ★ ✓ —
gemm_fp32_sme2_n512_k512 gemm 13 ✓ ✓ — — ★
gemm_i32_u8_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qai4c32_n256_k512 gemm 13 ✓ ✓ —
gemm_qai4c32_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qai8_qsi8cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qai8dxp_qs4c32_n256_k512 gemm 13 ✓ ★ — —
gemm_qai8dxp_qs4c32_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qs4c32_n256_k512 gemm 13 ✓ ★ — —
gemm_qs4c32_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qs4cx_n512_k512 gemm 13 ✓ ★ ✓ —
gemm_qs4cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qs8cx_n512_k512 gemm 13 ✓ ★ ✓ —
gemm_qs8cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_qsu2cx_n256_k512 gemm 13 ✓ ✓ —
gemm_qsu2cx_sme2_n256_k512 gemm 13 ✓ — — ★
gemm_u8_f32_sme2_n256_k512 gemm 13 ✓ — — ★
softmax_fp32 softmax 13 ★ ? —

e2e (llama.cpp GEMMs) (18)

Definition Op Workloads Eval set Subset SVE SVE2 SME2
gemm_ggml_q4_K_n1024_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n1024_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n14336_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n2560_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n2560_k9216 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n4096_k14336 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n4096_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n4096_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n8192_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q4_K_n9216_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q5_K_n2560_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q5_K_n8192_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q6_K_n1024_k2560 gemm 6 ✓ ✓ ✓
gemm_ggml_q6_K_n1024_k4096 gemm 6 ✓ ✓ ✓
gemm_ggml_q6_K_n128256_k4096 gemm 4 ✓ ✓ ✓
gemm_ggml_q6_K_n248320_k2560 gemm 4 ✓ ✓ ✓
gemm_ggml_q6_K_n2560_k9216 gemm 6 ✓ ✓ ✓
gemm_ggml_q6_K_n4096_k14336 gemm 6 ✓ ✓ ✓

Notes on ✗

  • loop_120 and loop_124 (Graviton3 and Graviton4): both sort their first input in place. The harness calls the kernel on the same buffers for the correctness, warmup and timed calls and does not restore the input in between, so every timed call, the baseline's included, sorts data that is already sorted, and a kernel that returns early on sorted input or caches its result looks 20–100x faster. The baselines themselves run correctly; the timings are not valid, so both loops are left out of the Eval set.
  • loop_032 (baseline-simd-loop-sve on Graviton3): wrong results on 7 of 10 workloads.
  • loop_121 (baseline-simd-loop-sve on Graviton3): hangs (no result after 20 min).
  • loop_122 (baseline-simd-loop-sve on Graviton3): about 960x slower than the auto-vectorized scalar starting point.
  • loop_032 (baseline-simd-loop-sve2 on Graviton4): wrong results on 7 of 10 workloads.
  • loop_104 (baseline-simd-loop-sve2 on Graviton4): wrong results on 1 of 10 workloads.
  • loop_106 (baseline-simd-loop-sve2 on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
  • loop_121 (baseline-simd-loop-sve2 on Graviton4): hangs (no result after 15 min).
  • loop_123 (baseline-simd-loop-sve2 on Graviton4): about 3.9x slower than the auto-vectorized scalar starting point.
  • loop_130 (baseline-simd-loop-sve2 on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
  • loop_135 (baseline-simd-loop-sve2 on Graviton4): does not compile (its compile flags lack the SVE2 extension it uses).
  • loop_002 (baseline-simd-loop-sme2 on M4): about 2.2x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_010 (baseline-simd-loop-sme2 on M4): about 44x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that (the scalar loop exits early, while the baseline scans the whole array).
  • loop_027 (baseline-simd-loop-sme2 on M4): about 2.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_028 (baseline-simd-loop-sme2 on M4): about 6.1x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_038 (baseline-simd-loop-sme2 on M4): about 5.0x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_114 (baseline-simd-loop-sme2 on M4): about 3.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_127 (baseline-simd-loop-sme2 on M4): about 5.3x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that.
  • loop_128 (baseline-simd-loop-sme2 on M4): 2.01x slower than the scalar starting point auto-vectorized for M4, so it fails the rule that a baseline be at most 2x slower than that, just over the limit.

Notes on the baselines

  • ncnn → baseline-ncnn, the upstream ncnn kernel, the same on every tier. ncnn is built with its SVE options off, so this is NEON code everywhere: ✓, never ★.
  • llama.cpp and e2e → baseline-llamacpp, the ggml CPU kernel built natively on each machine. The exception is the five gemm_bf16_* GEMMs: ggml's bf16 mul_mat is scalar on Arm, so their baseline is a NEON BFMMLA kernel written for this benchmark. Which kernels reach ggml's SVE code has not been checked, so these are ✓; ggml's KleidiAI path is off. ggml picks its kernel by op, data type and CPU features, not by shape, so a cell with no recorded run is ✓ when the same op and data type ran on that machine (8 llama.cpp definitions on Graviton4). e2e has recorded runs only on Graviton4 and is ✓ on Graviton3 and M4 for the same reason (q4_K ran on both in the llama.cpp set; q5_K and q6_K have not).
  • SIMD Loops → one hand-written Arm baseline per tier. baseline-simd-loop-sve2 uses SVE2-only instructions in some loops (★) and is SVE code in the rest (✓). Of the 31 baseline-simd-loop-sme2, 24 are SVE code run in streaming mode (__arm_locally_streaming, tag sme2-kernel:streaming-sve) and 7 use ZA (tag sme2-kernel:za: the matrix loops 216–221 and 223). Streaming SVE counts as ✓, not ★, because it uses nothing SME adds (ZA, outer products, SME2 multi-vector instructions); the ZA ones are ★. All 31 were run on M4 and pass every workload; the 2x check against the auto-vectorized starting point flags 8 of them, which are ✗ (see the notes on ✗). loop_032 has no SME2 code upstream, and under -mcpu=apple-m4 its source falls back to NEON, which streaming mode rejects on M4, so it has no baseline-simd-loop-sme2 (—).
  • KleidiAI → baseline-kleidiai: each kernel uses an SVE micro-kernel (gemm_fp32, gemm_qs4c32, conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64), a NEON dot-product / i8mm / bf16 one (gemm_f32_bf16, gemm_qai4c32, gemm_qsu2cx; KleidiAI has no SVE kernel for them: ✓ on Graviton3 and Graviton4, not specialized for either), or an SME2 one (M4). gemm_qs8cx and gemm_qs4cx choose at run time: on 256-bit SVE with SVE I8MM (Graviton3) they run KleidiAI's SVE micro-kernels (★; these need exactly 256-bit vectors), elsewhere (Graviton4) a NEON pair (✓). gemm_qs4cx keeps the NEON GEMV at M = 1, as KleidiAI has no SVE GEMV for that format. All their KleidiAI sources are from commit 9e404c3. Of the SME2 definitions, conv2d_fp32_nhwc_kh3_kw3_s1_p1_c32_c64_sme2 and the quantized and integer GEMMs run SME2 mopa micro-kernels (★); gemm_i32_u8 and gemm_u8_f32 use KleidiAI's newer kai_matmul_uker API. gemm_qai8dxp_qs4c32_n256_k512 runs kai_matmul_clamp_f32_qai8dxp2vsx8sf32_qsi4c32p8x8s16s0sbf16bf32_8vsx8_sve_i8mm for M > 1 (exactly 256-bit SVE, so — on Graviton4) and KleidiAI's NEON GEMV kai_matmul_clamp_f32_qai8dxp1x4_qsi4c32p8x4_1x8_neon_dotprod (the fastest GEMV of the family there) at M = 1, as there is no SVE GEMV for that format. softmax_fp32 runs kai_softmax_f32_f32_1d_sve_fexpa (any vector length; ? on Graviton4, not yet run there) and is judged by SQNR against it: its outputs (about 1/N) are below the default absolute tolerance.