[ROCm] Fix AITER all-reduce fusion coverage (#50802)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user