flashinfer.cake_rmsnorm_silu_gate_train.cake_rmsnorm_silu_gate

flashinfer.cake_rmsnorm_silu_gate_train.cake_rmsnorm_silu_gate(x: Tensor, z: Tensor, weight: Tensor, eps: float = 1e-06, *, deterministic: bool = True) → Tensor

Differentiable RMSNorm(x) * weight * SiLU(z) over the last dimension (128). Each autograd node saves only x, z and weight.

deterministic=True (default) is flashinfer.cake_rmsnorm_silu_gate_det_train.cake_rmsnorm_silu_gate_det() (a CakeRMSNormSiLUGateDetFunction node): the deterministic package in both directions, its bits. False applies the non-deterministic package’s own CakeRMSNormSiLUGateFunction (flashinfer.cake_rmsnorm_silu_gate_train_backend), whose weight gradient is summed over the CTAs in a scheduling-dependent order; it is refused while torch.use_deterministic_algorithms(True) is in effect (with warn_only=True: a warning, then the deterministic node). The backward of a False node raises PyTorch’s alert if the deterministic algorithms are enabled by the time it runs and weight needs a gradient (RuntimeError; under warn_only=True a UserWarning, then the non-deterministic backward). A non-reentrant checkpoint replays the forward through this function with the same flag.

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.

  • weight (torch.Tensor) – BF16 [128] weight shared by every token and head.

  • eps (float) – Variance epsilon (FP32 inside the kernel).

  • deterministic (bool) – True (default) applies the deterministic node, False the non-deterministic one (see above).

Returns:

BF16 y of x’s shape.

Return type:

torch.Tensor