vulkan: use density gate for MUL_MAT_VEC_ID path - #27332
Open
theycallmeloki wants to merge 1 commit into
Open
Conversation
Contributor
|
I ran this on my 5090 using the command line from the issue, and while it is marginally better for B==9, it is slower for larger values. So this would need more tuning: |
Replace the fixed 8-token cutoff with the ggml-org#25356 density gate (n_tokens * experts_per_token <= 2 * n_experts, cap 64 tokens) on AMD RADV devices. Removes the decode cliff at 9+ concurrent sequences; validated on gfx1013, gfx1151 and RDNA3. Other vendors keep the fixed cutoff (tiled wins at lower batch on NVIDIA, see review on the 5090). Assisted-by: DeepSeek V4 Flash
theycallmeloki
force-pushed
the
vulkan-moe-density-gate
branch
from
August 18, 2026 19:30
84b3b8f to
aba6a48
Compare
Author
Contributor
|
I doubt it's related to architectural differences. I think the coopmat2 path does better with small batches than coopmat1 due to the |
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.

Replace the fixed 8-token cutoff with the #25356 density gate (
n_tokens * experts_per_token <= 2 * n_experts, capped at 64 tokens). Avoids the batch-9 decode regression on AMD RADV; validated on gfx1151, RDNA3 and gfx1013 (BC-250): +36% at B=9, +27% at B=16, +21% at B=64, neutral at B<=8.Assisted-by: DeepSeek V4 Flash
Overview
Replace the hardcoded
batch <= 8threshold for the VulkanGGML_OP_MUL_MAT_IDMMV path with the routed-density heuristic proposed in #25356.For MoE decode, the MMV kernel performs better for small routed workloads, while the tiled kernel wins at larger workloads. The fixed cutoff causes a sharp kernel-selection regression when going from 8 to 9 concurrent sequences on AMD RADV.
The new gate keeps MMV selected while:
and
n_tokens <= 64.The existing F32/F16/quantized type check is unchanged, and large-batch prefill remains on the tiled path.
Additional information
On a BC-250 (
gfx1013), the new gate produced:The same density heuristic has previously been validated on Strix Halo (
gfx1151) and RDNA3 in the discussion of #25356.Forcing the tiled path everywhere was also tested on
gfx1013and performed substantially worse (-44% at tg64, about -50% at B=1), supporting kernel selection rather than removal of the MMV path.The change is limited to
ggml_vk_use_mul_mat_vec_id(): 9 insertions, 1 deletion, with no new configuration or environment knobs.Correctness:
test-backend-ops -b Vulkan0 -o MUL_MAT_IDpasses872/872on the patched build (gfx1013, RADV).
Related work
Repro
Reproduction (llama-batched-bench, Qwen3.5-35B-A3B, 4-node RPC):
stock: B=8 52.6, B=9 35.9 t/s (cliff)
patched: B=8 51.5, B=9 48.2 t/s (+36%)
Requirements