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
4 changes: 2 additions & 2 deletions src/paddlefleet/transformer/moe/moe_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def compute_combine(self, hidden_states, async_finish=False):

def aux_loss_compute(self, args):
hidden_states, aux_loss, residuals = args
if self.training and self.router_aux_loss_coef:
if self.training and self.router_aux_loss_coef > 0.0:
aux_loss = aux_loss * self.router_aux_loss_coef
output = AddAuxiliaryLoss.apply(hidden_states, aux_loss)

Expand Down Expand Up @@ -718,7 +718,7 @@ def forward(self, hidden_states: paddle.Tensor) -> paddle.Tensor:
reshaped_input, topk_indices, topk_weights
)

if self.training and self.router_aux_loss_coef:
if self.training and self.router_aux_loss_coef > 0.0:
aux_loss = aux_loss * self.router_aux_loss_coef
output = AddAuxiliaryLoss.apply(output, aux_loss)

Expand Down
2 changes: 1 addition & 1 deletion src/paddlefleet/transformer/moe/moe_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def forward(self, input):
self.expert_usage += exp_counts

# aux_loss
if self.config.router_aux_loss_coef:
if self.config.router_aux_loss_coef > 0.0:
if self.routing_type == "seq_aux_loss":
l_aux = self._cal_seq_aux_loss(
gates_ori,
Expand Down
Loading