Skip to content

[RFC][Config] Add torchtitan_configs for full training configurations - #4114

Merged
fegin merged 5 commits into
mainfrom
gh/fegin/154/head
Aug 17, 2026
Merged

fegin merged 5 commits into
mainfrom
gh/fegin/154/head

Conversation

@fegin

@fegin fegin commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

TL;DR

We plan to remove most CLI options, especially the options related to models, optimization, and parallelism, in the future. All users should use configuration programming to create their own Trainer.Config, which can be done easily with a coding agent. If CLI is a must, users can create their own CLI on top of the configuration system.

Motivation

There are several problems with the current configuration + CLI system. The two major ones developers hit today:

  1. update_from_config: some configurations can only be decided after the CLI is parsed, so every model has to provide an update_from_config to update the model configurations (e.g., sharding, optimization, backends) from the "new" configurations coming out of the CLI. This path is indirect and painful to maintain.

  2. CLI option exposure: when developers add a new feature they have to think about whether and how to expose the option, because the CLI is the entry to expose a knob. This is further amplified by the first issue -- developers also need to understand how (or if) update_from_config interacts with the new knob.

Implementation

torchtitan_configs is a package that lives outside the core torchtitan folder and is installed by pip install. It is not going to contain all use cases, because there are exponentially many combinations. It will only contains the test configs and some golden configs we verify on certain hardware. Users can put their own configs in this folder to launch a job.

Tentative Plan

  1. Introduce the torchtitan_configs package and freeze the CLI (this PR): Users should launch with MODULE=torchtitan_configs.tests CONFIG=llama3_debugmodel_fsdp2_cp2 ./run_train.sh and no further CLI options. Replace "tests" and "llama3_debugmodel_fsdp2_cp2" to fit your setting. To change options, change the configuration instead of appending a CLI flag. The existing flags still work, but only for backward compatibility; they are no longer the recommended way to configure a run.

  2. Move all the integration tests to use the new way to launch jobs.

  3. Demonstrate and document how to replace a module: With the future removal of the CLI, using a different implementation/optimization is done through config replacement. This step will document and demonstrate how to achieve that. [CP] Pluggable CP attention via cp_method + attention_sharding #3978 is the tentative PR (still WIP).

  4. Optimization composability: Now that optimizations are composed by replacing configs, we need to make sure these optimizations still compose. This needs more discussion and thought on the composability, and on whether there is a composability issue at all. We also need to understand if input_dst_sharding is still required.

  5. Split update_from_config: It does three different things: validation, derivation of the sharding configs, and the RoPE cache resize. Move the validation to one place so that every model does not need to implement its own, and leave the RoPE resize where it is. This step does not change any CLI behavior.

  6. Move the derivation into the configuration functions, which removes the rest of update_from_config: The derivation reads --parallelism.enable_sequence_parallel and --parallelism.expert_parallel_degree, and the CLI can still change them after the configuration function has run, so these two options have to go first. This is why steps 5 and 6 come late: users need time to move off these flags, and step 2 already removes the integration tests' dependency on them. This is also a BC breaking step, both for the two flags and for any out-of-repo model that implements its own update_from_config.

  7. Restructure configurations and trim CLI options and leave only the necessary ones: This is a huge BC breaking step. Tentative proposal, very early version, read this only if you are interested, https://gist.github.com/fegin/276f0b6d3d7a80ae2573516b25917166

