Repository navigation
cuda: keep PTQ1_0 on the PT mat-vec for 5-8 columns on Hopper (pp N=5 -30%, MTP depth 5 x1.24 on H200; not token-identical at verify width >= 5) - #382
Merged
Conversation
On H200 the MMQ tile path is slower than the PT mat-vec at 5-8 columns (Bonsai 2 27B, one forward at depth 4096: 17.99 vs 12.64 ms at n=5, 18.76 vs 15.71 ms at n=8). The PT kernel's per-column arithmetic does not depend on the column count, so 5-8 column results equal the 2-4 column ones. Ada and other architectures keep the 4-column crossover.
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
On Hopper, PTQ1_0 mat-muls with 5-8 columns (
MMVQ_MAX_BATCH_SIZE) stay on the PT mat-vec (mul_mat_vec_ptq1_0_pt) instead of crossing to MMQ at 5. The change is 6 lines inggml_cuda_should_use_mmvq(mmvq.cu). Ada and every other architecture keep the 4-column crossover.The gate is
cc >= GGML_CUDA_CC_HOPPER && cc < GGML_CUDA_CC_BLACKWELL.GGML_CUDA_CC_BLACKWELLis 1200 in this tree, so sm_100/sm_103/sm_110 fall inside the gate too. Only H200 was measured.Why
The existing comment explains the crossover at 4 with an Ada measurement: there, the PTQ1_0 MMQ tile path overtakes the mat-vec at 5+ columns. On H200 it is the other way round. MMQ at N=5 costs about 2.5× a single-column forward, while the PT mat-vec grows smoothly. This affects MTP / speculative verify at depth 4-7 (5-8 columns).
Results
H200, CUDA 12.8, Release sm_90. Ternary Bonsai 2 27B PTQ1_0 with an MTP head.
One forward of N tokens at depth 4096 (
llama-bench -fa 1 -ub 512 -b 2048 -d 4096 -r 10, ABBA, 4 pairs, tip vs this branch):So pp N=5 is −30% and N=8 is −16%. Outside 5-8 nothing changes.
End to end,
llama-server, MTP greedy decode, 4 prompts × 256 tokens × 2 reps, paired against tip. The same routing was selected through an environment override on an experimental build:Exactness
Related PRs
prism. This PR only moves the Hopper crossover.GGML_CUDA_BATCH_INVARIANT=1, plus aGGML_CUDA_PTQ1_MMVQ_MAXoverride. Its measurement (pp5 MMQ 172 vs mat-vec 162 tok/s) supports 4 as the default on its hardware, which is consistent with keeping 4 off Hopper here. The two PRs edit the same lines inggml_cuda_should_use_mmvqand will conflict textually. Whichever lands second needs a small rebase. The natural combination is cuda: BATCH_INVARIANT: occupancy-independent FA KV split, PTQ1_0 mat-vec up to 8 columns #322's override, then this Hopper default, then 4.Test plan
prism. Builds Release sm_90.test-backend-ops -b CUDA0 -o MUL_MAT: 1630/1630 at e8db221 (job 29679), the same (empty) failure set as tip73bfe6cc.Not verified
cc < GGML_CUDA_CC_BLACKWELLgate, so they get the new rule unmeasured.