Skip to content

[spmd_types] fix MoE sequence-sharded combine - #3664

Merged
pianpwk merged 100 commits into
mainfrom
gh/pianpwk/39/head
Jun 26, 2026
Merged

pianpwk merged 100 commits into
mainfrom
gh/pianpwk/39/head

Conversation

@pianpwk

@pianpwk pianpwk commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Fix spmd_types SP-padding support, by requiring evenly sharded seq-dim for MoE input activations, calculating post-combine output size based on local tensor shapes.

Raises in trainer for MoE + uneven seq-dim sharding.

Stack from ghstack (oldest at bottom):

pianpwk added 2 commits June 13, 2026 21:06
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 2 commits June 15, 2026 00:01
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 10 commits June 15, 2026 10:18
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Jun 16, 2026
ghstack-source-id: 8cb1e19
Pull Request resolved: pytorch/torchtitan#3664
pianpwk added 2 commits June 16, 2026 14:48
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 22 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]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 2 commits June 25, 2026 18:38
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added a commit that referenced this pull request Jun 26, 2026
`set_current_spmd_mesh(sparse_mesh)` transitions for MoE region, spmd.all_to_all switch, plus
mesh reinterprets, assert_type, mutate_type

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* #3740
* #3690
* #3673
* #3655
* #3741
* #3664
* __->__ #3654
@pianpwk
pianpwk changed the base branch from gh/pianpwk/39/base to main June 26, 2026 02:12
@pianpwk
pianpwk merged commit 565cb81 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
Teach MoE combine to derive its padded token count from local batch size and local sequence length, and make the spmd_types dense-SP path use the already-local sequence length instead of recomputing from a global shape.

Test Plan:

- PYTHONPATH=/data/users/pianpwk/full_spmd_types_torchtitan/pytorch:/data/users/pianpwk/full_spmd_types_torchtitan/tt4_spmd_types/torchtitan:/data/users/pianpwk/spmd_types /home/pianpwk/.conda/envs/full_spmd_tt/bin/python -m py_compile torchtitan/models/common/moe.py torchtitan/models/common/moe_sharding.py torchtitan/models/common/token_dispatcher.py torchtitan/models/gpt_oss/moe.py

- git diff --check -- torchtitan/models/common/moe.py torchtitan/models/common/moe_sharding.py torchtitan/models/common/token_dispatcher.py torchtitan/models/gpt_oss/moe.py

- spmd_types Qwen3 MoE 8-GPU sweep with --debug.spmd_typechecking, SP on/off, CP on/off, FSDP, plus SP-off/CP-off inference-simulation config; all passed with activation-checkpoint:none

Pull Request resolved: pytorch/torchtitan#3664
ghstack-source-id: 0f5618e
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.

3 participants