Triton RMSNorm Optimizations#593
Open
Micky774 wants to merge 11 commits into
Open
Conversation
aris134
reviewed
May 27, 2026
aris134
reviewed
May 27, 2026
aris134
reviewed
May 27, 2026
aris134
requested changes
May 27, 2026
alextmagro
requested changes
May 27, 2026
alextmagro
approved these changes
May 29, 2026
aris134
reviewed
May 29, 2026
ipanfilo
requested changes
May 30, 2026
| * NVTE_USE_CAST_TRANSPOSE_TRITON=1 can be used to enable cast transpose (bgrad) triton kernels; | ||
| * NVTE_USE_LAYERNORM_TRITON=1 can be used to enable layernorm triton kernels. | ||
| * NVTE_USE_RMSNORM_TRITON=1 can be used to enable rmsnorm triton kernels. | ||
| * NVTE_RMS_EXTERNAL_TRANSPOSE=0 disables external transpose in RMSNorm Triton kernels and |
Collaborator
There was a problem hiding this comment.
@ipanfilo Could you check if the comments has been addressed?
Collaborator
|
@alextmagro @aris134 I saw you had approved the PR. For the inline comments, let's also resolve conversation if the comments has been addressed. |
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.
Description
Optimizes the Triton RMSNorm forward and backward kernels and adds an LDS-tiled FP8 transpose path. Measured 10%-50% improvements across a representative shape sweep for bf16 w/ no quantization or FP8 quant, and improvements of 3x-8x on FP8 Transpose outputs.
Benchmarks generated by this script.
Type of change
Changes
Please list the changes introduced in this PR:
gammaload +ZERO_CENTERED_GAMMAadjustment +1/n_colshoisted outside the persistent row loop.gammahoist;inv_n_colshoisted.c_scalar = nf*nf*grad_sum*inv_n_colscomputed once before the dx/dg loop;dxexpression refactored tonf * (dz*g - c*x)(saves one multiply per element)._rmsnorm_bwd_tritonand_rmsnorm_bwd_dg_reduce_tritonnow follow the impl + autotune-wrapper dispatch pattern already used by the fwd kernel.te_rmsnorm_bwd_tritontakes anautotune: bool = Truekwarg; when off it uses the previously-hardcodednum_warps=8+ fixedBLOCK_SIZE_M/N=128/64reduce tile._fp8_transpose_2d_impl(+ autotune wrapper) replaces the in-kernelout_transpose_ptr + cols * stride + row_idxstrided byte stores that were uncoalesced (one byte per thread to a different cache line). The new kernel does a coalesced(BLOCK_M, BLOCK_N)read,tl.trans()for LDS-staged transpose, then coalesced strided write.Checklist: