Apply torchfix (#15532)

Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
cyyever
2025-03-26 12:09:06 +00:00
committed by GitHub
parent cf5c8f1686
commit 1aa162e030
5 changed files with 15 additions and 11 deletions
+3 -3
View File
@@ -63,8 +63,8 @@ def _cast_if_autocast_enabled(*args):
if not torch.is_autocast_enabled():
return args
else:
return torch.cuda.amp.autocast_mode._cast(
args, torch.get_autocast_gpu_dtype())
return torch.amp.autocast_mode._cast(
args, device_type="cuda", dtype=torch.get_autocast_gpu_dtype())
class NemotronLayerNorm1P(nn.LayerNorm):
@@ -89,7 +89,7 @@ class NemotronLayerNorm1P(nn.LayerNorm):
residual = x
args = _cast_if_autocast_enabled(x, self.normalized_shape,
self.weight + 1, self.bias, self.eps)
with torch.cuda.amp.autocast(enabled=False):
with torch.amp.autocast("cuda", enabled=False):
x = torch.nn.functional.layer_norm(*args)
return x if residual is None else (x, residual)