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.
🚀 Optimization Description
This PR introduces an
inference_modeargument to therms_norm_forwardwrapper and kernels. When enabled (True), the kernel skips storing the Reciprocal Standard Deviation (RSTD) to global memory.🧠 Motivation
RMSNorm is significantly memory-bound.
RSTDis required for the backward pass, so it must be stored.RSTDis not needed after normalization. Writing it to HBM consumes write bandwidth unnecessarily.By skipping this write operation, we reduce memory traffic. This results in significant throughput gains for smaller and medium hidden dimensions (critical for Speculative Decoding and MoE Architectures) while saving VRAM bandwidth on larger dimensions.
🛠️ Implementation Details
STORE_RSTDconstexpr to both standard and blocked Triton kernels.rms_norm_forwardwrapper to acceptinference_mode.inference_mode=True,RSTDallocation is skipped (empty tensor) and the store operation is compiled out via Triton's JIT.LigerRMSNormFunction(Autograd) default behavior is preserved (Training mode).📊 Benchmarks
Hardware: NVIDIA RTX 4050 (Ada Lovelace) | Precision: BFloat16
(Note: Gains are highest at lower dimensions where the RSTD write overhead is proportionally larger. Performance may vary slightly due to thermal throttling on consumer hardware.)
✅ Verification
RSTDis not written to memory using Nsight Compute (NCU) analysis.