hip: ROCm/HIP-only perf (TOP_K wave32 hybrid, k-quant VDR) - #153
Conversation
ROCm/HIP-only performance work with zero CUDA/Vulkan impact. Every hunk is `#if defined(GGML_USE_HIP)`- / `#if defined(RDNA*)`-gated, CPU-only, or test-only; CUDA paths are byte-identical by construction. - top-k.cu: replace the v0.4.7 no-CUB HIP radix fallback with the wave32-native hybrid (n-ary search + small-kernel + parallel radix + bitonic), gated `!CUB && HIP` so CUB is still preferred when available. (Task 3; supersedes the simpler v0.4.7 radix.) - mmvq.cu / vecdotq.cuh: RDNA Q4_K/Q5_K VDR=4, Q6_K VDR=2, Q8_0 VDR=4 (RDNA-gated macros/dispatch; new VDR kernels defined but dead on CUDA). (Task 5) - ggml-cuda.cu: HIP APU `integrated=false` host-buffer back-out (HIP-gated; CUDA branch unchanged). (Task 6/06) - sgemm.cpp: CPU llamafile decode/verify parity (`n<=8` through vec_dot). (Task 6/05) - tests: Qwen3.6-27B Q6_K/Q4_K/Q5_K + FA-head tuning shapes (test-only). The Task 2 FA head-cap/tile cluster (fattn.cu selection + fattn-mma-f16.cuh kernel cap + tile configs) is coupled and lives in PR-B, not here, to keep this PR self-consistent and provably CUDA-safe. CUDA negative control (thermis/4090) to be recorded in the handoff; gfx1100 task records: TOP_K 517/517 backend-ops + same-seed byte-identical, VDR MUL_MAT green + KLD identical + tg64 +4-6%.
|
Requesting changes on the CPU dispatch hunk; the rest are non-blocking. Blocking: Non-blocking:
What I checked: the new Q4_K/Q5_K VDR=4 and Q6_K VDR=2 entry points match the canonical VDR=2/VDR=1 element partition, the q8_1 block pairing and scale/ |
ROCm/HIP-only performance work. Every hunk in this PR is
#if defined(GGML_USE_HIP)- / RDNA-arch-gated, CPU-only, or test-only, so CUDA/Vulkan/CPU behavior is byte-identical. Verified with a CUDA negative control: clean-v0.4.7baseline vs baseline+this-PR —test-backend-opsMUL_MAT and TOP_K all-pass in both states (identical outcomes).What's inside (all HIP/RDNA-gated)
1. TOP_K wave32-native + hybrid kernels (
ggml-cuda/top-k.cu)Idea from nasone32's RDNA3-7900xtx-opt ("Applied series"). Replaces the no-CUB HIP radix fallback with wave32-native tiled + hybrid kernels, keeping the CUB preference where CUB exists. Op-level: TOP_K
ne=[200000,1,1,1] k=40runs on GPU in ~86.7 us vs ~161.2 us on the CPU fallback path. Validation:test-backend-opsTOP_K 517/517 pass, same-seed decode byte-identical.2. RDNA k-quant VDR decode boosts (
ggml-cuda/mmvq.cu,ggml-cuda/vecdotq.cuh)Idea from stew675's llama-cpp-rdna-boosts block 10 (RDNA-gated VDR bumps for Q4_K/Q5_K/Q6_K/Q8_0). Decode
tg64+4–6% on gfx1100. Validation:test-backend-opsMUL_MAT 1568/1568 pass, KLD bit-identical vs baseline, same-seed decode byte-identical. (The new*_vdr4/*_vdr2entry points compile on all backends but are dead code outside the RDNA dispatch gate — confirmed by the CUDA-build negative control.)3. Small HIP-gated + neutral hunks
ggml-cuda.cu:integrated=falsedevice flag underGGML_USE_HIP(the CUDA#elsearm already wasfalse— no behavior change).ggml-cpu/llamafile/sgemm.cpp: llamafile gaten<2→n<=8(CPU file, no GPU impact).tests/test-backend-ops.cpp: extra Q6_K/Q4_K/Q5_K + FA-head tuning shapes (test-only).Validation (gfx1100 RX 7900 XTX + RTX 4090 CUDA gate)
test-backend-opsresults (MUL_MAT 0 fails, TOP_K 0 fails in both) — PR-A provably does not change CUDA behavior.Kudos
Base:
v0.4.7. Sibling PR (shared-code perf) follows separately as PR B.