fegin added 2 commits August 11, 2026 14:25
[ghstack-poisoned]
[ghstack-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 11, 2026

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

I didn't get the "frozen" part

Comment thread tests/integration_tests/features.py Resolved
Comment thread torchtitan_recipes/tests.py Resolved
Comment thread torchtitan/config/README.md Resolved

### The command-line options are frozen

The set of `--section.option` CLI flags will not grow. New features express their knobs in the config tree instead, so the way to introduce a new feature is by adding a new configuration, not a new CLI flag.

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.

could you clarify what this means -- does it happen before or after we delete tyro and CLI capability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR is landed, any PR that tries to add a new CLI flag e.g., --parallelisms.enable_new_cp, will trigger a CPU test failure.

Comment thread docs/configuration.md Outdated

We do not ship every combination of model, degrees and optimization, because that set is exponential. Your run is your own configuration: add it here without committing it, or keep it in your own package and point `--module` at that. Deriving from a shipped one is a few lines, as above.

The per-model `config_registry.py` modules, selected with `--module <model> --config <function>`, are the earlier location for the same thing. They keep working and are still how the integration tests select configs, but they take no new entries.

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.

do you mean that this is the new home for config registries

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, sorry, this part is probably not very clear. This means that the original configurations registered by config registry will continue to work.

They keep working and are still how the integration tests select configs, but they take no new entries. is not correct and I should remove it.

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.

hmm not getting it -- if everything still work, why do we need torchtitan_configs? probably should chat in person about this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of BC. It is not wise to kill CLI usage without verifying things first.

Comment thread torchtitan_recipes/__init__.py Resolved
@tianyu-l
tianyu-l requested a review from felipemello1 August 12, 2026 01:12
return any(m is tyro.conf.Suppress for m in getattr(field_type, "__metadata__", ()))


def _cli_options(config, prefix: str = "") -> set[str]:

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 didn't understand how this works. Let's say

  • we migrate from torch.utils.checkpoint to torch_remat and some AC options change
  • we switch from DCPv1 to DCPv2 and checkpoint manager config options change

In these cases, what should happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You add more AC options to config, but do not expose to CLI. Nothing happen. People are forced to do config programming.
  2. DCPv2 is the same.

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.

what mechanism makes tyro not automatically exposing them to CLI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyro.conf.Suppress

Comment thread docs/configuration.md Outdated

We do not ship every combination of model, degrees and optimization, because that set is exponential. Your run is your own configuration: add it here without committing it, or keep it in your own package and point `--module` at that. Deriving from a shipped one is a few lines, as above.

The per-model `config_registry.py` modules, selected with `--module <model> --config <function>`, are the earlier location for the same thing. They keep working and are still how the integration tests select configs, but they take no new entries.

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.

hmm not getting it -- if everything still work, why do we need torchtitan_configs? probably should chat in person about this

@acisseJZhong

Copy link
Copy Markdown
Contributor

why do we need torchtitan_configs, as opposed to today where each model folder has their canonical configs?

[ghstack-poisoned]
fegin added a commit that referenced this pull request Aug 13, 2026
**TL;DR**

We plan to remove CLI support in the future. All users should use configuration programming to create their own Trainer.Config, which can be done easily with a coding agent. If CLI is a must, users can create their own CLI on top of the configuration system.

**Motivation**

There are several problems with the current configuration + CLI system. The two major ones developers hit today:

1. `update_from_config`: some configurations can only be decided after the CLI is parsed, so every model has to provide an `update_from_config` to update the model configurations (e.g., sharding, optimization, backends) from the "new" configurations coming out of the CLI. This path is indirect and painful to maintain.

2. CLI option exposure: when developers add a new feature they have to think about whether and how to expose the option, because the CLI is the entry to expose a knob. This is further amplified by the first issue -- developers also need to understand how `update_from_config` interacts with the new knob.

**Implementation**

`torchtitan_recipes` is a package that lives outside the core torchtitan folder and is installed by `pip install`. It is not going to contain all use cases, because there are exponentially many combinations. It only contains the test configs and some golden configs we verify on certain hardware. Users can put their own configs in this folder to launch a job.

**Tentative Plan**

1. Introduce the torchtitan_recipes package and freeze the CLI (this PR). Users should launch with `MODULE=torchtitan_recipes.tests CONFIG=llama3_debugmodel_fsdp2_cp2 ./run_train.sh` and no further CLI options. Replace "tests" and "llama3_debugmodel_fsdp2_cp2" to fit your setting. To change something, change the configuration instead of appending a flag. The existing flags still work, but only for backward compatibility; they are no longer the way to configure a run.

2. Move all the integration tests to use the new way to launch jobs. The test list is generated, so this also means the helpers that read `--parallelism.*_degree` back out of the override strings need to read the config object instead.

3. Demonstrate and document how to replace a module. With the removal of the CLI, using a different implementation is done through config replacement. This step will document and demonstrate how to achieve that.

4. Optimization composability. Now that optimizations are composed by replacing configs, we need to make sure these optimizations still compose. This needs more discussion and thought on the composability, and on whether there is a composability issue at all.

5. Split `update_from_config`. It does three different things: validation, derivation of the sharding configs, and the RoPE cache resize. Move the validation to one place so that every model does not need to implement its own, and leave the RoPE resize where it is. This step does not change any CLI behavior.

6. Move the model-size baselines to `torchtitan_recipes` and delete `config_registry.py`. Step 2 already moves the test configs out, so what is left is `llama3_8b`, `llama3_70b` and the like. This has to come before the derivation step, otherwise that step has to add the sharding derivation to all 63 config functions instead of only the ones that survive. Command lines change from `--module llama3` to `--module torchtitan_recipes.llama3`; there is no shim, since a re-export in every model directory would just be a second name for every config.

7. Move the derivation into the configuration functions, which removes the rest of `update_from_config`. The derivation reads `--parallelism.enable_sequence_parallel` and `--parallelism.expert_parallel_degree`, and the CLI can still change them after the configuration function has run, so these two options have to go first. This is why steps 5 and 7 come late: users need time to move off these flags, and step 2 already removes the integration tests' dependency on them. This is also a BC breaking step, both for the two flags and for any out-of-repo model that implements its own `update_from_config`.

8. Restructure configurations and remove all CLI options except `--module` and `--config`. This is a huge BC breaking step.

ghstack-source-id: 8b928bd
Pull-Request: #4114
@fegin

fegin commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

why do we need torchtitan_configs, as opposed to today where each model folder has their canonical configs?

So configurations are cluster dependent and machine dependent. That's why people have to also rely on CLI options/flags. Given that we are killing most CLI options, users should maintain their own configurations to run.

If your question is about why torchtitan_recipes, a separate package, not torchtitan.recipes, the answer is more subjective -- we don't want the core torchtitan package to maintain configurations because they are not always runnable.

cc., @tianyu-l

@fegin
fegin marked this pull request as ready for review August 13, 2026 18:23
@fegin
fegin requested review from wconstab and wwwjn as code owners August 13, 2026 18:23

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.

maybe test_no_new_cli_options?

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.

maybe README.md?

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.

If we decided to have a "recipes" folder, should we be more serious about the recipes we have? "recipes" sounds ready to use, but most of configs in torchtitan is not verified to be efficient or optimized

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming inside the recipes can also tell the story. Like torchtitan_recipes.tests contains the recipes for testing. You can also put some "base" recipes for users to extend. Then nothing claim that they are optimized.

fegin added 2 commits August 17, 2026 11:26
[ghstack-poisoned]
[ghstack-poisoned]
fegin added a commit that referenced this pull request Aug 17, 2026
**TL;DR**

We plan to remove CLI support in the future. All users should use configuration programming to create their own Trainer.Config, which can be done easily with a coding agent. If CLI is a must, users can create their own CLI on top of the configuration system.

**Motivation**

There are several problems with the current configuration + CLI system. The two major ones developers hit today:

1. `update_from_config`: some configurations can only be decided after the CLI is parsed, so every model has to provide an `update_from_config` to update the model configurations (e.g., sharding, optimization, backends) from the "new" configurations coming out of the CLI. This path is indirect and painful to maintain.

2. CLI option exposure: when developers add a new feature they have to think about whether and how to expose the option, because the CLI is the entry to expose a knob. This is further amplified by the first issue -- developers also need to understand how `update_from_config` interacts with the new knob.

**Implementation**

`torchtitan_recipes` is a package that lives outside the core torchtitan folder and is installed by `pip install`. It is not going to contain all use cases, because there are exponentially many combinations. It only contains the test configs and some golden configs we verify on certain hardware. Users can put their own configs in this folder to launch a job.

**Tentative Plan**

1. Introduce the torchtitan_recipes package and freeze the CLI (this PR). Users should launch with `MODULE=torchtitan_recipes.tests CONFIG=llama3_debugmodel_fsdp2_cp2 ./run_train.sh` and no further CLI options. Replace "tests" and "llama3_debugmodel_fsdp2_cp2" to fit your setting. To change something, change the configuration instead of appending a flag. The existing flags still work, but only for backward compatibility; they are no longer the way to configure a run.

2. Move all the integration tests to use the new way to launch jobs. The test list is generated, so this also means the helpers that read `--parallelism.*_degree` back out of the override strings need to read the config object instead.

3. Demonstrate and document how to replace a module. With the removal of the CLI, using a different implementation is done through config replacement. This step will document and demonstrate how to achieve that.

4. Optimization composability. Now that optimizations are composed by replacing configs, we need to make sure these optimizations still compose. This needs more discussion and thought on the composability, and on whether there is a composability issue at all.

5. Split `update_from_config`. It does three different things: validation, derivation of the sharding configs, and the RoPE cache resize. Move the validation to one place so that every model does not need to implement its own, and leave the RoPE resize where it is. This step does not change any CLI behavior.

6. Move the model-size baselines to `torchtitan_recipes` and delete `config_registry.py`. Step 2 already moves the test configs out, so what is left is `llama3_8b`, `llama3_70b` and the like. This has to come before the derivation step, otherwise that step has to add the sharding derivation to all 63 config functions instead of only the ones that survive. Command lines change from `--module llama3` to `--module torchtitan_recipes.llama3`; there is no shim, since a re-export in every model directory would just be a second name for every config.

7. Move the derivation into the configuration functions, which removes the rest of `update_from_config`. The derivation reads `--parallelism.enable_sequence_parallel` and `--parallelism.expert_parallel_degree`, and the CLI can still change them after the configuration function has run, so these two options have to go first. This is why steps 5 and 7 come late: users need time to move off these flags, and step 2 already removes the integration tests' dependency on them. This is also a BC breaking step, both for the two flags and for any out-of-repo model that implements its own `update_from_config`.

8. Restructure configurations and remove all CLI options except `--module` and `--config`. This is a huge BC breaking step.

ghstack-source-id: 77fd33d
Pull-Request: #4114
@fegin
fegin changed the base branch from gh/fegin/154/base to main August 17, 2026 21:19
@fegin
fegin merged commit c82675e into main Aug 17, 2026
11 checks passed
fegin added a commit that referenced this pull request Aug 18, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 7e75392
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 18, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: e0dee35
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 18, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 69b964e
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 18, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 874823e
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 19, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 106b527
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 19, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 106b527
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 19, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: a4c878e
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 19, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: 11e4b04
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 20, 2026
Step 2 of the plan in #4114: every integration test now names a full configuration with `--module`/`--config` instead of a base config plus command-line overrides, so CI exercises the same selection path users do.

ghstack-source-id: bcb0c1b
Pull-Request: #4177
fegin added a commit that referenced this pull request Aug 20, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* __->__ #4177

Step 2 of the plan in #4114: every integration test now names a full
configuration with `--module`/`--config` instead of a base config plus
command-line overrides, so CI exercises the same selection path users
do.
acisseJZhong pushed a commit that referenced this pull request Aug 20, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* __->__ #4177

Step 2 of the plan in #4114: every integration test now names a full
configuration with `--module`/`--config` instead of a base config plus
command-line overrides, so CI exercises the same selection path users
do.
acisseJZhong pushed a commit that referenced this pull request Sep 2, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0)
(oldest at bottom):
* __->__ #4177

Step 2 of the plan in #4114: every integration test now names a full
configuration with `--module`/`--config` instead of a base config plus
command-line overrides, so CI exercises the same selection path users
do.

(cherry picked from commit 4f167b0)
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.

4 participants