-
Notifications
You must be signed in to change notification settings - Fork 594
remove scatter_add in MoE implementation #1974
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
Open
garrett361
wants to merge
12
commits into
pytorch:main
Choose a base branch
from
garrett361:moe-bmm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
853d0bf
remove scatter_add
garrett361 41125e1
lint
garrett361 51f59d8
reset moe.py to minimize diff
garrett361 66b67ed
minimze diff
garrett361 b5f651a
minor edit
garrett361 2aa866b
clean up MoE
garrett361 e395a68
rm testing/dev files
garrett361 df60297
rm comment
garrett361 af76834
typo fix
garrett361 d3f56de
comment shape fix
garrett361 1c3cc87
comment consolidation
garrett361 ee2e8cc
top_k in reshapes, not bs*slen
garrett361 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm please educate me more here:
From Python level this might save memory, but wouldn't the
routed_inputactivations be saved by the autograd engine anyways?Are you observing meaningful savings? If not, I'd wish we separate the concern and focus on run-to-run determinism in this PR.
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.
The comment is probably overly-terse, and also maybe I'm just wrong?
The comment is in reference to an alternative implementation where we do something like:
or
The clone is needed in the second case, because otherwise
routed_output[token_indices_experts_sorted] = routed_outputleads toWhich is what I initially tried.
So the point here is about avoiding a
cloneorempty_likeor other similar call that would cause a new allocation.For training, both
routed_inputandrouted_outputare surely in the computational graph still: this doesn't avoid that.LMK if I'm wrong in any of the above, and if you want code or comment changes or any profiling of the different options here.