MMQ nwarps is under-tuned for gfx906
#23881
Replies: 4 comments
|
I got +76% pp512 on a mi50 32gb with Qwen 3.5 9B q8_0, getting around 860 t/sec. So I don't think it's only the mi60 that sees gains |
gfx906: the nwarps change helps Q8_0 (+19%) but regresses Q4_K (-7%) — same GPU, same buildI tested this on 5x Radeon VII (gfx906, Vega20), ROCm 6.2.4, llama.cpp b10451. Short version: What I changedOn b10451 the MMQ config is dispatched per architecture, and gfx906 is neither CDNA nor RDNA, so RDNA2 is wave32 and every one of its 242 CASE entries uses So I added a GCN config that is the RDNA2 table with only Note Results — one GPU, one variable
Qwen2.5-VL-7B-Instruct
The pp128 rows have large standard deviations and I would not lean on them. pp512 and pp2048 are So on the same card, same binaries and same model, nwarps 8 is worth about +19% at Q8_0 and I mention the one-variable framing explicitly because my first attempt at this compared my Q4 Correctness
SuggestionA blanket gfx906 Caveats on my end: one GPU model, one 7B model, two quantizations, and I have not tested Q5/Q6 or |
|
My understanding is that the GFX906 Architecture is severely compute bound for LLMs, given the 1T/s memory bandwidth but measly 29 TFLOPS of fp16 compute. This bucks traditional wisdom that makes Q4 faster for most GPUs than Q8, where Q8's simplicity wins out in speed over Q4's compression. This could extend to the nwarps conversation, where at q4 we're already severely compute constrained and more nwarps doesn't help or even adds overhead, while Q8 has a bit of room to spare. |
|
Your explanation fits our measurements surprisingly well. One refinement: on gfx906 the llama.cpp quantized MMQ/MMVQ paths go through DP4A integer dot-product kernels ( Same 5x Radeon VII rig as my earlier comment (gfx906, ROCm 6.2.4, llama.cpp b10451), Qwen3.6-35B-A3B,
That is +6.8% for Q8_0, with 0.02% drift between the two Q4 control legs, despite the Q8 model occupying ~40.1 GB VRAM against ~26.2 GB for Q4_K_XL. It also lines up with the nwarps result I posted earlier: Q8_0 gained +19.1% pp512 while Q4_K_M lost 6.9% on the same card. Q4_K carries substantially more superblock unpack/scale/min handling than Q8_0, so a working hypothesis is that gfx906 is already sufficiently compute/dequant limited on Q4_K that its smaller memory footprint does not buy the usual speed advantage, while Q8_0 is simple enough that the extra bandwidth cost is outweighed by cheaper execution. Two caveats. I have not measured DP4A utilisation directly, so that remains a hypothesis rather than a demonstrated bottleneck. And our Q4-vs-Q8 prefill comparison on the 5-GPU configuration came out inconclusive — the effect was smaller than run-to-run drift — so the +6.8% above is a decode result only. |
Uh oh!
There was an error while loading. Please reload this page.
Background
While investigating the potential to port the kernels from the gfx906 fork back to mainline llama.cpp and observing that that fork's nwarps value of 2 (half that of mainline) reduced the prompt processing performance of both models I tested, I tried increasing it instead and saw major gains.
Testing (pp512)
Both models were ran at q8 on a single mi60, and validated on a second:
Correctness
test-backend-ops -o MUL_MATpasses at nwarps=16, though there was some non-deterministic flicker of pass-fail, specifically atq5_1, m=16, n=1, k=32measured at nwarps=8. This flicker was not observed at nwarps=16, but I can't prove that it will never happen.Suggestion
I think it may be worth re-evaluating the
256/warp_sizeheuristic for non-MFMA AMD cards.Caveats
This may be gfx906 specific behavior, and may even be specific to the mi60 (which has more cores than the mi50). I can't verify otherwise at this time. I also only tested this at q8, as I was specifically targeting q8 performance.
All reactions