[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:
1 parent
e823f0d909
commit
965ad68f1d
7 files changed
+172
-43
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user