Skip to content

Deduplicate TorchTitan main function - #1995

Merged
fegin merged 7 commits into
mainfrom
gh/fegin/25/head
Nov 7, 2025
Merged

fegin merged 7 commits into
mainfrom
gh/fegin/25/head

Conversation

@fegin

@fegin fegin commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

People are creating different train.py and duplicate the main function. But in realitly people just want to use different Trainer subclasses. This PR creates a main() in torchtitan/train.py to deduplicate the code.

fegin added 2 commits November 5, 2025 14:15
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Nov 5, 2025
People are creating different train.py and duplicate the `main` function. But in realitly people just want to use different Trainer subclasses. This PR creates a main() in torchtitan/train.py to deduplicate the code.


ghstack-source-id: 2b3b9ac
Pull-Request: #1995
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 5, 2025

@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.

nice!

fegin added 2 commits November 6, 2025 23:28
[ghstack-poisoned]
[ghstack-poisoned]
fegin added 2 commits November 6, 2025 23:34
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Nov 7, 2025
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* #2002
* #2001
* #1995
* __->__ #1985

We are adding more actions to convert the raw inputs and label.

1. The new CP can do the input/label/BlockMask sharding this in this
method.
2. The experimental full dtensor model can simply override this method
without changing too many Trainer code.

This method is extracted from
#1857

Makeing this a standalone PR allows us to continue the two projects
above without one blocks another.
[ghstack-poisoned]
@fegin
fegin changed the base branch from gh/fegin/25/base to main November 7, 2025 18:52
@fegin
fegin merged commit 4caa379 into main Nov 7, 2025
jquesnelle pushed a commit to NousResearch/torchtitan that referenced this pull request Nov 10, 2025
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* pytorch#1995
* __->__ pytorch#1985

We are adding more actions to convert the raw inputs and label.

1. The new CP can do the input/label/BlockMask sharding this in this
method.
2. The experimental full dtensor model can simply override this method
without changing too many Trainer code.

This method is extracted from
pytorch#1857

Makeing this a standalone PR allows us to continue the two projects
above without one blocks another.
jquesnelle pushed a commit to NousResearch/torchtitan that referenced this pull request Nov 10, 2025
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* __->__ pytorch#1995

People are creating different train.py and duplicate the `main`
function. But in realitly people just want to use different Trainer
subclasses. This PR creates a main() in torchtitan/train.py to
deduplicate the code.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* pytorch#1995
* __->__ pytorch#1985

We are adding more actions to convert the raw inputs and label.

1. The new CP can do the input/label/BlockMask sharding this in this
method.
2. The experimental full dtensor model can simply override this method
without changing too many Trainer code.

This method is extracted from
pytorch#1857

Makeing this a standalone PR allows us to continue the two projects
above without one blocks another.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* __->__ pytorch#1995

People are creating different train.py and duplicate the `main`
function. But in realitly people just want to use different Trainer
subclasses. This PR creates a main() in torchtitan/train.py to
deduplicate the code.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* pytorch#1995
* __->__ pytorch#1985

We are adding more actions to convert the raw inputs and label.

1. The new CP can do the input/label/BlockMask sharding this in this
method.
2. The experimental full dtensor model can simply override this method
without changing too many Trainer code.

This method is extracted from
pytorch#1857

Makeing this a standalone PR allows us to continue the two projects
above without one blocks another.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.12.0)
(oldest at bottom):
* pytorch#2002
* pytorch#2001
* __->__ pytorch#1995

People are creating different train.py and duplicate the `main`
function. But in realitly people just want to use different Trainer
subclasses. This PR creates a main() in torchtitan/train.py to
deduplicate the code.
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.

2 participants