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/ |
|
All items addressed in 5344385 (on top of abe3026, no force-push). Builds + validation below are new runs on the final tree: HIP = RX 7900 XTX gfx1100 (TheRock, clean Blocking (sgemm): reverted to upstream
Validation table:
The only build failure is the known pre-existing |
ROCm/HIP-only performance work. Every hunk in this PR is
#if defined(GGML_USE_HIP)- / RDNA-arch-gated, CPU-only, or test-only. The sgemm hunk is back to upstream after review, 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: 1818/1818 each).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 525/525 pass (ROCm0, gfx1100), same-seed decode byte-identical. Review fix: per-iteration seeding of the radix selection state, which stayed uninitialized (first pass) / stale (later passes) for all-+inf/NaN rows.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 1293/1293 pass (372 unsupported-type skips of 1665 selected cases), KLD identical vs the v0.4.7 base (see table), 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). Review fix: the "at no cost" comment now records the placement trade-off, with a matching note indocs/beellama-features.md(APU tensors move off host-mapped memory, VRAM headroom changes, unmeasured -- no APU hardware here).ggml-cpu/llamafile/sgemm.cpp: REVERTED to upstreamif (n < 2)per review -- the CPU neutrality claim above is exact again.tests/test-backend-ops.cpp: extra Q6_K/Q4_K/Q5_K + FA-head tuning shapes (test-only); removed one duplicated dead Q8_0 line.Validation (gfx1100 RX 7900 XTX + RTX 4090 CUDA gate)
test-backend-ops: TOP_K 525/525, MUL_MAT 1293/1293 (ROCm0).test-backend-opsresults (1818/1818 in both, byte-identical outcomes) plusctest -R "kvarn|fattn-route"15/15 -- this PR provably does not change CUDA behavior.-c 512 -ub 512, ngl99), stock v0.4.7 / this PR / PR hip: shared perf (MMQ MoE tiles + mmvdq, prefill plumbing) #154 -- bit-identical across all three trees:test-kvarnladder aborts at the head-wide store-route require -- pre-existing on the v0.4.7 base (fixed in Make KVarN usable on ROCm RDNA3 (toward #122: D256 race, portable prefill, f32 WMMA prototype) #149 round 2; Make KVarN usable on ROCm RDNA3 (toward #122: D256 race, portable prefill, f32 WMMA prototype) #149-final passes).Kudos
Base:
v0.4.7. Sibling PR (shared-code perf) follows separately as PR B.