-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SwitchTransformers
] Fix return values
#24300
Conversation
encoder_router_logits, encoder_expert_indexes = self._unpack_router_logits( | ||
encoder_outputs.router_probs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoder_outputs.router_probs
cannot be accessed if return_dict = False
*decoder_outputs[1:], | ||
*encoder_outputs, | ||
) | ||
else: | ||
output += (*decoder_outputs[1:], *encoder_outputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reduce used lines
@@ -1736,18 +1723,18 @@ def forward( | |||
decoder_hidden_states=decoder_outputs.hidden_states, | |||
decoder_attentions=decoder_outputs.attentions, | |||
cross_attentions=decoder_outputs.cross_attentions, | |||
decoder_router_logits=decoder_outputs.router_probs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make order of return consistent with tuples
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes!
What does this PR do?
The previous version of the code would always return
None
values for the router losses, since theif output_router_probs
was wrapper aroundif labels is not None
. But router logits can still be computed wthout labels.Also returns tensors instead of None, this follows our usual API, and is less prone to errors.