[ROCm] Fix AITER all-reduce fusion coverage (#50802)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
Andreas Karatzas
2026-08-06 14:52:23 +08:00
committed by GitHub
parent 5370461649
commit 7e724dca89
2 changed files with 93 additions and 44 deletions
@@ -1245,6 +1245,34 @@ class AiterAllreduceFusedAddRMSNormPattern(BasePattern, VllmPatternReplacement):
return _replacement
class AiterAllreduceFusedAddRMSNormOutputOnlyPattern(
AiterAllreduceFusedAddRMSNormPattern
):
"""Match the add-RMSNorm form when its residual output is dead."""
@property
def pattern(self):
pattern = super().pattern
def _pattern(
residual: torch.Tensor, input: torch.Tensor, weight: torch.Tensor
) -> torch.Tensor:
return pattern(residual, input, weight)[0]
return _pattern
@property
def replacement(self):
replacement = super().replacement
def _replacement(
residual: torch.Tensor, input: torch.Tensor, weight: torch.Tensor
) -> torch.Tensor:
return replacement(residual, input, weight)[0]
return _replacement
class AiterAllreduceFusedRMSNormGroupQuantFP8Pattern(
BasePattern, VllmPatternReplacement
):
@@ -1624,6 +1652,13 @@ class RocmAiterAllReduceFusionPass(VllmFusionPatternMatcherPass):
self.device,
)
)
self.register(
AiterAllreduceFusedAddRMSNormOutputOnlyPattern(
epsilon,
self.model_dtype,
self.device,
)
)
# WARNING: This is a hack to clear the pattern matcher cache
# and allow multiple values of epsilon.