-
Notifications
You must be signed in to change notification settings - Fork 904
feat: article exploring ways to compute MoE #3038
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
base: main
Are you sure you want to change the base?
Conversation
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.
TIL! 💗
|
||
# Three MoEs | ||
|
||
Three Ways to Compute Mixture of Experts (MoE) in PyTorch |
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.
might be nice to put this on the title
|
||
Three Ways to Compute Mixture of Experts (MoE) in PyTorch | ||
|
||
Mixture of Experts (MoE) looks complex, but under the hood it’s just: |
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.
perhaps link to this blog so people have more initial context https://huggingface.co/blog/moe
|
||
## Step 1: Routing | ||
|
||
Every token chooses its top-k experts with softmaxed scores. |
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.
would be nice to give just a little bit more context
2. Apply MLPs (one per expert). | ||
3. Recombine outputs with routing weights. | ||
|
||
Below are **three ways** to compute MoE in PyTorch — from simple to complex. |
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.
Below are **three ways** to compute MoE in PyTorch — from simple to complex. | |
Below are **three ways** to build MoEs in PyTorch — from simple to complex. |
Quick test: | ||
|
||
```python | ||
hs = torch.randn(B, S, H) |
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.
very nice to have simple reproducible snippets, would be nice to put these into a notebook and link at the end so people don't have to copy paste to try
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.
in general let's avoid single letter variable names and find meaningful ones!
This article explores three different ways to compute MoE and focuses on the "how" of MoE