Repository navigation
ggml-cpu: repack kernels for targets without dotprod (ARMv8.0 64-bit) for Q4_0/Q8_0 - #32142
Conversation
dfd5157 to
1fcbf43
Compare
|
@ServeurpersoCom please verify. Thanks. |
ServeurpersoCom
left a comment
There was a problem hiding this comment.
Tested on a Cortex-A53 emulated with qemu in my rootless container. This uses qemu user mode, so it needs no KVM, no binfmt and no privileges: qemu translates the aarch64 binary process by process, and with -cpu cortex-a53 any dotprod instruction would crash with SIGILL.
cmake -B build -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8-a
qemu-aarch64 -L /usr/aarch64-linux-gnu -cpu cortex-a53 build/bin/llama-perplexity -m Qwen3-0.6B-Q4_0.gguf ...
Correctness looks good: the new kernels give the same results as the generic ones, and the int16 sums don't overflow even with every value at its max. A full mul_mat through the repack buffer also matches the plain CPU path, row tails included.
With this PR, Qwen3-0.6B Q4_0 on the emulated A53 gets the same perplexity (9.8626) as the existing dotprod repack on an emulated A76.
Emulation says nothing about speed, so for the performance numbers I trust your measurements on the real board.
@rjtokenring Nit: the ggml_hsum_4x_s16 comment says lanes must stay below 8192, but the pairwise add only needs below 16384.
11e1b5e to
2d677c3
Compare
|
@ServeurpersoCom for completeness, here is a bech performed on a Raspberry Pi 4. Raspberry Pi 4 Model B (4x Cortex-A72 @ 1.5 GHz, no dotprod), gcc 14.2 4 threads
1 thread
|
@ServeurpersoCom comment fixed, thanks! |
|
@max-krasnyansky please review |
|
If you build this, #32142, without dotprod the repack might be making prompt processing slower for cpu inference because repacked weights can't use Accelerate BLAS. The BLAS backend can only accept host buffers and repacked weights are not host buffers. Tested on my macmini m4 with Cmake command: Model tested: Q4_0:
build: 2d677c3 (20) Q8_0:
build: 2d677c3 (20) |
The CPU buffer order is ACCEL, GPU host, CPU extra (repack), CPU, and BLAS uses the plain CPU buffer type, so it is skipped. |
max-krasnyansky
left a comment
There was a problem hiding this comment.
I didn't get a chance to try it on my setups but the repack/ukernel changes look good to me.
|
@rjtokenring take a look at the CI failures. EditorConfig, etc. |
2d677c3 to
28f6159
Compare
|
Thanks @max-krasnyansky! Failures (EditorConfig) were in master and has been fixed after my rebase. |
|
@chaxu01 please review/ack when you get the chance |
|
I have one comment: The new default repack selection for Q4/Q8 appears to prevent Accelerate/BLAS from handling these weights, since BLAS cannot consume the repacked buffers. This seems consistent with the reported Q8 pp128 regression. While existing dotprod builds may have the same limitation, this introduces a regression for previously unaffected ARM builds. --no-repack provides a workaround, but the default behavior is still concerning. |
@chaxu01 thanks for the review. For a53 CPU, BLAS is slower wrt new repack approack. Arduino UNO Q (4x Cortex-A53 @ 2.0 GHz, no dotprod), PR head 28f6159, gcc 14.2
|
|
@chaxu01 do you have any comment? Thanks! |
|
The changes look good to me, and I don't have any further code review concerns. I noticed there are still failing CI checks. They don't appear to be related to this patch. Could you please take a look and clarify the failures before merging. |
9838345 to
47b41ce
Compare
Thanks! I rebased now with master, but I see those jobs failing on master as well. |
47b41ce to
e361196
Compare
…owner 2026-11-25) Base b12723 (merge a940ab9), pin ggml-org#401 removed (80211b4), RoPE multi-section fusion from upstream ggml-org#32500 (owner's decision), MIX.md (3563400). Build gate: test-backend-ops ROCm 21878/21878, bench r17 (llama-mix-notes, mesures/2026.md): Inkling tg +4.5 % [bon], Qwen3.6 and Gemma 4 without regression. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QBjnvFCJ83vkmygsLNv5cu * mix/wip-b12723: (55 commits) mix: MIX.md — base b12723 (branche wip), retrait du pin ggml-org#401, conflit RoPE tranché (amont ggml-org#32500) revert: pin: CUDA: fuse the row L2 clip chain (unslothai#401, commit 6c0e84d) model : inkling2 graph with fewer ops in mix() and control() (ggml-org#32948) opencl: add clc coopmat moe kernel for q4_0/q4_1/q4_k/q5_0/q5_1/q5_k/q6_k/mxfp4 (ggml-org#32971) tests : fix MSVC static build of test-batch-alloc and test-server-component (ggml-org#32870) feat: Inkling 2 DSpark support (ggml-org#32218) cuda : fix int overflow of the MMVF matrix offsets (ggml-org#32965) docs : describe SpacemiT runtime environment variables (ggml-org#32452) ggml : fix SpacemiT flash attention null mask, ALiBi and softcap (ggml-org#32182) cmake : include the llguidance header from the source tree (ggml-org#32928) ci : move some jobs to gb10 runners (ggml-org#32968) ui: run Llama Chat apart from llama-server, named in config.json or npx --server (ggml-org#32945) ui: fix prebuilt UI download in shallow clones (ggml-org#32952) convert : fix qwen3-omni conversion (ggml-org#32941) ggml-cpu: repack kernels for targets without dotprod (ARMv8.0 64-bit) for Q4_0/Q8_0 (ggml-org#32142) ui: expect the Llama Chat name in the PWA manifest e2e test (ggml-org#32959) ggml-cpu: add SVE-optimized q5_0 and q5_1 dot-product kernels (ggml-org#30867) server : include MCP image and audio data in tool results (ggml-org#32064) context : prevent excessive CPU polling without OpenMP (ggml-org#32378) metal : reserve the top-k scratch only for short rows (ggml-org#32942) ...
… for Q4_0/Q8_0 (ggml-org#32142) * ggml-cpu: optimized kernels for ARM v8.0 (without dotprod) * ggml-cpu: fix comment and align to implementation * ggml-cpu: exclude new kernels for apple arch
Overview
ggml-cpu: repack kernels for targets without dotprod (ARMv8.0 64bit) for Q4_0/Q8_0
Tested on Arduino UNOQ with Qwen3.5 0.8B Q4_0 pure and Q8_0
Measured a max throughput increase by x2.6 on prefill, x1.6 in token generation.
llama-bench, tokens/s
llama-server, chat request with a 584-token prompt, tokens/s