Repository navigation
[w2] mmvq: opt-in Q6_K single-warp 4-row variant on RDNA3 (GGML_CUDA_MMVQ_Q6K_LANES) - #164
Merged
Merged
Conversation
…Q6K_LANES) For Q6_K, one column, RDNA3_0: rows of 9..11 superblocks (K=2304/2560/2816) run one warp per row with four rows per block instead of four warps on one row (the third trip of the 4 warp block is part idle), and rows of 1..2 superblocks (K<=512, e.g. Qwen4 hc_up 8192x256) get four rows per block instead of one. Needs nrows % 4 == 0, otherwise the old path is used. Fused gate/up and the shared expert go through the same kernel. Opt-in because the row reduction order changes. Adds MUL_MAT / MUL_MAT_FUSION cases for these shapes (eval and perf). Assisted-by: Claude Sonnet 5.5
rafasmour
force-pushed
the
opt/w2-q6k-lane-waste
branch
from
December 4, 2026 13:28
1e560ff to
0ffe5c0
Compare
Owner
Author
|
Reverted from master on 2026-12-04 (w2 build crashed Qwen4-single at >20k ctx; no measured gain). Commit preserved on branch archive/w2-25f0def; will be re-landed individually after GPU validation. |
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.
What / why
RDNA3 (gfx1100) Q6_K mat-vec with one column uses 4 warps per row. For rows of 9-11 superblocks (K=2304/2560/2816: Nemotron Bolt E4B FFN and head) the 4-warp block takes three trips and the last is part idle. For rows of 1-2 superblocks (K<=512, Qwen4 hc_up 8192x256, 80 calls/token) the default is already 1 warp, 1 row (small_k), with a block per row.
New template flag
q6k_lanesonmul_mat_vec_q: Q6_K, ncols_dst==1, RDNA3_0 only: 1 warp per row, 4 rows per block (every lane busy; a Q6_K superblock is exactly one warp, qi=32). Selected at runtime whenGGML_CUDA_MMVQ_Q6K_LANES=1, nrows % 4 == 0 and blocks_per_row is 1-2 or 9-11. Every other Q6_K shape (K=17408, 10240, 5120, 2048, ...) is unchanged. Fused gate/up GLU and the shared-expert path use the same kernel (rows_per_block 4 already satisfies the one-lane-per-output static_assert; the mixed-type shared expert instance is untouched).Plan correction: the task said to check whether small_k already covers K<=512. It does (1 warp, 1 row per block), so for K<=512 the variant only changes rows per block 1 -> 4.
Expected gain (estimate, unmeasured)
Nemotron +1-3% tg (Q6_K K=2560 kernels at about 666 vs 700+ GB/s). Qwen4 hc_up: launch-dominated, maybe 0.1-0.2 ms/token over 80 calls.
Env switch
GGML_CUDA_MMVQ_Q6K_LANES=1(opt-in, default off; the row reduction order changes).Files
ggml/src/ggml-cuda/mmvq.cu, tests/test-backend-ops.cpp (MUL_MAT q6_K n=1 for (10240,2560), (2560,2560), (16384,2304), (8192,256), (2048,512), (4096,2816), (4099,2560 - fallback), (10240,3072 / 2560,5120 - unchanged); MUL_MAT_FUSION Q6_K gate/up at k=2560/2304/256 and a MoE case).
Risks
Checks done (no GPU used)
HIP compile of mmvq.cu.o for gfx1100 clean; CPU test-backend-ops compile. No GPU, no production, nothing touched in ggml-org/llama.cpp.
GPU validation tonight (NOT YET RUN)
Also run MUL_MAT_FUSION for q6_K at k=2560.
Assisted-by: Claude Sonnet 5.5