Skip to content

[refactor] combine spmd parallelize into pp parallelize, with some other changes - #980

Merged
fegin merged 1 commit into
mainfrom
pp_refactor
Mar 19, 2025
Merged

fegin merged 1 commit into
mainfrom
pp_refactor

Conversation

@tianyu-l

@tianyu-l tianyu-l commented Mar 19, 2025 •

Copy link
Copy Markdown
Contributor

This PR does the following refactoring:

  1. combine spmd paralllize into pp parallelize -- now with a TrainSpec pipelining_fn is expected to call parallelize_fn inside. This is to allow for whole-model compile (which will come soon with a SimpleFSDP experiment). Also marking pipelining_fn as optional.
  2. update TrainSpec to use build_tokenizer_fn instead of tokenizer_cls, to facilitate use case like this.
  3. call import torchtitan.experiments in torchtitan/__init__.py, so that experiments can register TrainSpec and reuse torchtitan/train.py. This is the only place where torchtitan core would depend on experiments -- for now requiring experiments to be importable makes sense; we can revisit this assumption later.
  4. move LR scheduler code from optimizer.py into dedicated lr_scheduler.py given the complexity of both.
  5. create a new config section called parallelism to host all parallelism-related configs, and graduate experimental configs to parallelism as they have been introduced for a while.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 19, 2025
@tianyu-l
tianyu-l force-pushed the pp_refactor branch 2 times, most recently from d8409c8 to 9f72ed6 Compare March 19, 2025 03:10
@fegin
fegin merged commit 785c34c into main Mar 19, 2025
MaxiBoether pushed a commit to eth-easl/torchtitan-mixtera that referenced this pull request Apr 17, 2025
…her changes (pytorch#980)

This PR does the following refactoring:
1. combine spmd paralllize into pp parallelize -- now with a TrainSpec
`pipelining_fn` is expected to call `parallelize_fn` inside. This is to
allow for whole-model compile (which will come soon with a SimpleFSDP
experiment). Also marking `pipelining_fn` as optional.
2. update `TrainSpec` to use `build_tokenizer_fn ` instead of
`tokenizer_cls`, to facilitate use case like
[this](https://github.com/pytorch/torchtitan/pull/919/files#diff-f21036d57ee66cb8307ca425bdb94c54ce0e0fa7d7ca175e2f770b47ef1782ecR109-R111).
3. call `import torchtitan.experiments` in `torchtitan/__init__.py`, so
that experiments can register `TrainSpec` and reuse
`torchtitan/train.py`. This is the only place where torchtitan core
would depend on experiments -- for now requiring experiments to be
importable makes sense; we can revisit this assumption later.
4. move LR scheduler code from `optimizer.py` into dedicated
`lr_scheduler.py` given the complexity of both.
5. create a new config section called `parallelism` to host all
parallelism-related configs, and graduate `experimental` configs to
`parallelism` as they have been introduced for a while.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
…her changes (pytorch#980)

This PR does the following refactoring:
1. combine spmd paralllize into pp parallelize -- now with a TrainSpec
`pipelining_fn` is expected to call `parallelize_fn` inside. This is to
allow for whole-model compile (which will come soon with a SimpleFSDP
experiment). Also marking `pipelining_fn` as optional.
2. update `TrainSpec` to use `build_tokenizer_fn ` instead of
`tokenizer_cls`, to facilitate use case like
[this](https://github.com/pytorch/torchtitan/pull/919/files#diff-f21036d57ee66cb8307ca425bdb94c54ce0e0fa7d7ca175e2f770b47ef1782ecR109-R111).
3. call `import torchtitan.experiments` in `torchtitan/__init__.py`, so
that experiments can register `TrainSpec` and reuse
`torchtitan/train.py`. This is the only place where torchtitan core
would depend on experiments -- for now requiring experiments to be
importable makes sense; we can revisit this assumption later.
4. move LR scheduler code from `optimizer.py` into dedicated
`lr_scheduler.py` given the complexity of both.
5. create a new config section called `parallelism` to host all
parallelism-related configs, and graduate `experimental` configs to
`parallelism` as they have been introduced for a while.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
…her changes (pytorch#980)

This PR does the following refactoring:
1. combine spmd paralllize into pp parallelize -- now with a TrainSpec
`pipelining_fn` is expected to call `parallelize_fn` inside. This is to
allow for whole-model compile (which will come soon with a SimpleFSDP
experiment). Also marking `pipelining_fn` as optional.
2. update `TrainSpec` to use `build_tokenizer_fn ` instead of
`tokenizer_cls`, to facilitate use case like
[this](https://github.com/pytorch/torchtitan/pull/919/files#diff-f21036d57ee66cb8307ca425bdb94c54ce0e0fa7d7ca175e2f770b47ef1782ecR109-R111).
3. call `import torchtitan.experiments` in `torchtitan/__init__.py`, so
that experiments can register `TrainSpec` and reuse
`torchtitan/train.py`. This is the only place where torchtitan core
would depend on experiments -- for now requiring experiments to be
importable makes sense; we can revisit this assumption later.
4. move LR scheduler code from `optimizer.py` into dedicated
`lr_scheduler.py` given the complexity of both.
5. create a new config section called `parallelism` to host all
parallelism-related configs, and graduate `experimental` configs to
`parallelism` as they have been introduced for a while.
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.

3 participants