vulkan: add dedicated iq4_xs mat-vec shader - #28426
Conversation
|
Hi @WakeUpMorty, 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. |
|
Rewrote the description. Could the check be re-run? |
|
Hi. Author of the mentioned PR #28417. Can confirm that this PR ever so slightly outperforms the variant I had in that PR. Benchmark with 4096 tokens on my machineThis version:
#28417 version:
Also ran the build & tests with this branch and can confirm it works:Total Test time (real) = 776.30 sec Closing my PR in favor of this one. Funny that we worked on this in parallel. |
|
There's also #28415 |
I tested the changes from that PR to compare it to this variant: Benchmark on unsloth/Qwen3.8-27B-UD-Q3_K_XLIQ4_XS takes up ~40% of total compute on that model on my RX 9070 XT (radv): ./build/bin/llama-bench -m Qwen3.8-27B-UD-Q3_K_XL.gguf -ngl 99 -fa on -n 3 -r 4096 -p 0
This version:
master:
So both improve on master but this PR performs better in my tests |
|
@pwomser Yeah, funny how life works. This was quick ~+6-17% improvement. Thanks for closing your PR in favor of this one and for tests you did.
Yes I did see it, but from what I understand it uses int-dot q8_1 path, which could be faster on hardware that supports it. My PR stays the f16 path, so I would say other hardware will still get performance boost. |
|
Please rebase to fix the conflict. |
Dedicated mul_mat_vec_iq4_xs for the dmmv path, replacing the generic fallback. ~+6-17% token generation on RDNA4 depending on model. Assisted-by: Pi agent with Qwen3.8 27B
efe3c48 to
d9f41c2
Compare
|
@0cc4m its done |
Remove the n_it <= 8 experimental branch that attempted to fully unroll the block loop. Since n_it is a runtime value, [[unroll]] is ignored by the compiler, making both branches equivalent. Kept the simple loop matching mul_mat_vec_iq3_s.comp.
* vulkan: add dedicated iq4_xs mat-vec shader Dedicated mul_mat_vec_iq4_xs for the dmmv path, replacing the generic fallback. ~+6-17% token generation on RDNA4 depending on model. Assisted-by: Pi agent with Qwen3.8 27B * vulkan iq4_xs: remove dead n_it unroll branch Remove the n_it <= 8 experimental branch that attempted to fully unroll the block loop. Since n_it is a runtime value, [[unroll]] is ignored by the compiler, making both branches equivalent. Kept the simple loop matching mul_mat_vec_iq3_s.comp.
Dedicated mul_mat_vec_iq4_xs for the dmmv path, replacing the generic fallback. ~+6-17% token generation on RDNA4 depending on model.
Overview
Add a dedicated
mul_mat_vec_iq4_xsVulkan compute shader foriq4_xsmatrix-vectormultiplication, replacing the generic unpacking path in
mul_mat_vec.comp.This provides +6-17% token generation speedup on AMD RDNA4 (RX 9070 XT), with larger gains the more iq4_xs a model contains. For small K the loop is unrolled, so small models get the same gain.
Additional information
Benchmark results (AMD RX 9070 XT). Reference = official prebuilt 95ef7fc without
this change; Patched = 427291b + this change.
Flags used:
llama-bench -m <model> -p <depth> -n <256|512> -r 3Qwen3.8-27B Q3_K_XL (~41% iq4_xs):
Qwen3.8-27B IQ4_XS (100% iq4_xs):
Same-session A/B against the official prebuilt (tg256/tg512, fresh context):
Q3_K_XL 34.31→36.38 / 33.84→36.65, IQ4_XS 32.38→35.45 / 32.37→35.38.
Gemma 4 12B IQ4_XS:
Correctness: bit-identical output between reference and patched builds at temperature 0
(64 tokens, same prompt, all three models), and perplexity on
docs/build.mdunchanged:Q3_K_XL 3.6406, IQ4_XS 3.5981, Gemma 77.1819.
#28417 was uploaded a few hours before mine, but this PR does a bit better (+0.5% to +1.2%). #28417 work per-K-chunk and this PR tiles per-32-superblock
Test PR #28415 vs #28426
#28415 (comment)
Requirements