Repository navigation
CUDA: batch-1 Q8_0 mat-vec against F32 activations, without the q8_1 quantize - #448
Open
danielhanchen wants to merge 5 commits into
Open
danielhanchen wants to merge 5 commits into
danielhanchen wants to merge 5 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)
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