Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA TransformerEngine Ops Fused Backward Add RMSNorm

From Leeroopedia
Revision as of 15:59, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/NVIDIA_TransformerEngine_Ops_Fused_Backward_Add_RMSNorm.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Field Value
Sources TransformerEngine
Domains Deep_Learning, PyTorch, Optimization
Last Updated 2026-02-07 14:00 GMT

Overview

Fused backward pass operation that combines RMSNorm gradient computation with residual gradient addition into a single kernel.

Description

BackwardAddRMSNorm is a FusedOperation that fuses the backward pass of MakeExtraOutput (residual branch) and RMSNorm into a single tex.rmsnorm_bwd_add kernel call. This avoids a separate kernel launch for adding the residual gradient to the RMSNorm input gradient. The fusion requires a non-in-place MakeExtraOutput followed by RMSNorm in the backward operation list.

Usage

Automatically applied by the operation fuser when it detects the compatible backward pass pattern. This fusion is common in pre-norm transformer architectures.

Code Reference

Source Location

Repository
NVIDIA/TransformerEngine
File
transformer_engine/pytorch/ops/fused/backward_add_rmsnorm.py
Lines
1--127

Signature

class BackwardAddRMSNorm(FusedOperation):
    def __init__(self, *, add: MakeExtraOutput, rmsnorm: RMSNorm): ...
    def fuser_backward(self, basic_op_ctxs, grad_output, *, basic_op_grad_extra_outputs) -> Tuple: ...

    @staticmethod
    def fuse_backward_ops(ops, **unused) -> list[FusibleOperation]: ...

Import

from transformer_engine.pytorch.ops.fused.backward_add_rmsnorm import BackwardAddRMSNorm

I/O Contract

Inputs

Name Type Required Description
add MakeExtraOutput Yes The MakeExtraOutput (residual) operation (must not be in-place)
rmsnorm RMSNorm Yes The RMSNorm operation
grad_output torch.Tensor Yes Upstream gradient
basic_op_grad_extra_outputs list Yes Contains residual gradient from extra output

Outputs

Name Type Description
grad_input torch.Tensor Combined gradient (RMSNorm backward + residual)
grad_weight torch.Tensor Gradient w.r.t. RMSNorm weight parameter

Usage Examples

# Automatically fused by the operation fuser when detecting pattern:
# [MakeExtraOutput(in_place=False), RMSNorm] in the backward pass
# No manual usage required - the fuser handles fusion automatically

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment