flashinfer.norm.gated_residual_rmsnorm¶
- flashinfer.norm.gated_residual_rmsnorm(branch: Tensor, residual: Tensor, weight: Tensor | None, alpha: Tensor, beta: Tensor, eps: float = 1e-06, gain_center: float = 0.0, out: Tensor | None = None, *, enable_pdl: bool = True, backend: Literal['auto', 'cake', 'cute'] = 'auto') Tensor¶
Gated residual RMSNorm for hidden size 8192: blend a normalized branch into the stream.
The operation is
alpha * residual + beta * RMSNorm(branch). Whenweightis supplied,weight + gain_centeris applied tobranchbefore its RMS reduction. When it isNone, the branch is unweighted.This optimized implementation currently supports contiguous BF16 tensors with hidden size 8192 on SM100, SM103, and SM107 GPUs.
- Parameters:
branch (torch.Tensor) – Two-dimensional BF16 and FP32 tensors, respectively, with shape
(rows, 8192).residual (torch.Tensor) – Two-dimensional BF16 and FP32 tensors, respectively, with shape
(rows, 8192).weight (Optional[torch.Tensor]) – Optional BF16 pre-normalization weight with shape
(8192,).alpha (torch.Tensor) – FP32 gate tensors with shape
(8192,).beta (torch.Tensor) – FP32 gate tensors with shape
(8192,).eps (float) – Epsilon added to the RMS denominator.
gain_center (float) – Constant added to
weightin FP32.out (Optional[torch.Tensor]) – Optional FP32 output tensor with the same shape and layout as
residual.enable_pdl (bool) – Whether to enable programmatic dependent launch. Defaults to
True; passFalseto disable it. The Cake package ships a plain and a programmatic-dependent-launch build of each program and runs the one the flag selects.backend (str) –
"auto"(default) runs the Cake kernels (flashinfer.cake_muse_spark_norm_backend) where the package ships a program for the device, the call’s inputs (weightpresent or not,enable_pdl) and its row count (the package’s routes may leave row-count gaps where the CuTe DSL kernel measured ahead) and the tensors sit in 32-byte aligned storage (the package’s programs read and write 256-bit vectors; storage aligned to 16 bytes only runs the CuTe DSL kernel), else the CuTe DSL kernel;"cake"and"cute"select one and raiseValueErrorwhen it is not available ("cake"at a row count in a gap, or on storage aligned to 16 bytes only, raises too).
- Returns:
The fused result.
- Return type:
torch.Tensor