PyTorch
Read post

Towards Free Normalization: Fusing Normalization into GEMM and Attention Kernels – PyTorch

Novel GPU kernel fusion techniques are presented for LayerNorm and RMSNorm operations, which typically consume 10-20% of training latency in LLMs and recommendation models. Three main contributions are covered: (1) naive epilogue fusion for small N dimensions yielding 17-32% latency savings; (2) Lazy Pre-Norm, a prologue fusion technique that exploits the commutativity of row-wise multiplication to delay RMSNorm's elementwise step until after the GEMM k-loop, hiding most norm computation behind TensorCore ops; (3) Multi-CTA Norm Fusion using CTA clusters and Distributed Shared Memory to collaboratively compute reductions across CTAs, enabling epilogue fusion for larger N. A 'fusion regrouping' trick ensures backward passes also achieve epilogue fusion by fusing norms with different linear layers than in forward. Finally, FlashNormAttention fuses both a pre-LayerNorm and post-RMSNorm into a GDPA attention kernel, achieving up to 35% kernel speedup, with detailed optimizations for memory pressure (SMEM/TMEM reuse, register subtiling) and pipeline stalls (warp specialization, register pre-loading). Benchmarks are on NVIDIA B200 GPUs using bfloat16.

    #gpu#pytorch
Jul 10•25m read time•From pytorch.org
Post cover image
Table of contents
TL;DRIntroduction1. Challenges of Normalization Fusion2. Lazy Pre-Norm: A Novel Technique of Fusing Pre-Norm with Linear Layers3. Multi-CTA Norm: Fusing Post-Norm with Linears as Epilogue4. FlashNormAttention: Fusing both Pre-Norm and Post-Norm into FlashAttention-variant kernelsAcknowledgementsReferences
125 Impressions
PyTorch's image
PyTorch

PyTorch offers insights into deep learning, neural network modeling, and machine learning research, ...

142 Followers

•

231 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard