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
(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.
Functions:
-
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_quant(x, residual, weight, eps, scale, nvfp4, 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) –FP8: the static per-tensor input scale. NVFP4: the global scale (
input_global_scale_inv). -
(nvfp4¶bool) –quantize to NVFP4 with swizzled 128x4 block scales instead of static FP8.
-
(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) or
scalefor FP8, and the normed -
tuple[Tensor, Tensor, Tensor | None]–activation (or None).