nemo_automodel.components.models.common.squared_relu
nemo_automodel.components.models.common.squared_relu
ReLU squared for non-gated MLPs, through Transformer Engine’s kernels where they apply.
Module Contents
Classes
Functions
Data
API
Bases: Function
ReLU squared through Transformer Engine’s srelu and dsrelu kernels.
Return the gradient of x: 2 * relu(x) * grad_output.
Parameters:
Autograd context of the forward.
Gradient of the output, shape [rows, width], any strides.
Returns: torch.Tensor
A new tensor with the shape and dtype of x.
Return relu(x) ** 2 and save x for the backward.
Parameters:
Autograd context; saves x.
Contiguous CUDA tensor of shape [rows, width] in BF16, FP16 or FP32.
Returns: torch.Tensor
A new tensor with the shape and dtype of x.
Return Transformer Engine’s kernel module, or None when Transformer Engine does not load.
Return relu(x) ** 2 in the dtype of x.
A CUDA tensor in BF16, FP16 or FP32 runs through Transformer Engine’s kernels, one per direction, which
keep x alone for the backward. The values and the gradient are those of the eager chain
F.relu(x).pow(2) bit for bit. Every other tensor, and every tensor where Transformer Engine does not
load, takes the eager chain.
Parameters:
Tensor of shape […, width], any strides.
Returns: torch.Tensor
A new tensor with the shape and dtype of x.