vllm.models.qwen3_5.nvidia.ops.fused_norm_quant
¶
Gemma (1 + w) add-RMSNorm fused with the consumer linear's input quant.
Replaces gemma_fused_add_rmsnorm followed by a standalone static FP8 or
dynamic per-token FP8 (scaled_fp8_quant) or NVFP4 (scaled_fp4_quant)
kernel. The quantized values are computed from the bf16-rounded normed
activation with the same scale arithmetic as those kernels, so codes match
the unfused chain.
gemma_add_rms_norm is the same kernel without the quant epilogue, used
as the pre-SM80 fallback where flashinfer's norm module cannot JIT-build.
Functions:
-
gemma_add_rms_norm–Gemma RMSNorm of
x (+ residual)without quantization. -
gemma_add_rms_norm_quant–Gemma RMSNorm of
x (+ residual)quantized for the next linear.
_cvt_e2m1x2(lo, hi)
¶
Pack fp32 (lo, hi) pairs into E2M1 bytes (lo in the low nibble).
Source code in vllm/models/qwen3_5/nvidia/ops/fused_norm_quant.py
gemma_add_rms_norm(x, residual, weight, eps)
¶
Gemma RMSNorm of x (+ residual) without quantization.
The pre-SM80 fallback for flashinfer's norm kernels, whose JIT build
fails there. x is read only; residual is updated in place.
Returns the normed activation in x's dtype.
Source code in vllm/models/qwen3_5/nvidia/ops/fused_norm_quant.py
gemma_add_rms_norm_quant(x, residual, weight, eps, scale, key, write_y=False)
¶
Gemma RMSNorm of x (+ residual) quantized for the next linear.
Parameters:
-
(x¶Tensor) –(num_tokens, hidden) bf16/fp16 activation, contiguous. Read only.
-
(residual¶Tensor | None) –same shape as x, or None. Updated in place to x + residual.
-
(weight¶Tensor) –(hidden,) Gemma norm weight; the norm scales by (1 + weight).
-
(eps¶float) –RMS norm epsilon.
-
(scale¶Tensor | None) –FP8: the static per-tensor input scale, or None for dynamic per-token FP8. NVFP4: the global scale (
input_global_scale_inv). -
(key¶QuantKey) –the consumer's input quant key: static per-tensor FP8, dynamic per-token FP8, or NVFP4 with swizzled 128x4 block scales.
-
(write_y¶bool, default:False) –also return the bf16 normed activation.
Returns:
-
Tensor–(q, block_scale, y): quantized data (fp8, or packed fp4 uint8), -
Tensor–NVFP4 block scales (fp8,
(round_up(M, 128), round_up(H // 16, 4)); -
Tensor | None–rows >= M are left unwritten),
scalefor static FP8 or the -
tuple[Tensor, Tensor, Tensor | None]–(M, 1)fp32 token scales for dynamic FP8, and the normed -
tuple[Tensor, Tensor, Tensor | None]–activation (or None).
Source code in vllm/models/qwen3_5/nvidia/ops/fused_norm_quant.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |