flashinfer.norm¶
Kernels for normalization layers.
|
Root mean square normalization. |
|
Root mean square normalization + fp8 quantization. |
|
Fused add root mean square normalization. |
|
Fused add root mean square normalization + fp8 quantization. |
|
Fused add-residual + RMSNorm + 1x128 fp8 block quantization, in one pass. |
|
Gemma-style root mean square normalization. |
|
Gemma-style fused add root mean square normalization. |
|
Layer normalization. |
|
Layer normalization + fp8 quantization. |
|
Fused RMSNorm + SiLU activation. |
|
Fused QK RMSNorm + 3D RoPE + V copy for video generation DIT self-attention. |
Fused residual + LayerNorm + scale/shift for DIT self-attention. |
|
Fused gate + residual + LayerNorm + scale/shift for DIT self-attention. |
|
Fused gate + residual + LayerNorm(gamma, beta) for DIT self-attention. |
Fixed-Width Fused Norms¶
Fused gated-residual and per-head gated RMSNorm kernels for SM100, SM103 and
SM107. They support only the widths in their docstrings (hidden size 8192, head
dim 64); check the matching supports_* helper and fall back otherwise.
|
Gated residual RMSNorm for hidden size 8192: blend a normalized branch into the stream. |
|
Return whether tensors satisfy the SM100/SM103/SM107 fused-kernel contract and |
|
Gated residual RMSNorm plus the next RMSNorm in one launch, for hidden size 8192. |
|
Return whether inputs satisfy the SM100/SM103/SM107 two-norm kernel contract and |
|
Per-head RMSNorm and sigmoid gate, in place, for head dim 64. |
|
Whether a BF16, head-dimension-64 call can run on |
Training RMSNorm (Cake)¶
Fused BF16 RMSNorm forward / backward for training on SM100, SM103 and SM107:
FP32 statistics and accumulation, one FP32 reciprocal RMS saved per row,
fused dx + deterministic FP32 dw backward, optional residual-add
fusion and an autograd wrapper.
|
Autograd-enabled fused BF16 RMSNorm (optionally with a fused residual add). |
|
Fused BF16 RMSNorm forward with FP32 statistics. |
|
Fused BF16 RMSNorm backward: |
Bytes of the caller-owned backward workspace of width |
|
|
Allocate a zero-initialized backward workspace (see |
|
Autograd wrapper saving only |
Training SiLU-gated RMSNorm (Cake)¶
RMSNorm(x) * weight * SiLU(z) with a separate gate input z, forward /
backward for training on SM100, SM103 and SM107: rows of 128 ([T, H, 128]
or [T * H, 128]) normalized per head with FP32 statistics and gate, BF16
inputs, outputs and gradients, a weight shared by every token and head whose
gradient is summed in a fixed order (repeated calls return the same bits), and
an autograd wrapper that saves only its inputs.
|
Differentiable |
|
SiLU-gated RMSNorm forward: |
|
SiLU-gated RMSNorm backward: |
Bytes of the backward's FP32 weight-gradient partial buffer for |
|
A caller-owned backward workspace for |
|
|
Autograd of |