Skip to content
Open
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
9 changes: 9 additions & 0 deletions nemo_automodel/components/moe/experts.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ def forward(
else None
)

# Match activation dtype for grouped_mm; covers the case where FSDP2's
# MixedPrecisionPolicy does not reach EP DTensors.
gate_and_up_projs = gate_and_up_projs.to(x.dtype)
down_projs = down_projs.to(x.dtype)

# EP variable-length all-gather
if ep_size > 1:
ep_group = ep_mesh.get_group()
Expand Down Expand Up @@ -688,6 +693,10 @@ def forward(
gate_and_up_projs = self.gate_and_up_projs.to_local()
down_projs = self.down_projs.to_local()

# Match activation dtype for grouped_mm; see GroupedExperts.forward.
gate_and_up_projs = gate_and_up_projs.to(permuted_local_hidden_states.dtype)
down_projs = down_projs.to(permuted_local_hidden_states.dtype)

if torch.count_nonzero(tokens_per_expert) > 0:
if self.use_torch_mm:
tokens_per_expert_gpu = tokens_per_expert.to(
Expand Down
Loading