perf(kernels): budget cublasLt tuning repeats by weight traffic - #822
Open
FeathBow wants to merge 1 commit into
Open
perf(kernels): budget cublasLt tuning repeats by weight traffic#822FeathBow wants to merge 1 commit into
FeathBow wants to merge 1 commit into
Conversation
Signed-off-by: Feathbow <feathbow@gmail.com>
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.
Description
gemm_lt_tune_cudatimes every heuristic candidate for a decode GEMM shape and caches the winner. It spent a flat 20 timed repeats per candidate regardless of shape.Timing noise is roughly a fixed cost per launch, so the repeats a candidate needs for a stable ranking fall as the GEMM streams more weight. A flat count overpays on the large projections and buys nothing extra on the small ones. This budgets the repeats by weight traffic instead:
The upper bound is the count it replaces, so no shape is tuned more than before. As a pure function of BF16 weight bytes the rule describes its own blast radius: a projection keeps 20 repeats below about 52.5 MiB, falls through the range above that, and sits at the floor of five past about 186.2 MiB.
Reported by the build itself:
Qwen3.5's ten tuning calls resolve to eight distinct
(M, K); the tuner caches on(device, M, N, K), so calls sharing a shape share one tuned result. Qwen3-4B's lm_head M isvocab_size, Qwen3.5's isselection_vocab. The DFlash draft path keeps its attention shape at 20 and crosses the threshold in its context projection only at five or more target layers.gemm_lt_tune_cudanow rejects a non-positiveM,N, orKat its entry, so the helper works on validated dimensions.What motivated this: on Qwen3-4B, warm startup spent 1594 ms of 3073 ms in this tuner, against 908 ms in the weight load that two earlier PRs optimised.
Test Env
Single GPU (sm_89, x86_64), CUDA 12.9, Qwen3-4B and Qwen3.5-4B, page cache warm. Both A/B binaries are built from this commit and its parent on
35f990d.Covered: the two 4B checkpoints on sm_89 — every shape whose repeat count changes there, plus the golden gate for both model lines.
Not covered: Qwen3-8B and Qwen3.5-9B/27B.
Verification
A/B — five order-rotated interleaved pairs.
Paired median 749 ms (23.6%) off warm HTTP-ready, 5/5 pairs. The weight-load phase is unchanged — 872–906 ms flat against 809–926 ms budgeted, overlapping ranges with means 9 ms apart — so the saving sits in tuning.
A second five-pair session on the same parent measured a paired median of 800 ms for a behaviourally identical revision. Pooling both gives ten pairs spanning 687–873 ms at a median of 774 ms, which is this harness's resolution.