flashinfer.cake_rmsnorm_silu_gate_train.cake_rmsnorm_silu_gate_train_forward¶
- flashinfer.cake_rmsnorm_silu_gate_train.cake_rmsnorm_silu_gate_train_forward(x: Tensor, z: Tensor, weight: Tensor, eps: float = 1e-06, *, out: Tensor | None = None, deterministic: bool = True) Tensor¶
SiLU-gated RMSNorm forward:
y = BF16(((x * rstd) * weight) * silu(z)).rstd = 1 / sqrt(mean(x^2) + eps)over the last dimension (128), in FP32;silu(z) = z / (1 + exp(-z))in FP32; one rounding to BF16 at the end.- Parameters:
x (torch.Tensor) – BF16
[..., 128]input ([T, H, 128]or[T * H, 128]).z (torch.Tensor) – BF16 gate input of the same shape as
x(its own strides).weight (torch.Tensor) – BF16
[128]weight shared by every token and head.eps (float) – Variance epsilon (FP32 inside the kernel).
out (torch.Tensor, optional) – Preallocated BF16 output of
x’s shape.deterministic (bool) –
True(default) runs the deterministic package’s forward (flashinfer.cake_rmsnorm_silu_gate_det_train.cake_rmsnorm_silu_gate_det_train_forward()) with these arguments.Falseruns the non-deterministic package’s forward program, the same kernel rendered there, or up to 12 rows per SM on SM100 / SM103 (59 on SM107) a forward with 16 threads to a row, and from 976 rows per SM on SM100 / SM103 (800 on SM107) a forward whose CTAs each walk several row blocks, with the same arithmetic (the forward has no reduction, so both return the same bits); it is refused whiletorch.use_deterministic_algorithms(True)is in effect (withwarn_only=True: a warning, then the deterministic forward).
- Returns:
BF16
yofx’s shape (outwhen given).- Return type:
torch.Tensor