hip: shared perf (MMQ MoE tiles + mmvdq, prefill plumbing) - #154
hip: shared perf (MMQ MoE tiles + mmvdq, prefill plumbing)#154raufaser wants to merge 2 commits into
Conversation
|
Requesting changes on the prefill graph skip; the other items are minor. Blocking: Minor:
What I checked: the nine |
…ing, J_MAX validation, split-state init)
|
All items addressed in 31a7396 (on top of 93247bc, no force-push). Builds + validation below are new runs on the final tree: HIP = RX 7900 XTX gfx1100 (TheRock, clean Blocking (graph skip): wrapped in
Validation table:
The only build failure is the known pre-existing |
Shared-code performance work (compiles for all backends; may affect CUDA/Vulkan behavior -- maintainer decides). This is the sibling of PR #153 (HIP-only, provably no CUDA impact). KVarN-specific changes are NOT here -- they live in PR #149.
What's inside
1. MMQ tile sizing + dequant-float matvec
mmvdq(ggml-cuda/mmq.cuh, all 9mmq-config-*.cuh, newmmvdq.cu/.cuh,ggml-cuda.cudispatch)Ideas from nasone32's RDNA3-7900xtx-opt (MMQ tile sized to MoE tokens-per-expert, dequant-float matvec for Q4_K/Q5_K/Q6_K) plus the upstream llama.cpp #24546 MMQ cherry-pick. The new
mmvdqkernel is default-OFF except RDNA3_5 but env-activatable on any backend. Behaviorally CUDA/CDNA-neutral by analysis (new branches require RDNA3 arch checks or the opt-in env), but this is shared code, so review + CI decide. Review fix:GGML_CUDA_DQ_MMV/GGML_CUDA_DQ_Q6Know parse strict 0/1 (anything else warns once and keeps the arch default); all three knobs (DQ_MMV,DQ_Q6K,DQ_ROWS) are documented indocs/beellama-args.md.2. Prefill plumbing (
ggml-backend-meta.cpp,src/llama.cpp,ggml-cuda.cu,ggml-cpu/llamafile/sgemm.cpp)Ideas from stew675's llama-cpp-rdna-boosts blocks 05/06/07/09/11: Meta headroom 32->128, single-device Meta-wrapper skip, mmvdq decode/GLU dispatch, prefill graph-skip + graph-opt default. Measured on the final tree (27B Q5_K_S, kvarn6, gfx1100):
pp512~466 t/s,pp4096~173 t/s -- neutral vs stock v0.4.7 (same numbers; the earlier 823 figure was a stale dev-tree reading, corrected). (Task 6 block 08 fused-core prefill kernels deliberately deferred -- needs rework against this fork's fusion dispatch.) Review fix: the prefill graph skip is now#if defined(GGML_USE_HIP)-gated (compiles out on CUDA -- zero NVIDIA behavior change by construction) with the keying theory trimmed; final-tree A/B shows it perf-neutral (gate on 466.5 vs off 465.4-467.5 -- the earlier +6.7% dev-tree reading did not reproduce and is scheduled for investigation).3. MMQ vec-dot register hoists (
ggml-cuda/mmq-vec-dot.cuh)Q8_1/Q6_K scale hoists in the shared MMQ path. The Q6_K fold re-associates one scale multiply -- empirically bit-identical KLD on the test corpus, but numerics-touching shared code, hence PR B and not PR A. Review fix:
GGML_CUDA_MMQ_J_MAXis now validated (multiples of 8 in 8..512, warn + ignore otherwise) and cached instead of re-read per call.4. Single-device split state (
src/llama.cpp)Review fix: both single-device branches now publish
n_devices = 1+ model pointer, so the split-state callback is never reached with uninitialized data. Parity: 4B PPL identical with explicit single-device tensor-split vs default (HIP 13.4884 both legs, CUDA 13.3835 both legs).Deliberately NOT in this PR
Validation (gfx1100 RX 7900 XTX + RTX 4090 CUDA gate)
test-backend-ops: TOP_K + MUL_MAT 1818/1818 (ROCm0), including withGGML_CUDA_DQ_MMV=1/GGML_CUDA_DQ_Q6K=1forced on (DQ kernels correct on gfx1100).test-backend-opsMUL_MAT + TOP_K 1818/1818 plusctest -R "kvarn|fattn-route|cuda-fattn"16/16. No byte-identical claim for CUDA (shared code by design).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).Kudos
Base:
v0.4.7.