Skip to content

Commit

Permalink
- Adds a flag to check whether to return moe losses in SequentialWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Shetano committed Feb 7, 2025
1 parent f7a5a6f commit b1e3a7d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions megatron/model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def train_mode(self):
recursive_setattr(self.sequential, "training", True)

def forward(
self, forward_input, curriculum_seqlen=None, labels=None, neox_args=None
self, forward_input, curriculum_seqlen=None, labels=None, neox_args=None, return_moe_losses=False
):

if self.batch_fn:
Expand Down Expand Up @@ -212,7 +212,10 @@ def exec_func(*inputs):
)
else:
x = exec_range_func(start_idx, end_idx)(*x)
return x, moe_losses
if return_moe_losses:
return x, moe_losses
else:
return x

def clear_cache(self):
"""
Expand Down

0 comments on commit b1e3a7d

Please sign in to comment.