Skip to content
Merged
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion megatron/core/transformer/moe/moe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ def switch_load_balancing_loss_func(
return aux_loss


def z_loss_func(logits, z_loss_coeff):
def z_loss_func(logits: torch.Tensor, z_loss_coeff: float):
Comment thread
yaox12 marked this conversation as resolved.
Outdated
"""Encourages the router's logits to remain small to enhance stability.
Please refer to the ST-MoE paper (https://arxiv.org/pdf/2202.08906.pdf) for details.

Args:
logits (torch.Tensor): The logits of the router.
z_loss_coeff (float): The coefficient for the z-loss.

Returns:
torch.Tensor: The logits after applying the z-loss.
Expand Down