Skip to content

Implicit overlap of shared expert compute and token combine communication - #1741

Merged
mreso merged 1 commit into
mainfrom
mreso/shared_expert_token_combine_overlap
Sep 23, 2025
Merged

mreso merged 1 commit into
mainfrom
mreso/shared_expert_token_combine_overlap

Conversation

@mreso

@mreso mreso commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

This PR moves the computation of the shared expert before the possible scoring of the routed expert output which leads to an implicit overlap between shared expert compute and token combine communication in MoE models.

Repro (lowered the layer number to 2):

CONFIG_FILE="./torchtitan/models/deepseek_v3/train_configs/deepseek_v3_16b.toml" ./run_train.sh --profiling.enable_profiling --profiling.profile_freq 10  --training.steps 10 

Trace before the change:
Screenshot 2025-09-23 at 12 08 31 AM

Trace after the change (note that all-to-all comm is now overlapping shared expert compute):
Screenshot 2025-09-23 at 12 04 56 AM

cc @tianyu-l @xmfan

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 23, 2025
@mreso
mreso requested a review from xmfan September 23, 2025 07:27

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Error seems unrelated.

@mreso
mreso merged commit 476a965 into main Sep 23, 2025
@facebook-github-bot

Copy link
Copy Markdown

@mreso has imported this pull request. If you are a Meta employee, you can view this in D83064257.

@tianyu-l
tianyu-l deleted the mreso/shared_expert_token_combine_overlap branch September 23, 2025 17:12
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
…tion (pytorch#1741)

This PR moves the computation of the shared expert before the possible
scoring of the routed expert output which leads to an implicit overlap
between shared expert compute and token combine communication in MoE
models.

Repro (lowered the layer number to 2):
```
CONFIG_FILE="./torchtitan/models/deepseek_v3/train_configs/deepseek_v3_16b.toml" ./run_train.sh --profiling.enable_profiling --profiling.profile_freq 10  --training.steps 10 
``` 
Trace before the change:
<img width="1503" height="625" alt="Screenshot 2025-09-23 at 12 08
31 AM"
src="https://github.com/user-attachments/assets/bbcc41cf-6497-482e-972e-d917baf4498e"
/>

Trace after the change (note that all-to-all comm is now overlapping
shared expert compute):
<img width="1503" height="625" alt="Screenshot 2025-09-23 at 12 04
56 AM"
src="https://github.com/user-attachments/assets/3504e77c-aa14-46fd-8e47-e247b88d7b9c"
/>

cc @tianyu-l @xmfan
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
…tion (pytorch#1741)

This PR moves the computation of the shared expert before the possible
scoring of the routed expert output which leads to an implicit overlap
between shared expert compute and token combine communication in MoE
models.

Repro (lowered the layer number to 2):
```
CONFIG_FILE="./torchtitan/models/deepseek_v3/train_configs/deepseek_v3_16b.toml" ./run_train.sh --profiling.enable_profiling --profiling.profile_freq 10  --training.steps 10 
``` 
Trace before the change:
<img width="1503" height="625" alt="Screenshot 2025-09-23 at 12 08
31 AM"
src="https://github.com/user-attachments/assets/bbcc41cf-6497-482e-972e-d917baf4498e"
/>

Trace after the change (note that all-to-all comm is now overlapping
shared expert compute):
<img width="1503" height="625" alt="Screenshot 2025-09-23 at 12 04
56 AM"
src="https://github.com/user-attachments/assets/3504e77c-aa14-46fd-8e47-e247b88d7b9c"
/>

cc @tianyu-l @xmfan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants