feat(Part2): Fused Add + RMSNorm Triton kernel with MASE transform pass#313
Closed
Dorijan9 wants to merge 1 commit intoDeepWok:mainfrom
Closed
feat(Part2): Fused Add + RMSNorm Triton kernel with MASE transform pass#313Dorijan9 wants to merge 1 commit intoDeepWok:mainfrom
Dorijan9 wants to merge 1 commit intoDeepWok:mainfrom
Conversation
- Triton forward/backward kernels fusing residual addition + RMSNorm - torch.autograd.Function and nn.Module wrappers - FX graph transform pass: pattern-matches add→RMSNorm, swaps in fused module - 3 casting modes: llama, gemma, none (matches Liger-Kernel conventions) - 144/144 forward + 36/36 backward correctness tests - Benchmarks: up to 4.9x speedup (bf16 batch), 60% memory reduction Part 2 of ADLS kernel-fusion-aware optimisation pipeline.
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.
Fused Add + RMSNorm Triton Kernel with MASE Transform Pass
Part 2 of the ADLS kernel-fusion-aware optimisation pipeline.
Problem
Every transformer decoder layer runs residual addition and RMSNorm as two separate CUDA kernels, writing the intermediate tensor to HBM and reading it back. For a 32-layer Llama model, that's 64 wasted memory round-trips per forward pass.
Solution
A hand-written Triton kernel fuses both operations into a single GPU kernel launch, plus an FX graph transform pass that automatically pattern-matches
add → RMSNormand swaps in the fused module.Files
Tests
nn.Modulewrapper: ✅Supports
llama,gemma, andnonecasting modes. Recognises all major HuggingFace RMSNorm variants (Llama, Mistral, Gemma, Qwen2).