[perf][gemm]: optimize long-token FFN deterministic path - #353
Closed
maxiaosong1124 wants to merge 5 commits into
Closed
maxiaosong1124 wants to merge 5 commits into
maxiaosong1124 wants to merge 5 commits into
Conversation
maxiaosong1124
requested review from
Flink-ddd,
KJLdefeated,
bitborne and
inaniloquentee
as code owners
August 28, 2026 12:47
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Collaborator
Author
|
Superseded by #354, which uses the correctly named |
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.
Summary
Optimize the long-token CUDA deterministic GEMM path used by the Qwen3 FFN, building on PR #351's short-token
dWoptimization.The PR351 short-token path is intentionally unchanged: when
tokens < 32,det_gemm_db_small_kis still used. This change targets thetokens >= 32SM90 path.The long-token path now:
__hadd2tree merges;Validation
tests/test_det_gemm.py tests/test_qwen_ffn.py: 69 passeddet_gemm_db_small_kkernel.benchmarks/results/qwen_ffn_h100_trace/.H100 benchmark results
Hardware: NVIDIA H100 80GB HBM3, BF16, Qwen3-8B FFN (
hidden=4096,intermediate=12288).CUDA-event latency uses 5 warmups, 20 forward iterations, and 10 forward+backward iterations. Values are the median of three trial medians. Baseline is
origin/pr-351 @ adb575d.Nsight Systems kernel attribution
The
cuda_gpu_kern_sumaggregates show the deterministic GEMM reduction remains positive across all long-token scenarios:Deterministic GEMM accounts for approximately 85%–91% of GPU kernel time in these profiles and remains the primary FFN bottleneck. The percentage benefit decreases with token count as the long-token GEMM work dominates fixed launch/reduction overheads.
Reproduction
PYTHONPATH=$PWD python benchmarks/results/qwen_ffn_h100_trace/bench_long_token_std.py \ 1024 2048 4096 8192The raw
.nsys-repfiles are retained on the profiling node; the SVGs and summary are included as review artifacts.