flashinfer.cake_rmsnorm_train.cake_rmsnorm¶
- flashinfer.cake_rmsnorm_train.cake_rmsnorm(x: Tensor, w: Tensor, eps: float = 1e-06, residual: Tensor | None = None, deterministic: bool = True)¶
Autograd-enabled fused BF16 RMSNorm (optionally with a fused residual add).
- Parameters:
x (torch.Tensor) – BF16
[T, H]input on a supported CUDA device (withdeterministic=Falsealso[..., H]under the layout rule ofcake_rmsnorm_train_forward()).w (torch.Tensor) – BF16
[H]RMSNorm weight (withdeterministic=Falsealso FP32 on the routes that ship the FP32-weight programs); the weight gradient is returned inw.dtype.eps (float) – Variance epsilon evaluated in FP32 by the kernel.
residual (torch.Tensor, optional) – BF16 update of
x’s shape added toxbefore normalization. When provided, the normalized inputh_newis returned with the output.deterministic (bool) –
True(default): the deterministic package in both directions, the bits offlashinfer.cake_rmsnorm_det_train.cake_rmsnorm_det().False: this package’s kernels, whose weight gradient is summed over the CTAs in a scheduling-dependent order and is not guaranteed bitwise reproducible; refused whiletorch.use_deterministic_algorithms(True)is in effect (withwarn_only=True: a warning, then this package’s forward programs and the deterministic package’s backward, or oneRuntimeErrorwhen that backward cannot serve the call).
- Returns:
BF16
yofx’s shape, or(y, h_new)whenresidualis given. Backward launches the kernels ofcake_rmsnorm_train_backward()under the samedeterministic.- Return type:
torch.Tensor or tuple[torch.Tensor, torch.Tensor]