Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for RMS Normalization.
Computes the per-slice reciprocal RMS
over
the trailing dimensions of x, scales the input by it, and
applies the per-element gain . Only saved_rstd_ is
cached for backward — no mean is needed because RMSNorm does not
centre the input.
Inherits FuncOp<RMSNormBackward, 2> with two saved-input slots —
x and gamma (RMSNorm has no bias). outer_ * N_ always
equals numel(x).
Math
For each leading-axis slice of x (flattened length ):
Equivalently, with the saved :
References
Zhang & Sennrich, "Root Mean Square Layer Normalization" (NeurIPS 2019, arXiv:1910.07467).
Attributes
schema_v1OpSchemaname="rms_norm", version=1, amp_policy=ForceFP32, produces_grad=true).saved_rstd_Storage(outer_,).outer_std::size_tx.N_std::size_tx (== numel(gamma)).Notes
Thread safety: instances are created during forward and consumed during backward — no concurrent access expected.
Static methods
1Run the forward pass.
Reduces x over its last dimensions (where is the rank
of gamma), divides by the RMS, applies the gain, and (when
grad mode is on) registers this as the grad_fn of the
returned output. Caches saved_rstd_ for backward.
Parameters
xTensorImplPtr(*, normalized_shape). Rank must be >= rank(gamma).gammaTensorImplPtrx.epsdoubleReturns
TensorImplPtrNormalised output, same shape as x.
Raises
ShapeMismatchgamma.ndim > x.ndim or if the trailing dims of x do not match gamma.Methods
1Compute gradients for the two saved inputs.
Returns {dx, d_gamma} in the saved-input order. Closed-form
(per leading slice of length , using the cached
):
and the input gradient is the standard RMSNorm backward formula (the centred grad is replaced by the un-centred grad since RMSNorm has no mean subtraction).
Parameters
grad_outStorageReturns
std::vector<Storage>Two-element vector {dx, d_gamma}.