-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Removed unnecessary transpose in Switch Transformer Routing #33582
Removed unnecessary transpose in Switch Transformer Routing #33582
Conversation
Thanks for the PR @karan-uppal3 ! cc @ArthurZucker when you have a second |
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.
Hey! We have run heavy integration tests here:
transformers/tests/models/switch_transformers/test_modeling_switch_transformers.py
Line 902 in f83917e
class SwitchTransformerRouterTest(unittest.TestCase): |
Could you make sure they are either:
- wrong (meaning the output we have today are just wrong)
- right (meaning this does not influence the output)
Otherwise, makes sense and quite supprised that we did not catch this before 😢
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Hey @ArthurZucker! I went through the tests and found unit tests for the |
Did you run the tests with transformers/tests/models/switch_transformers/test_modeling_switch_transformers.py Line 1033 in 21beb57
|
Hey @ArthurZucker, I just ran the tests with
|
Cool! Tested locally as well the skipped tests (generation ones) not affected |
thanks! |
…ace#33582) removed switch transformer routing transpose
What does this PR do?
There is an additional transpose operation at link in the Switch Transformer Implementation. The shape of the tensor is [batch_size, seq_len, num_experts] which undergoes
.transpose(1,2)
to get the shape [batch_size, num_experts, seq_len], which is later.reshape(batch_size * seq_len, num_experts)
. Due to thetranspose
the routing gives incorrect results. Simply removing the.transpose(1,2)
gives the correct output. A simple reproducible example can be found at #33463.Fixes #33463
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@LysandreJik @ArthurZucker @younesbelkada