perf: tile wide GeGLU rows on SM103 - #1403
Open
heiheiha798 wants to merge 4 commits into
Open
Conversation
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
blackwell_ultra).next_power_of_2(n_cols) >= 16384; other architectures and narrower rows keep the existing one-row kernels and launches.Related fork tracker: heiheiha798#1
Engineering record: heiheiha798#2
Details
On an NVIDIA B300 SXM6 AC, the legacy BF16 backward kernel at
8192x14336used 128 registers per thread. Registers limited it to one block per SM, with 25% theoretical and 21.75% achieved occupancy. NCU also reported 46.02% of cycles with no eligible warp and 29.07% DRAM throughput.The fixed 1024-element, 4-warp tile was selected from
{256, 512, 1024, 2048, 4096} x {4, 8}and checked against 2048x4 over widths 11008, 14336, 18944, and 29568. It was the robust choice across the measured row counts and widths.The optimized path is exact-SM103 only. B200, consumer Blackwell, Hopper, AMD/NPU, and narrow widths retain the legacy path. This intentionally duplicates the small elementwise kernel body so the legacy launch and compilation surface remain unchanged.
The optional cuTile GeGLU backend in #1250 is separate. This change follows the default-Triton Blackwell column-tiling direction established for SwiGLU in #1271, with a narrower architecture guard because these measurements are B300-specific.
Testing Done
The GPU correctness, performance, and profile results below are from Slurm job
4777on an NVIDIA B300 SXM6 AC, using the clean pushed head02697305d0870f4fb574da24fa09382b4b979014, driver 580.126.09, CUDA 13.0, PyTorch 2.13.0+cu130, and Triton 3.7.1.Targeted correctness:
The added tests force the legacy and tiled paths on the same GPU and require exact equality for forward,
da, anddbacross FP32, FP16, and BF16; aligned and ragged widths; the 8193-column dispatch boundary; and mocked nonzero CUDA-device routing.Static checks:
All passed.
make checkstylechecked all 371 files and left them unchanged.B300 kernel performance
Each result is the median across five alternating legacy/dispatched pairs. Each inner measurement uses 100 ms warmup and 500 ms repetition time. The tracked benchmark restores working
aandbfrom immutable originals before every backward or full launch; restoration is outside the timed region. Earlier dirty-worktree jobs4732and4738and their mutated-operand results are superseded by job4777.At the dispatch boundary, 8192 columns retained the legacy path at 1.000x full speed, while 8193 columns reached 1.371x at 1024 rows and 1.380x at 8192 rows.
NCU
Paired legacy/tiled BF16 backward profiles at
8192x14336:Full MLP check
A supplemental paired BF16
LigerGEGLUMLPcheck used hidden size 4096 and intermediate size 14336. Identical weights and inputs were measured over three alternating rounds with 100 ms warmup and 500 ms repetition time.The repository-standard
python benchmark/scripts/benchmark_geglu.py --model llama_3_8bend-to-end benchmark was not rerun.make testto ensure correctness (targeted GeGLU suite passed as reported above)make checkstyleto ensure code stylemake test-convergenceto ensure convergence