Repository navigation
CUDA: batch-1 Q8_0 mat-vec against F32 activations, without the q8_1 quantize - #448
Open
danielhanchen wants to merge 7 commits into
Open
danielhanchen wants to merge 7 commits into
danielhanchen wants to merge 7 commits into
Conversation
…quantize One src1 column of Q8_0 weights on NVIDIA cc >= 10.0: the weights are dequantized in registers and dotted with the F32 activations, so src1 is not quantized to q8_1 first. Weight loads are issued before the PDL wait when src0 is a weight. Changes rounding against MMVQ (the activations are no longer rounded to 8 bits). Kill switch: GGML_CUDA_DISABLE_MMVQ_F32_ACT.
The reference rounds the activations to 8 bits while the CUDA F32 activation path does not, so with one or two output rows the NMSE of a single dot product goes over 5e-4 in a few percent to one in eight random draws. Use 7 rows or more, and add 1185 rows for the partial block of the two rows per block launch.
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
danielhanchen
changed the base branch from
master
to
base/upstream-d141011c2
November 25, 2026 02:42
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
added a commit
that referenced
this pull request
Nov 25, 2026
…, take #414 0cbe311, add #447 and #448, drop #427 and #428 (#451) Upstream b12696..b12719 changed the Inkling 2 code the pins touch (DSpark drafter, clip on ggml_l2_norm, depth mix weighted sum order, MMVF int64 offsets), so the old pins no longer merge. Each pin branch merged upstream 33aeb17 (b12720) and keeps upstream's code as is: - #378: e1b2a33 -> ba3ad42 - #405: b5ed9f2 -> b14ca2b - #386: a8ca6da -> 7280c5e - #431: f44881a -> 5373aec Also: - #414: 74a0ffc -> 0cbe311 (HIP build of the depth mix fusion) - add #447 0bc8e1c and #448 e148684, with their feature-checks.json entries - drop #427 and #428: the base carries both CUDA changes Every pin moves by fast-forward. Only for a base at or past b12720.
danielhanchen
changed the base branch from
base/upstream-d141011c2
to
base/upstream-b671865c7
November 28, 2026 05:07
danielhanchen
changed the base branch from
base/upstream-b671865c7
to
base/upstream-a38695013
November 28, 2026 07:04
danielhanchen
changed the base branch from
base/upstream-a38695013
to
base/upstream-94f17f659
December 2, 2026 15:08
danielhanchen
added a commit
that referenced
this pull request
Dec 2, 2026
#378, #385, #386 and #431 merge upstream aa631e0 (FA bias API cleanup, b12859); #378 also keeps the Inkling router soft_max off the new short-row kernels (CUDA b12878, Vulkan b12916). #448 merges b12922 (few-row MMQ for NVFP4 adds a dst argument to ggml_cuda_should_use_mmq_few). feature-checks: add inkling2-expert-scales (MUL_MAT_ID with weight scales).
This was referenced Dec 2, 2026
danielhanchen
added a commit
that referenced
this pull request
Dec 3, 2026
fix #396, pin #469 #470 (#473) * pr-set : pin #464, default a missing NVFP4 / FP8 weight scale to 1.0 * pr-set : repin #378 #385 #386 #431 #448 for upstream b12859..b12927 #378, #385, #386 and #431 merge upstream aa631e0 (FA bias API cleanup, b12859); #378 also keeps the Inkling router soft_max off the new short-row kernels (CUDA b12878, Vulkan b12916). #448 merges b12922 (few-row MMQ for NVFP4 adds a dst argument to ggml_cuda_should_use_mmq_few). feature-checks: add inkling2-expert-scales (MUL_MAT_ID with weight scales). * pr-set : repin #378 to keep the Inkling router soft_max on the pre-b12878 Metal kernel * pr-set : repin #378 #386 #431 for b12939 (rpc SUPPORTS_OP, BF16 supports_op), comment-only repins of #241 #243 * pr-set : drop #462, upstream took the same short conv fusion in b12942 * pr-set : pin #469 (greedy argmax of the logits row) * pr-set : repin #418 for the upstream flat CONCAT kernel in b12957 * pr-set : pin #470 (CPU multi-row MUL_MAT_ID for few-row experts) * pr-set : repin #396 (the model saver writes a shared host weight once) * feature-checks : keep cuda-short-conv-in-place with owner null, upstream b12942 carries it * pr-set : pin upstream's Qwen4 model support until the aged base carries it (b12969)
danielhanchen
changed the base branch from
base/upstream-94f17f659
to
base/upstream-8f50b1db9
December 6, 2026 08:25
This branch has not been deployed
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.
CUDA: batch-1 Q8_0 mat-vec against F32 activations, without the q8_1 quantize
For one src1 column (single-token decode) with Q8_0 weights, MMVQ first quantizes the F32 activations to q8_1 in a separate kernel, then runs the integer dot products. At batch 1 on Blackwell, that extra launch and the round trip through the q8_1 buffer are a visible share of every Q8_0 projection in decode.
This adds a dedicated kernel for that case on NVIDIA cc >= 10.0:
ne00 % 32 == 0,ne00 <= 4096, and the alignments the vector loads need hold. Everything else goes to the existing paths.GGML_CUDA_DISABLE_MMVQ_F32_ACT=1turns it off.This is not bit-exact. The activations are no longer rounded to 8 bits before the dot product, so results change slightly against MMVQ. The effect is a small accuracy gain, shown below. Batches larger than one column are unchanged and match bit for bit.
Accuracy
KLD against the BF16 GGUF of the same model, wikitext-2 test,
-c 512, 32 chunks, F16 KV, FA on, B200. The BF16 reference has no Q8_0 weights, so this path cannot engage while producing it. "off" is the same binary withGGML_CUDA_DISABLE_MMVQ_F32_ACT=1. Every arm was run twice, and the repeats are bit-identical, so the A/A floor is 0.The BF16 reference PPL is 6.4174. At ubatch 512 the path is not taken, and every value is identical. At ubatch 1, mean KLD is lower on both quants. Top-1 agreement moves by less than one standard error on IQ3_XXS and improves on Q4_K_XL.
Speed
llama-bench, B200 (exclusive), F16 KV, FA on,-r 3. There were 4 rounds interleaved ABBA, each round a fresh process per arm, and medians are over rounds. The A/A spread is the min-to-max range of the off arm across rounds. Both arms use the same binary and differ only byGGML_CUDA_DISABLE_MMVQ_F32_ACT=1.Prompt processing does not use this path. Its spread comes from a single cold first round. Without that round the other three are within about 1.5%.
Testing
test-backend-ops -o MUL_MATon CUDA0: 2916/2916. The Q8_0 x F32 one-column subset was also repeated 12 times, each 141/141.Not covered
Update: limit the F32-activation Q8_0 mat-vec to cc 10.x
New head
75c936de1f586ea369a7d828280c42217cdfa991, one commit on top of the current pin410a1ff30e1. Two files change, +3/-2:The header comment changes from
cc >= 10.0tocc 10.x. Nothing else changes. The kernel, the shape checks and theGGML_CUDA_DISABLE_MMVQ_F32_ACTkill switch are untouched.Why
This pin enabled the path on every NVIDIA cc >= 10.0. Its speed evidence covers B200 (cc 10.0) only. On an RTX 5090 (cc 12.0) the path makes batch-1 decode slower than the existing quantize + MMVQ path. It also changes output against q8_1, so it should run only where it is measured to win. cc 11.x (Thor) was never measured either, so it is excluded too. On cc 12.x the new head is the same as running the old head with
GGML_CUDA_DISABLE_MMVQ_F32_ACT=1.Prebuilt model
The prebuilt is the aged upstream
b####plus the pins inscripts/unsloth/pr-set.json, merged in order. This change stays inside #448's own lines and does not touch any other pin.Pin set merge
Simulated at b13024 with the next-round pr-set (67 pins) and #448 repinned to
75c936de1f5. Every pin merges,pin_contractreports all 67 pins intact,merge_checksis clean, and the new gate line is present in the merged tree.RTX 5090 (sm_120a, CUDA 13.0), pin-set tree
410a1ff30e1.75c936de1f5.GGML_CUDA_DISABLE_MMVQ_F32_ACT=1.Each arm ran 3 rotated rounds. Qwen4-35B-A3B UD-Q2_K_XL is fully on the GPU (UD-Q4_K_XL does not fit in 32 GB), FA on,
llama-benchtg128 in t/s.An independent repeat on another 5090 used Qwen4 UD-Q4_K_XL, comparing the old head with and without the kill switch. Decode went from 216.8 to 221.6 t/s at depth 0 (+2.2%, A/A 221.6 vs 221.6) and from 194.4 to 198.2 t/s at 64K (+1.9%).
With MTP (draft 2, llama-server), decode is unchanged within noise. The verify batch has more than one column, so it never takes this path.
At the chat turn, draft acceptance is 0.644 on A and 0.634 on B. Akill gives the same 0.634 as B.
Greedy output, RTX 5090
llama-completion -no-cnv --temp 0 -s 42 -n 128, md5 of the output.--cpu-moe)B matches the kill-switch output on every model. Where a model has Q8_0 tensors, B differs from A as expected. Qwen3.8-27B does not reach the path and is identical in all three arms.
cc 10.x
On cc 10.x the code path is the same as before, since only cc >= 11.0 is newly excluded. The B200 numbers in this PR's description still apply: +9.7% tg128 and +7.9% at 32K on UD-Q4_K_XL, +6.1% / +7.7% on UD-IQ3_XXS. B200 was not re-run for this change.
Not covered