Repository navigation
cuda: wider FWHT blocks at decode/verify sizes, bit-identical: +2.6-4.9% 9B, +4% 27B MTP on H200 - #396
Merged
Conversation
…code / verify sizes fwht_cuda_block and fwht_quantize_q8_1 run one 256-thread block per transform. At decode and speculative verify there are only 1-64 transforms in flight, so a handful of small blocks leaves most of the GPU idle and the kernel is bound by its stage latency. With 64 or fewer transforms, use min(n/2, 1024) threads (at least two elements per thread). The butterfly runs its stages in the same order for any block width, so results are bit-identical. GGML_CUDA_FWHT_NT overrides the wide value (256 disables it). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PRQc3TQpn72qBxrUn5vKqo
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
fwht_cuda_block(plain/signed transform, n ≥ 512) andfwht_quantize_q8_1(transform + q8_1, the PTQ1_0 path of #377) launch one 256-thread block per transform.During decode and speculative verify only 1–64 transforms are in flight. On the 9B, for example, the o_proj and ffn_down inputs give 4–8 blocks of 4096 elements on a 132-SM H200. Those few small blocks are bound by the 12 butterfly stages' latency, not by bandwidth.
With 64 or fewer transforms, this PR uses min(n/2, 1024) threads per block, so every thread still holds at least two elements:
Above 64 transforms (prefill) nothing changes.
Bit-identical:
ggml_cuda_fwht_block_butterfly<N, NT>runs its stages in ascending stride order for anyNT.Override:
GGML_CUDA_FWHT_NT=512|1024overrides the wide value;256restores the old behaviour.Results (H200, prism 97ea5ae, job 31313, tokens identical in every cell)
GGML_CUDA_FWHT_NT=256The block-width sweep (jobs 31218 and 31254, on top of #391/#395) picked the rule:
Tests
On the #391/#395 stack, ADD_RMS_NORM_HADAMARD (22/22) also passes at NT 256, 512 and 1024.
Independent of #391 and #395. It applies on top of them without conflicts and adds to their gains.