vllm.compilation.passes.fusion.allreduce_rms_fusion
¶
Classes:
-
AiterAllreduceFusedAddGemmaRMSNormOutputOnlyPattern–Match fused-add GemmaRMSNorm when its residual output is dead.
-
AiterAllreduceFusedAddGemmaRMSNormPattern–Match all-reduce followed by fused-add GemmaRMSNorm.
-
AiterAllreduceFusedAddRMSNormGroupQuantFP8Pattern–fused_addvariant ofAiterAllreduceFusedRMSNormGroupQuantFP8Pattern. -
AiterAllreduceFusedAddRMSNormGroupQuantWithIndexerPattern–Indexer-fan-out variant of
AiterAllreduceFusedAddRMSNormGroupQuantFP8Pattern. -
AiterAllreduceFusedAddRMSNormOutputOnlyPattern–Match the add-RMSNorm form when its residual output is dead.
-
AiterAllreduceFusedGemmaRMSNormPattern–Match all-reduce followed by GemmaRMSNorm without a residual.
-
AiterAllreduceFusedRMSNormGroupQuantFP8Pattern–Fuse AllReduce + RMSNorm + per-group FP8 quant into a single AITER
-
AllReduceFusedAddGemmaRMSNormPattern–Gemma-style variant of AllReduceFusedAddRMSNormPattern (with residual).
-
AllReduceFusedAddRMSNormPattern–This pattern replaces the allreduce + rms norm (with residual)
-
AllReduceFusedAddRMSNormStaticQuantFP8Pattern–This pattern replaces the allreduce + rms norm (with residual)
-
AllReduceFusedAddRMSNormStaticQuantNVFP4Pattern–This pattern replaces the allreduce + rms norm (with residual)
-
AllReduceFusedRMSNormStaticQuantFP8Pattern–This pattern replaces the allreduce + rms norm (without residual)
-
AllReduceFusedRMSNormStaticQuantNVFP4Pattern–This pattern replaces the allreduce + rms norm (without residual)
-
AllReduceGemmaRMSNormPattern–Gemma-style variant of AllReduceRMSNormPattern (no residual).
-
AllReduceRMSNormPattern–This pattern replaces the allreduce + rms norm (without residual)
-
FlashInferFusedAllReduceParams–Parameters for FlashInfer fused allreduce operations.
AiterAllreduceFusedAddGemmaRMSNormOutputOnlyPattern
¶
Bases: AiterAllreduceFusedAddRMSNormOutputOnlyPattern
Match fused-add GemmaRMSNorm when its residual output is dead.
AiterAllreduceFusedAddGemmaRMSNormPattern
¶
Bases: AiterAllreduceFusedAddRMSNormPattern
Match all-reduce followed by fused-add GemmaRMSNorm.
AiterAllreduceFusedAddRMSNormGroupQuantFP8Pattern
¶
Bases: BasePattern, VllmPatternReplacement
fused_add variant of AiterAllreduceFusedRMSNormGroupQuantFP8Pattern.
Targets the dominant DSv3.2-style post-attention / post-MLP path:
all_reduce -> fused_add_rms_norm -> group_fp8_quant. Returns the
FP8 quant output, the residual carry-over, and the per-group scale.
AiterAllreduceFusedAddRMSNormGroupQuantWithIndexerPattern
¶
Bases: BasePattern, VllmPatternReplacement
Indexer-fan-out variant of AiterAllreduceFusedAddRMSNormGroupQuantFP8Pattern.
Targets the DSv3.2 post-attention / post-MLP path where the post-AR normed
activation has two consumers: a per-group FP8 quant for fused_qkv_a_proj
and a bf16 rocm_unquantized_gemm for the indexer wk_weights_proj.
The single-consumer pattern above cannot fire when this fan-out is present,
so without this pattern the standalone FP8 quant kernel survives unfused
(~535us / decode step on DSv3.2 MI355X TP4).
Lowers to rocm_aiter_fused_allreduce_rmsnorm_quant_per_group_with_bf16_norm
(the emit_bf16=True variant of the AR+RMS+QUANT launcher, which returns
FP8 quant + scales + bf16 normed activations in one kernel) and rewires the
indexer GEMM onto the emitted bf16 norm output. The RMS output is also a
graph output in DSv3.2's residual carry; it is returned as a pattern output
so the matcher can substitute the bf16 norm in its place.
The trailing FP8 group-quant is matched via MatcherQuantFP8 (consistent
with the sibling patterns above), which traces both QuantFP8.forward_hip
and forward_native paths and so matches whichever op the call site
lowers to (vllm.rocm_aiter_group_fp8_quant).
AiterAllreduceFusedAddRMSNormOutputOnlyPattern
¶
Bases: AiterAllreduceFusedAddRMSNormPattern
Match the add-RMSNorm form when its residual output is dead.
AiterAllreduceFusedGemmaRMSNormPattern
¶
Bases: AiterAllreduceFusedRMSNormPattern
Match all-reduce followed by GemmaRMSNorm without a residual.
AiterAllreduceFusedRMSNormGroupQuantFP8Pattern
¶
Bases: BasePattern, VllmPatternReplacement
Fuse AllReduce + RMSNorm + per-group FP8 quant into a single AITER custom op.
Matches the AR-side analogue of AiterRMSFp8GroupQuantPattern in
rocm_aiter_fusion.py: all_reduce -> rms_norm -> group_fp8_quant
fans out into rocm_aiter_fused_allreduce_rmsnorm_quant_per_group.
Without this pattern, RocmAiterAllReduceFusionPass would fuse the
all_reduce + rms_norm half (PR #41825 wires that), but the trailing
rocm_aiter_group_fp8_quant would still launch as a separate kernel.
That standalone quant accounts for ~535us / decode step on DSv3.2 MI355X
TP4 -- this pattern eliminates it by absorbing the quant into the AR
epilogue. Group size 128 matches the FP8 block-scaled MM kernel used by
DSv3.2's linear weights.
AllReduceFusedAddGemmaRMSNormPattern
¶
Bases: BasePattern
Gemma-style variant of AllReduceFusedAddRMSNormPattern (with residual).
AllReduceFusedAddRMSNormPattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (with residual) with fused flashinfer implementation. Applies to o_proj + rmsnorm after attn and mlp + rmsnorm before attn.
AllReduceFusedAddRMSNormStaticQuantFP8Pattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (with residual) + static fp8 quant with fused flashinfer implementation. Applies to o_proj + rmsnorm after attn + quant and mlp + rmsnorm + quant before attn.
AllReduceFusedAddRMSNormStaticQuantNVFP4Pattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (with residual) + static nvfp4 quant with fused flashinfer implementation. Applies to o_proj + rmsnorm after attn + quant and mlp + rmsnorm + quant before attn.
AllReduceFusedRMSNormStaticQuantFP8Pattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (without residual) + static fp8 quant with fused flashinfer implementation. Applies to allreduce + rmsnorm + quant before attn in the first Transformer block.
AllReduceFusedRMSNormStaticQuantNVFP4Pattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (without residual) + static nvfp4 quant with fused flashinfer implementation. Applies to allreduce + rmsnorm + quant before attn in the first Transformer block.
AllReduceGemmaRMSNormPattern
¶
Bases: BasePattern
Gemma-style variant of AllReduceRMSNormPattern (no residual).
AllReduceRMSNormPattern
¶
Bases: BasePattern
This pattern replaces the allreduce + rms norm (without residual) with fused flashinfer implementation. Applies to allreduce + rmsnorm before attn in the first Transformer block.
FlashInferFusedAllReduceParams
¶
Parameters for FlashInfer fused allreduce operations.
_fused_ar_workspace_hidden_dim(config)
¶
Widest hidden size across the target and (optional) draft models.
The FlashInfer allreduce+RMSNorm workspace is a process-global singleton created eagerly at pass construction and reused by every model. Under speculative decoding the draft shares it, so it must fit the larger of the two hidden sizes; a draft wider than the target otherwise overflows the target-sized buffer (vLLM #52023).
_norm_input_weight_dtype_match(match)
¶
Prevent fusion when the norm input and weight dtypes differ (e.g. a Gemma fp32 weight.float()+1 gamma), covering rms_norm and fused_add_rms_norm.
_view_flashinfer_nvfp4_scale_out_as_int32(scale_out)
¶
View FlashInfer's NVFP4 scale buffer back as vLLM's int32 format.
_view_nvfp4_scale_out_for_flashinfer(scale_out)
¶
View vLLM's packed NVFP4 scale buffer as FP8 for FlashInfer.