Skip to content

[spmd_types] add parallelism.spmd_backend config - #3466

Merged
pianpwk merged 13 commits into
mainfrom
gh/pianpwk/17/head
Jun 6, 2026
Merged

pianpwk merged 13 commits into
mainfrom
gh/pianpwk/17/head

Conversation

@pianpwk

@pianpwk pianpwk commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

The initial thought for spmd_types + titan was to kill the legacy & full_dtensor paths at once. As managing that became harder (lots of bitwise configs, ongoing model/full_dtensor work), we settled on having it as a 3rd path in the short-term, under parallelism.spmd_backend: Literal["default", "full_dtensor", "spmd"] = "default"

This PR just adds the flag and modifies existing uses of .full_dtensor, banning spmd backend until it's enabled.

Stack from ghstack (oldest at bottom):

pianpwk added 2 commits May 31, 2026 16:22
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added 2 commits June 1, 2026 13:11
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk pianpwk changed the title Add SPMD backend selector [spmd_types] add parallelism.spmd_backend config Jun 1, 2026
@pianpwk
pianpwk marked this pull request as ready for review June 1, 2026 20:18
Comment thread torchtitan/config/configs.py Outdated

full_dtensor: bool = False
"""Whether to use full DTensor mode."""
spmd_backend: Literal["default", "full_dtensor", "spmd"] = "default"

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.

Suggested change
spmd_backend: Literal["default", "full_dtensor", "spmd"] = "default"
spmd_backend: Literal["default", "full_dtensor", "spmd_types"] = "default"

Comment thread torchtitan/config/configs.py Outdated

- "default": use the existing TorchTitan parallelism paths.
- "full_dtensor": use the existing full DTensor path.
- "spmd": use the new local-tensor SPMD path.

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.

just say spmd_types

it's not only about "local-tensor"

Comment thread torchtitan/config/configs.py Outdated
"""Choose the base RNG seed used for training"""

spmd_typechecking: bool = False
"""Enable global SPMD type checking for the local-tensor SPMD backend."""

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.

say something like

  • only effective under spmd_backend=="spmd_types"

pianpwk added 2 commits June 3, 2026 15:43
[ghstack-poisoned]
[ghstack-poisoned]

@fegin fegin 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, but I think we should consider to use StrEnum in the future.

pianpwk added 2 commits June 5, 2026 09:54
[ghstack-poisoned]
[ghstack-poisoned]
pianpwk added a commit that referenced this pull request Jun 5, 2026
Adds the spmd_types integration to titan part-by-part, starting from
replacing the `torch.distributed.tensor.parallel.loss_parallel()`
DTensor-based context manager with a manually written
`_LossParallelCrossEntropy` custom autograd function.

Written to support uneven sharding (on last rank), IGNORE_INDEX,
verified bitwise against loss_parallel() in test cases. The PR adds
spmd_types requirement to titan, as it includes typecheck_forward &
testing.

Not yet wired into the training path - the later stack will wire it for
the spmd backend path, but likely leaves DTensor & plain-tensor on the
loss_parallel() path for now.

Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* #3551
* #3550
* #3278
* #3472
* #3468
* #3471
* #3253
* #3501
* #3466
* __->__ #3467
pianpwk added 2 commits June 5, 2026 14:42
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk
pianpwk requested a review from IvanKobzarev as a code owner June 5, 2026 21:42
@pianpwk
pianpwk changed the base branch from gh/pianpwk/17/base to main June 5, 2026 21:42
[ghstack-poisoned]
@pianpwk
pianpwk changed the base branch from main to gh/pianpwk/17/base June 5, 2026 22:16
@pianpwk
pianpwk changed the base branch from gh/pianpwk/17/base to main June 5, 2026 22:17
@pianpwk
pianpwk changed the base branch from main to gh/pianpwk/17/base June 6, 2026 18:46
pianpwk added 2 commits June 6, 2026 11:46
[ghstack-poisoned]
[ghstack-poisoned]
@pianpwk
pianpwk changed the base branch from gh/pianpwk/17/base to main June 6, 2026 18:47
@pianpwk
pianpwk merged commit 641b5f6 into main Jun 6, 2026
14 checks passed
saforem2 added a commit to saforem2/torchtitan that referenced this pull request Jun 7, 2026
…tor still TODO

Documents the 34-commit pull from upstream/main (27aa490..641b5f6,
merge commit fb1c5a3, sitting in worktree ezpz-46th-47th-sync).
Two structural refactors hit ezpz:

  - PR pytorch#3458 (RoPE refactor): REPLAYED in commit 02dd1e7, verified
    by importing + building all agpt + moe flavors under the torch
    2.13 venv. Numerics smoke against baselines still pending.
  - PR pytorch#3269 (mixed-optimizer refactor): NOT YET STARTED. Affects
    OptimizersContainer.Config + 8 custom container subclasses in
    optimizer/containers.py + ~13 callsites in agpt/moe/competition
    config registries.

Also documents that spmd_types==0.2.1 was installed into .venv (new
upstream runtime dep from PR pytorch#3466/pytorch#3467/pytorch#3560) and notes the open
follow-ups (replay PR pytorch#3269, smoke against baselines, audit RL).

Doesn't update upstream-sync.md's "next-sync" reminder banner —
this sync isn't complete yet (ezpz branch is not on the worktree
HEAD).
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