Skip to content

[spmd_types] MoE sparse mesh transitions - #3654

Merged
pianpwk merged 94 commits into
mainfrom
gh/pianpwk/37/head
Jun 26, 2026
Merged

pianpwk merged 94 commits into
mainfrom
gh/pianpwk/37/head

Conversation

@pianpwk

@pianpwk pianpwk commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

pianpwk added 2 commits June 13, 2026 01:26
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 2 commits June 15, 2026 00:01
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk pianpwk changed the title Set sparse SPMD mesh for token dispatch [spmd_types] MoE sparse mesh transitions Jun 15, 2026
pianpwk added 4 commits June 15, 2026 10:18
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk
pianpwk marked this pull request as ready for review June 15, 2026 20:15
pianpwk added 4 commits June 15, 2026 23:54
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines +323 to +324
num_local_tokens_per_expert_E = spmd.reinterpret_mesh(
num_local_tokens_per_expert_E, spmd.current_mesh()

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.

is this no-op in erasure mode?


with torch.no_grad():
if use_spmd_types:
num_local_tokens_per_expert_EP_e = (

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.

Technically this naming is breaking convention, which is "a single letter means one tensor dim; among multiple letters there's no _".

https://github.com/pytorch/torchtitan/blob/main/torchtitan/models/common/moe.py#L21

If we don't want to introduce another letter just for "EP", this temporary violation sounds fine. But please comment explicitly.

num_local_tokens_per_expert_EP_e = (
num_local_tokens_per_expert_E.view(ep_size, -1)
)
num_global_tokens_per_local_expert_EP_e = spmd.all_to_all(

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.

I guess the if-else is because DTensor doesn't support spmd collectives?

pianpwk added 2 commits June 25, 2026 09:28
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 18 commits June 25, 2026 10:16
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk
pianpwk changed the base branch from gh/pianpwk/37/base to main June 26, 2026 01:35
@pianpwk
pianpwk changed the base branch from main to gh/pianpwk/37/base June 26, 2026 01:36
pianpwk added 2 commits June 25, 2026 18:38
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk
pianpwk changed the base branch from gh/pianpwk/37/base to main June 26, 2026 02:09
@pianpwk
pianpwk merged commit b052f36 into main Jun 26, 2026
9 of 11 checks passed
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu 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.

2 participants