Repository navigation
[PoC] Typed JobConfig - #767
Conversation
torchtitan/torchtitan/config_manager.py Line 143 in 82f7387 torchtitan/torchtitan/config_manager.py Lines 683 to 686 in 82f7387
|
|
hi @tianyu-l, ready for review custom_args implementation changed, not sure if it's what we want, but was one way I it got to work. torchtitan/tests/assets/argparser_example.py Lines 26 to 32 in d5a474c |
brentyi
left a comment
There was a problem hiding this comment.
left some minor notes! torchtitan/docs/extension.md also looks like it would need to be updated
tianyu-l
left a comment
There was a problem hiding this comment.
Looks reasonable after the first pass.
I left many comments, lol.
| def parse_args(self, args=None) -> None: | ||
| if args is None: | ||
| args = sys.argv[1:] | ||
| config_cls = self.maybe_add_custom_args(args) |
There was a problem hiding this comment.
I'd like to be a bit careful here.
Before this PR, we support custom_args_module even if it's only given from the .toml file.
It seems to me that in this PR, it only supports custom_args_module from cmdline input.
There was a problem hiding this comment.
added a test to confirm custom args parse from .toml file is okay --
however, reading comma separated string via toml loader not working
torchtitan/tests/unit_tests/test_job_config.py
Lines 268 to 269 in 9de5ea5
fegin
left a comment
There was a problem hiding this comment.
Given that the dataclasses merge allow users to overwrite (not just extend) the existing fields, we should document the expected behaviors.
tianyu-l
left a comment
There was a problem hiding this comment.
Looks really good.
I have two more requests:
- can we support
custom_args_moduleeven if it's only given in toml file - could you do a global audit (at least for
train.pyfile,llama3folder,llama4folder) and modify the callsites: (1)ConfigManager+JobConfig-maybe_add_custom_args()(2) in toml files, turnlist[str]args from "single str with comma" to "list of strings".
| config = config_manager.parse_args( | ||
| [ | ||
| f"--job.config_file={fp.name}", | ||
| f"--experimental.custom_args_module={path}", |
There was a problem hiding this comment.
what I meant was:
Before this PR, even if we don't specify this line, the custom_args_module in toml would be imported. Can we still support this use case, presumably with some inefficiency?
tianyu-l
left a comment
There was a problem hiding this comment.
Looks good to me! I believe this is a great improvement to the configuration system in torchtitan, in terms of user experience, readability, typing, and extensibility. Thank you for the solid work!
Please address remaining nits before we merge.
| class MyJobConfig: | ||
| checkpoint: Checkpoint = field(default_factory=Checkpoint) | ||
|
|
||
| MergedJobConfig = ConfigManager._merge_configs(JobConfig, MyJobConfig) |
There was a problem hiding this comment.
This use case may indicate _merge_configs could be made public. I think we can do it later once it is more "popular".
There was a problem hiding this comment.
agree, these two scripts under llama4/ were the only instances of such
a followup fix of #767 should be safe to land
|
Amazing works. This is such a nice improvement. I've been wanting something like this for awhile. I can close #1059 now. Thanks everyone. |
…n layer shape issue (#1153) ## What changed? 1. Refactor Flux arg parser to follow #767 new argparse practice 2. Explicitly change dtype for flux model to avoid #1137 (when FSDP is not enabled) 3. Fix txt_in layer shape issue by changing the config of schnell and dev model #1146 ## dtype management in Flux Training Without FSDP (fsdp dim = 1) : - Encoder's dtype = float32, Flux model's dtype = float32 With FSDP enabled: - Encoder's dtype = bfloat16, Text and Image encodings' dtype=bfloat16 - Flux Model's dtype: sharded params are in fp32, reduce-scatter is in fp32, so gradient updates happen in fp32. dtype when calculation=bfloat16 cc @CarlosGomes98
Incase theres any interest for type hinting of config args, at the expense of an added dependency (`tyro`). Re; pytorch#753 --------- Co-authored-by: Jayson Francis <[email protected]>
a followup fix of pytorch#767 should be safe to land
…n layer shape issue (pytorch#1153) ## What changed? 1. Refactor Flux arg parser to follow pytorch#767 new argparse practice 2. Explicitly change dtype for flux model to avoid pytorch#1137 (when FSDP is not enabled) 3. Fix txt_in layer shape issue by changing the config of schnell and dev model pytorch#1146 ## dtype management in Flux Training Without FSDP (fsdp dim = 1) : - Encoder's dtype = float32, Flux model's dtype = float32 With FSDP enabled: - Encoder's dtype = bfloat16, Text and Image encodings' dtype=bfloat16 - Flux Model's dtype: sharded params are in fp32, reduce-scatter is in fp32, so gradient updates happen in fp32. dtype when calculation=bfloat16 cc @CarlosGomes98
Incase theres any interest for type hinting of config args, at the expense of an added dependency (`tyro`). Re; pytorch#753 --------- Co-authored-by: Jayson Francis <[email protected]>
a followup fix of pytorch#767 should be safe to land
…n layer shape issue (pytorch#1153) ## What changed? 1. Refactor Flux arg parser to follow pytorch#767 new argparse practice 2. Explicitly change dtype for flux model to avoid pytorch#1137 (when FSDP is not enabled) 3. Fix txt_in layer shape issue by changing the config of schnell and dev model pytorch#1146 ## dtype management in Flux Training Without FSDP (fsdp dim = 1) : - Encoder's dtype = float32, Flux model's dtype = float32 With FSDP enabled: - Encoder's dtype = bfloat16, Text and Image encodings' dtype=bfloat16 - Flux Model's dtype: sharded params are in fp32, reduce-scatter is in fp32, so gradient updates happen in fp32. dtype when calculation=bfloat16 cc @CarlosGomes98
attn-gym 0.0.20 changes chunk_kda BF16 bits (meta-pytorch/attention-gym#764, #767), so kimi_k3_mm_muon no longer matches the old reference. The new values are from this branch's B200 run: https://github.com/pytorch/torchtitan/actions/runs/43270645434


Incase theres any interest for type hinting of config args, at the expense of an added dependency (
tyro).Re; #753