Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/pytorch/test_grouped_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ def test_grouped_mlp_glu_mxfp8_real_cudnn_fusion(
"a_dtype": torch.float8_e4m3fn,
"b_dtype": torch.float8_e4m3fn,
"alpha_dtype": torch.bfloat16,
"prob_dtype": torch.bfloat16,
"prob_dtype": torch.float32,
"c_dtype": torch.bfloat16,
"d_dtype": torch.float8_e4m3fn,
"act_func": act_func,
Expand Down
13 changes: 5 additions & 8 deletions transformer_engine/pytorch/ops/fused/grouped_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,11 +1589,11 @@ def fuser_forward(

fc1_prob_tensor = None
if not unit_activation_scale:
fc1_prob_tensor = (
scales.detach()
.to(dtype=torch.float32 if use_nvfp4 else dtype)
.reshape((-1,) if canonical else (-1, 1, 1))
)
fc1_prob_tensor = scales.detach().reshape((-1,) if canonical else (-1, 1, 1))
if use_nvfp4:
# cuDNN NVFP4 kernel only accepts fp32 scales.
fc1_prob_tensor = fc1_prob_tensor.to(torch.float32)

if use_nvfp4:
# cuDNN receives NVFP4 block-scaled inputs without TE's per-group
# global scale factors, so alpha supplies the product of the two
Expand Down Expand Up @@ -2701,9 +2701,6 @@ def fuser_backward(
else:
fc2_bias_grads = [fc2_dbias_packed[idx] for idx in range(num_groups)]

if grad_scales is not None:
grad_scales = grad_scales.to(dtype=dtype)

fc1_bias_grads: Optional[list[Optional[torch.Tensor]]] = None
fc1_bias_grad_packed: Optional[torch.Tensor] = None
if fc1_op.has_bias:
Expand Down
Loading