[CUDA] Enable native CuTe DSL fused linear cross entropy on SM103 - #1401
Open
heiheiha798 wants to merge 4 commits into
Open
[CUDA] Enable native CuTe DSL fused linear cross entropy on SM103#1401heiheiha798 wants to merge 4 commits into
heiheiha798 wants to merge 4 commits into
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, 10.0)and(blackwell_ultra, 10.3)pairs are accepted, while SM120, Hopper, CPU, FP32, andreduction="none"retain their existing behavior.This change tracks fork issue #17. The original OPEN draft engineering record is heiheiha798/Liger-Kernel#18.
This is complementary to #1396: that PR adds Triton fallback behavior for capability misses, while this PR enables the existing native path on exact SM103.
Testing Done
make testto ensure correctness (the focused suites listed below were run instead)make checkstyleto ensure code stylemake test-convergenceto ensure convergence (the selected mini-Llama3 and mini-Qwen2 cases listed below were run instead)All GPU validation ran through Slurm on one NVIDIA B300 SXM6 AC (SM103), driver 580.126.09, CUDA 13.0, PyTorch 2.13.0+cu130, Triton 3.7.1, NVIDIA CUTLASS DSL 4.7.0.
run_epilogue_gemmpassed BF16/FP16 PyTorch GEMM oracles; unchanged native public FLCE passed independent FP32 PyTorch loss and all-gradient oracles for BF16/FP16, mean/sum, bias, ignore rows, label smoothing, and non-unit upstream gradients.990b24c: 247 CuTe FLCE/GEMM tests, 203 transformer/monkey-patch tests, and BF16 mini-Llama3/mini-Qwen2 selection (4 selected cases) passed.c95cdaf: 250 CuTe FLCE/GEMM tests passed, including TVM-FFI, DLPack, partial/frozen gradients, repeated backward, ignored rows, odd tails, actual-device dispatch, and compile-cache isolation.a1db3ac: the focused full-pipeline device-context regression passed and the complete CuTe FLCE/GEMM suite passed (251 passed). The test forces the native pipeline with mocked launch bodies and proves its CE stage executes inside the input-device context even when the modeled ambient device differs.make checkstylepassed on the login node at final head: 370 files lint-clean and already formatted.B300 Results
Job 5089 used detached clean worktrees at baseline
124fb8aand production commit990b24c, fresh exact-source processes, identical deterministic inputs, compilation excluded, three measurements per round, and seven alternating paired rounds. Public forward-plus-backward is authoritative. The token sweep fixes H4096/V128256; the vocabulary sweep fixes BT8192/H4096.All 7/7 token and 6/6 vocabulary points exceeded the 20% acceptance target. Thirteen FP16, odd-H/V, feature, metric, token-scaling, and FP32-gradient-accumulation controls had no median regression above 5%; the minimum ratio was 0.969x on the sub-millisecond V513 control. At BT8192/H4096/V128256, incremental peak allocation fell from 4,134.7 MiB to 1,316.5 MiB, a 2,818.2 MiB reduction. Job 5102 reconfirmed the final context-only head at the same reference point: 120.922 ms Triton versus 20.268 ms native CuTe (5.966x), with 3.140x lower incremental peak allocation.
NCU from job 5089 captured one unchanged native persistent forward GEMM chunk at BT8192/H4096/V128256: 862.592 us, grid
(2,1,74), block(192,1,1), 48 registers/thread, 94.95% tensor-pipe activity, 1.089 GB read, 249.553 MB written, 1.552 TB/s aggregate DRAM traffic, 72.60% L2 hit rate, and zero local loads/stores or spill requests. The public native path launches 8 persistent GEMMs for the reference forward chunking.Reproduction
Run the existing repository benchmark from clean detached baseline/candidate worktrees in the same B300 allocation, using the same environment and model selection:
Raw local evidence:
.cache/b300-cutedsl-sm103/final-5089.out,final-5089.err,native-5089.ncu-rep,native-5089.csv,head-5095.out,review-5102.out, andreview-5102.err. Job 5088 failed before worker import because its metadata probe omitted the isolated dependency hook. Jobs 5090/5092 stopped in newly added test setup before FLCE; corrected job 5093 passed. These discarded runs are not performance evidence.Optional SM103 schedule tuning was intentionally omitted: the unchanged native schedule cleared every frozen public-path gate, avoiding architecture-specific schedule churn.