vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec … - #27449
Merged
ggerganov merged 2 commits intoSep 2, 2026
Merged
Conversation
added 2 commits
August 20, 2026 17:23
…when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5
0cc4m
approved these changes
Sep 1, 2026
Contributor
|
LGTM, thank you for the contribution (and sorry about the review delay) |
Lawlietr
pushed a commit
to Lawlietr/llama.cpp
that referenced
this pull request
Sep 3, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
1 task
thecodacus
pushed a commit
to thecodacus/llama.cpp
that referenced
this pull request
Sep 7, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
x1250
pushed a commit
to x1250/llama.cpp
that referenced
this pull request
Sep 9, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
zbrad
pushed a commit
to zbrad/llama.cpp
that referenced
this pull request
Sep 10, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
pl752
pushed a commit
to pl752/llama.cpp
that referenced
this pull request
Sep 15, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
zsogitbe
pushed a commit
to zsogitbe/llama.cpp
that referenced
this pull request
Sep 17, 2026
…gml-org#27449) * vulkan: handle larger batch sizes (>4) efficiently for IQ3_S mat-vec when NUM_COLS > 4. 5x perf at n=8 Assisted-by: Claude Opus 5 * adds 2 cases per quant type at `k=16*256` to the `all_types` mat-vec sweep --------- Co-authored-by: Marshall <assistant@llama.cpp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Vulkan fix: At larger batch sizes, as happens when using speculation (dflash2 in this case) the IQ3_S mat_mul becomes highly inefficient by overflowing the VGPR budget.
The shader spills 442 registers into 17 KB of scratch per wave, making it ~9x slower
than at
NUM_COLS = 4while doing only 2x the work. iq3_s is the only quant type that does thisAdditional information
8 floats per l step x 4 l steps x NUM_COLS
At
NUM_COLS = 8that is 256 floats. A VGPR holds one 32-bit value per lane and RDNA gives awave at most 256 VGPRs, so B alone wants the whole register file, before
temp[8][4](32 more),the grid values and the addresses.
The compiler batches those loads into VMEM clauses to hide memory latency, which is normally
correct. Here it means all 64 vec4 loads want to be live at once.
RADV_DEBUG=shaderstats,nocache, m=4096 k=14336:After the fix,
NUM_COLS = 8reports 252 VGPRs, 0 spilled, 0 scratch, 6 subgroups per SIMD.Only iq3_s is affected. Same shape, n=4 -> n=8, microseconds/run:
Every other type scales smoothly (~1.6-1.8x from n=4 to n=8). iq3_s goes 9.2x.
Measured on Radeon 8060S Graphics (RADV STRIX_HALO)
Verified perplexity and updated tests to catch this
Model level
Qwen3.8-27B, unsloth UD-Q4_K_M, which carries 4 IQ3_S tensors
(
blk.11.ffn_gate,blk.14/15/17.ffn_down) out of 866:UD-Q4_K_XL has 1 IQ3_S tensor: pp8 goes 69.3 -> 70.3 t/s. UD-Q5_K_M and UD-Q6_K_XL contain no
IQ3_S and are unaffected.
The end-to-end speculative numbers carry run-to-run variance because acceptance rate varied
(65.9% - 80.6% for the same request at temperature 0). pp8 is the controlled measurement: it is
the 8-token verify graph in isolation and it is deterministic.
Perplexity
unsloth/Qwen3.8-27B-GGUF:UD-IQ3_S, which carries 127 IQ3_S tensors out of 866. wikitext-2 raw,-c 512 --chunks 30 -ngl 99 --seed 1234: