[Kernel][MammothModa2] Use shared RMSNorm in the DiT (#7489)

Signed-off-by: Jerry Xu <xjr2423@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jierui (Jerry) XuandClaude Opus 5 authored and GitHub committed 2026-09-29 00:12:16 +08:00
1 parent e823f0d909
commit 965ad68f1d
7 files changed
+172 -43

No files matched your search

+2 -16
View File
@@ -93,22 +93,8 @@ class RMSNorm(CustomOp):
# (returns None) and accesses self.weight.data, which is a DTensor under
# HSDP. Both patterns confuse inductor's compute_ancestors scheduler.
# Fall back to forward_native so inductor can fuse the pure-PyTorch ops
# itself.
if torch.compiler.is_compiling():
return self.forward_native(x)
try:
return self._forward_fused(x)
except Exception:
return self.forward_native(x)
def forward_hip(
self,
x: torch.Tensor,
residual: torch.Tensor | None = None,
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
if residual is not None:
return self.forward_native(x, residual)
if torch.compiler.is_compiling():
# itself. The fused kernel also cannot launch on an empty tensor.
if torch.compiler.is_compiling() or x.numel() == 0:
return self.forward_native(x)
try:
return self._forward_fused(x)