e2e gemm: real-activation workloads for Qwen3.5-4B, Llama-3.1-8B, OLMoE-1B-7B; unified quantized gemm definitions

#8

Summary

Real-activation workloads for the e2e llama.cpp GEMM operators of three models and MoE operators, rebuilt with kgen
(collect -> add workload -> capture -> calibrate), the operator sets re-selected with E2E total running share rule, and the quantized gemm definitions unified on the ggml block-bytes ABI under plain names (no ggml_ prefix), so that All gemm kernels supports e2e replay test.

E2E total running share rules

Identify Execution Candidates (role, type, shape):
- Filter for unique operator candidates defined by their role, data type, and tensor shape to prevent redundant benchmarking of identical kernels.
- Skip operators too small to time reliably to eliminate measurement noise.
Rank Candidates by Time Share (Not Count):
- Rank operators using estimated execution time rather than raw layer or call counts.Operators with higher time share are more critical to benchmark, as they contribute more to overall execution time.
- Feel free to customize your ranking metric based on the model/kernel's characteristics, for example: For memory-bound decode, estimate time share based on weight bytes accessed per token.For MoE experts, scale memory/compute weight by the active routing fraction per token (e.g., top-$k$ active experts).
Apply Pareto Tail Cut (90% Cumulative Share per Group):
- Group candidates by (model, quantization type).
- Within each group, rank candidates by share, calculate cumulative share relative to the group total, and retain operators until the running total first reaches or crosses 90%.
- Drop all remaining long-tail operators beyond the crossing point.
Provide Audit Trail & Context:
- List all dropped operators explicitly for transparency.
- State explicitly whether the time share is estimated or measured.

What is in this PR

The following gemm kernels are recalibrated and selected with the group:

Group Total (all shapes) Definition E2E share Cumulative / total Keep?
qwen3.5-4b · Q4_K 0.4987 q4_K_n9216_k2560 0.3112 0.3112 / 0.4987 = 62.40% keep
q4_K_n2560_k9216 0.0778 0.3890 / 0.4987 = 78.00% keep
q4_K_n4096_k2560 0.0519 0.4409 / 0.4987 = 88.41% keep
q4_K_n8192_k2560 0.0346 0.4755 / 0.4987 = 95.35% keep
q4_K_n2560_k4096 0.0173 0.4928 / 0.4987 = 98.82% Remove
q4_K_n1024_k2560 0.0059 0.4987 / 0.4987 = 100% Remove
qwen3.5-4b · Q5_K 0.1902 q5_K_n8192_k2560 0.1268 66.67% keep
q5_K_n2560_k4096 0.0634 100% keep
qwen3.5-4b · Q6_K 0.3083 q6_K_n248320_k2560 0.1910 0.1910 / 0.3083 = 61.95% keep
q6_K_n2560_k9216 0.1134 0.3044 / 0.3083 = 98.73% keep
q6_K_n1024_k2560 0.0039 0.3083 / 0.3083 = 100% Remove
llama-3.1-8b · Q4_K 0.7277 q4_K_n14336_k4096 0.4578 0.4578 / 0.7277 = 62.91% keep
q4_K_n4096_k4096 0.1308 0.5886 / 0.7277 = 80.88% keep
q4_K_n4096_k14336 0.1145 0.7031 / 0.7277 = 96.62% keep
q4_K_n1024_k4096 0.0246 0.7277 / 0.7277 = 100% Remove
llama-3.1-8b · Q6_K 0.2721 q6_K_n4096_k14336 0.1669 0.1669 / 0.2721 = 61.34% keep
q6_K_n128256_k4096 0.0933 0.2602 / 0.2721 = 95.63% keep
q6_K_n1024_k4096 0.0119 0.2721 / 0.2721 = 100% Remove
olmoe-q4_k_m · Q4_K 0.6882 q4_K_n1024_k2048 / n2048_k2048 / n2048_k1024 0.4078 / 0.1785 / 0.1019 59.26% / 85.19% / 100% keep ×3
olmoe-q4_k_m · Q6_K 0.3000 q6_K_n2048_k1024 / n50304_k2048 / n2048_k2048 0.1487 / 0.1141 / 0.0372 49.57% / 87.60% / 100% keep ×3
olmoe-q8_0 · Q8_0 0.9928 q8_0_n1024_k2048 0.4530 0.4530 / 0.9928 = 45.63% keep
q8_0_n2048_k1024 0.2265 0.6795 / 0.9928 = 68.44% keep
q8_0_n2048_k2048 0.2264 0.9059 / 0.9928 = 91.25% keep
q8_0_n50304_k2048 0.0869 0.9928 / 0.9928 = 100% Remove

