Repository navigation
[RFC][Config] Add torchtitan_configs for full training configurations - #4114
Conversation
[ghstack-poisoned]
tianyu-l
left a comment
There was a problem hiding this comment.
I didn't get the "frozen" part
|
|
||
| ### 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. |
There was a problem hiding this comment.
could you clarify what this means -- does it happen before or after we delete tyro and CLI capability?
There was a problem hiding this comment.
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.
|
|
||
| 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. |
There was a problem hiding this comment.
do you mean that this is the new home for config registries
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
hmm not getting it -- if everything still work, why do we need torchtitan_configs? probably should chat in person about this
There was a problem hiding this comment.
Because of BC. It is not wise to kill CLI usage without verifying things first.
| return any(m is tyro.conf.Suppress for m in getattr(field_type, "__metadata__", ())) | ||
|
|
||
|
|
||
| def _cli_options(config, prefix: str = "") -> set[str]: |
There was a problem hiding this comment.
I didn't understand how this works. Let's say
- we migrate from
torch.utils.checkpointtotorch_rematand some AC options change - we switch from DCPv1 to DCPv2 and checkpoint manager config options change
In these cases, what should happen?
There was a problem hiding this comment.
- You add more AC options to config, but do not expose to CLI. Nothing happen. People are forced to do config programming.
- DCPv2 is the same.
There was a problem hiding this comment.
what mechanism makes tyro not automatically exposing them to CLI?
|
|
||
| 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. |
There was a problem hiding this comment.
hmm not getting it -- if everything still work, why do we need torchtitan_configs? probably should chat in person about this
|
why do we need torchtitan_configs, as opposed to today where each model folder has their canonical configs? |
**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
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 cc., @tianyu-l |
There was a problem hiding this comment.
maybe test_no_new_cli_options?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
[ghstack-poisoned]
**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
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.
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.
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)
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:
update_from_config: some configurations can only be decided after the CLI is parsed, so every model has to provide anupdate_from_configto 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.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_configinteracts with the new knob.Implementation
torchtitan_configsis a package that lives outside the core torchtitan folder and is installed bypip 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
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.shand 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.Move all the integration tests to use the new way to launch jobs.
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).
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_shardingis still required.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.Move the derivation into the configuration functions, which removes the rest of
update_from_config: The derivation reads--parallelism.enable_sequence_paralleland--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 ownupdate_from_config.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