Repository navigation
ggml-cpu: add SVE-optimized q5_0 and q5_1 dot-product kernels - #30867
Conversation
|
Hi @t-kusanagi, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
Some comments:
|
|
Thank you for the review and the detailed feedback. It seems I caused confusion by combining two separate commands into one in the PR description. The commands I actually ran were: I apologize for the confusion and for not making this clear in the PR description. Therefore, the performance results I initially posted were obtained by running the Q5_0 and Q5_1 benchmarks separately. I changed the code to pass the result of ggml_cpu_get_sve_cnt() from the caller. This also eliminated the spills. I verified this with Clang 22.1.8. I rebuilt the code with LTO disabled using the following configuration, then extracted only the relevant functions from the generated assembly to confirm that the spills were eliminated without relying on link-time optimization. before after I removed the assertions triggered by unsupported SVE vector lengths in the Q5_0 and Q5_1 paths. For unsupported lengths, SVE processing is skipped, and all blocks are computed using the existing scalar loop. |
|
@t-kusanagi There are CI failures. Can you fix them and maybe rebase against upstream/master again? |
5e99d73 to
77c0006
Compare
…q5_1_q8_1 SVE suooprt for ggml_vec_dot_q5_0_q8_0, ggml_vec_dot_q5_1_q8_1
- Load high-bit masks directly from quantized blocks - Replace lookup-table expansion with predicated SVE duplication - Reduce scalar high-bit unpacking overhead
- Add a helper to load mask data as svbool_t with ldr - Replace direct svbool_t pointer casts in the q5 dot-product path
- Fix qh bit inversion in the SVE q5_0/q8_0 dot-product path - Use the proper predicate-aware svnot_b_z mask logic for bit extraction - Restore correct quantized compute behavior on ARM SVE targets
- replace manual qh extraction with vector bitmask loads in the ARM SVE path - remove temporary unpack buffers used during q5_1 dot-product assembly - preserve the qh bit pattern while keeping the quantized dot-product logic intact
- Add the existing GNU/Clang inline assembly path for SVE bool loading - Provide a portable fallback for other compilers using SVE intrinsics - Preserve current behavior on supported toolchains while improving compatibility
- fix SVE byte load by casting the uint32_t pointer to uint8_t* - preserve correct mask generation in load_as_svbool on Arm SVE - prevent undefined pointer aliasing in the SIMD vector path
- Limit q5 dot-product paths to 256-bit and 512-bit SVE vectors - Assert when encountering unsupported vector lengths - Localize the SVE predicate loader to the ARM quantization kernels
- Add an intrinsic predicate loader for SVE VL128 qh halves - Replace table-based qh expansion in q5_0 and q5_1 paths - Remove temporary qh expansion buffers - Preserve direct predicate loads for wider SVE vector lengths
- Unify predicate loading for q5 quantization paths - Prevent out-of-bounds reads from 8-bit high-bit storage - Remove unsupported VL512 q5 dot-product cases
- Bound qh predicate loads for SVE vectors at or above 512 bits - Use the shared SVE vector-length helper - Extend q5_0 and q5_1 dot products to VL512
- Document that values beyond the first 32 bits of qh are undefined - Warn that the loader may cause a SEGV for vector lengths above 1024
- Pass the cached vector length to SVE predicate loading - Remove repeated SVE vector length queries - Allow unsupported vector lengths to exit without assertions
- Remove obsolete VL > 1024 SEGV warning from load_as_svbool
77c0006 to
3918cc8
Compare
|
Thank you for your review. I've fixed the compilation errors and pushed the updated commits. I've confirmed that the compilation errors observed in the previous CI runs no longer occur. However, some CI jobs failed for reasons that appear to be unrelated to the changes in this PR. I've rebased onto the latest master and pushed the updated commits several times, but encountered different CI failures each time. Therefore, it may be necessary to rerun only the failed jobs rather than rebase and push again. It appears that the CI workflows require approval from someone with write access to the repository. Since I don't have write access, could you please approve and trigger the CI workflows for the latest commit? If any unrelated CI failures occur again, I may ask for your help in rerunning the failed jobs. Thank you for your help and patience! |
|
CI failures unrelated to PR. Merging. |
…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) ...
…rg#30867) * Merged PR 5925: SVE suooprt for ggml_vec_dot_q5_0_q8_0, ggml_vec_dot_q5_1_q8_1 SVE suooprt for ggml_vec_dot_q5_0_q8_0, ggml_vec_dot_q5_1_q8_1 * perf(arm): optimize q5_0 q8_0 dot products with SVE - Load high-bit masks directly from quantized blocks - Replace lookup-table expansion with predicated SVE duplication - Reduce scalar high-bit unpacking overhead * fix(arm): load SVE masks through inline assembly - Add a helper to load mask data as svbool_t with ldr - Replace direct svbool_t pointer casts in the q5 dot-product path * fix(arm): correct q5/q8 SVE bitmask handling - Fix qh bit inversion in the SVE q5_0/q8_0 dot-product path - Use the proper predicate-aware svnot_b_z mask logic for bit extraction - Restore correct quantized compute behavior on ARM SVE targets * fix(arm): simplify q5_1/q8_1 bitpack handling - replace manual qh extraction with vector bitmask loads in the ARM SVE path - remove temporary unpack buffers used during q5_1 dot-product assembly - preserve the qh bit pattern while keeping the quantized dot-product logic intact * fix(ggml-cpu): support SVE load on non-GNU compilers - Add the existing GNU/Clang inline assembly path for SVE bool loading - Provide a portable fallback for other compilers using SVE intrinsics - Preserve current behavior on supported toolchains while improving compatibility * fix(cpu): cast SVE input pointer before byte load - fix SVE byte load by casting the uint32_t pointer to uint8_t* - preserve correct mask generation in load_as_svbool on Arm SVE - prevent undefined pointer aliasing in the SIMD vector path * fix(arm): restrict q5 SVE kernels to supported vector lengths - Limit q5 dot-product paths to 256-bit and 512-bit SVE vectors - Assert when encountering unsupported vector lengths - Localize the SVE predicate loader to the ARM quantization kernels * perf(arm): optimize SVE q5 dot products for VL128 - Add an intrinsic predicate loader for SVE VL128 qh halves - Replace table-based qh expansion in q5_0 and q5_1 paths - Remove temporary qh expansion buffers - Preserve direct predicate loads for wider SVE vector lengths * fix(arm): correct SVE q5 predicate loading - Unify predicate loading for q5 quantization paths - Prevent out-of-bounds reads from 8-bit high-bit storage - Remove unsupported VL512 q5 dot-product cases * fix(arm): support SVE VL512 q5 dot products - Bound qh predicate loads for SVE vectors at or above 512 bits - Use the shared SVE vector-length helper - Extend q5_0 and q5_1 dot products to VL512 * docs(arm): clarify SVE predicate loader limit - Document that values beyond the first 32 bits of qh are undefined - Warn that the loader may cause a SEGV for vector lengths above 1024 * perf(arm): reuse SVE vector length in quantized dot products - Pass the cached vector length to SVE predicate loading - Remove repeated SVE vector length queries - Allow unsupported vector lengths to exit without assertions * docs(arm): remove outdated SVE loader warning - Remove obsolete VL > 1024 SEGV warning from load_as_svbool * fix compilation errors --------- Co-authored-by: Kato, Masaya 加藤 雅也 <[email protected]> Co-authored-by: Masaru Ito <[email protected]>
Overview
q5_0 x q8_0andq5_1 x q8_1dot-product kernels.qh), as the required unpacking differs depending on the SVE vector length.Additional information
Environment
cmake -B build -S . \ -DGGML_CUDA=OFF \ -DGGML_CPU_KLEIDIAI=ON \ -DBUILD_SHARED_LIBS=OFF \ -DGGML_NATIVE=ON \ -DGGML_LTO=ON \ -DLLAMA_BUILD_UI=OFF \ -DLLAMA_USE_PREBUILT_UI=OFF \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ONPerformance Results
Results from the optimized
q5svebuild and gcc baselineCommands used to collect the performance results:
Perplexity
Non-regression check
Result: No significant regression
Command:
Requirements