The following moe kernels are recalibrated with model qwen1.5-moe-a2.7b: moe_q4_k_m_e60_k4_d2048_ff1536, moe_q4_k_m_e64_k8_d2048_ff1024, moe_q8_0_e60_k4_d2048_ff1408, moe_q8_0_e64_k8_d2048_ff1024, no new tensor are produced.

Removed definitions (with their workloads, tensors and every author's solutions)

The following gemms are removed based on e2e total running share rules:

  • Qwen3.5-4B: gemm_q4_K_n2560_k4096, gemm_q4_K_n1024_k2560, gemm_q6_K_n1024_k2560
  • Llama-3.1-8B: gemm_q4_K_n1024_k4096, gemm_q6_K_n1024_k4096

The following gemms are replaced by unified-ABI definitions:

  • legacy triplet-ABI gemm_q4_k_m_n{1024_k2048,1408_k2048,2048_k1024,2048_k1536,2048_k2048} and gemm_q8_0_n{1408_k2048,2048_k1408} (replaced by the unified-ABI definitions above; the Qwen1.5-MoE shapes are re-created)
  • the old gemm_ggml_* names (renamed to gemm_*)

Other files

  • expected_sets_sve.json, subset_sve.json, subset_sme.json: gemm_q4_k_m_* -> gemm_q4_K_* (same shapes)
  • TASKS.md: e2e section (22 operators), llama.cpp section (renamed gemms, current workload counts), summary
  • bf16 gemm, moe and rms_norm workloads refreshed to the prefill M range (1..512)

How the workloads were built

  • Activations: each model run in PyTorch bf16 on ShareGPT prompts (up to 512 tokens), forward-hooked per layer; OLMoE experts rebuilt as per-expert nn.Linear (verified bit-identical to transformers' reference loop) so each expert call is one gemm with M = tokens routed to it.
  • Operator selection: shapes ranked by per-token weight-byte share (decode, memory-bound estimate); per quantization type, keep operators until the running share first reaches 90% of that type's total (as E2E total running share rule explained). Qwen3.5-4B and Llama-3.1-8B use the shares already recorded in their e2e inventories (e2e-share tags); OLMoE comes from a kgen discover plugin run over the GGUF headers of OLMoE-1B-7B Q4_K_M and Q8_0.
  • baseline_sqnr_db calibrated on aarch64 (Graviton4) with the corrected bf16 tensor loader. The Qwen1.5-MoE definitions use deterministic random inputs.
  • The Llama weights come from the ungated unsloth/Meta-Llama-3.1-8B mirror.

Notes for reviewers

  • Needs the bf16 bit-pattern fix in bench/runtime/inputs.py (code repo, not part of this PR): half-precision tensor inputs are stored as raw 16-bit patterns.
  • The Fable solutions of the kept operators were optimized on the earlier 6-workload (M <= 32) sets and have not been re-evaluated on these workloads.
  • OLMoE operators are marked ? in TASKS.md (no recorded speedup run yet); the 4 restored Qwen1.5-MoE definitions have no e2e tag.
  • LFS: 412 new tensor files (~242 MB).
ArtificialRay7579 changed pull request status to open

Will be merged after e2e gemm kernel rerun ends

Cannot merge
This branch has merge conflicts in the following files:
  • TASKS.md

Sign up or log in to comment