Skip to content

[config] Split shared configs into dedicated modules - #4907

Open
acisseJZhong wants to merge 2 commits into
mainfrom
reorder_config
Open

acisseJZhong wants to merge 2 commits into
mainfrom
reorder_config

Conversation

@acisseJZhong

Copy link
Copy Markdown
Contributor

Summary

  • move TrainingConfig, CompileConfig, CommConfig, and DebugConfig into dedicated modules under torchtitan/config
  • remove the aggregate configs.py module and update internal imports
  • preserve the public torchtitan.config exports and the shared configuration guidance in the package docstring

Testing

  • pre-commit run ufmt --files <changed files>
  • pre-commit run flake8 --files <changed files>
  • pytest -q tests/unit_tests/cpu/test_config_manager.py tests/unit_tests/cpu/test_compile_config.py tests/unit_tests/cpu/test_config_converter.py tests/unit_tests/cpu/test_configurable.py tests/unit_tests/cpu/test_trainer.py tests/unit_tests/rl/test_trainer.py torchtitan/experiments/graph_trainer/tests/test_simple_fsdp.py (106 passed, 7 subtests passed)

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 27, 2026
@acisseJZhong
acisseJZhong marked this pull request as ready for review September 27, 2026 00:52
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 27, 2026

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.

After seeing the change, I found it to be somewhat confusing -- e.g. we have config/validation.py which is about validating the config, not the config of validator.

I wonder if we should have a separate torchtitan/configs/ folder which is separated from this torchtitan/config/ folder.

@acisseJZhong
acisseJZhong marked this pull request as draft September 27, 2026 06:50
@pytorch-bot pytorch-bot Bot removed the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 27, 2026
@acisseJZhong
acisseJZhong marked this pull request as ready for review September 27, 2026 06:53
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Sep 27, 2026
Comment on lines 28 to +29
from torchtitan.config import CompileConfig, TrainingConfig
from torchtitan.config.parallelism import ParallelismConfig
from torchtitan.config.configs.parallelism import ParallelismConfig

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.

the difference doesn't make much sense -- I'll think about it

tianyu-l pushed a commit that referenced this pull request Oct 2, 2026
`GarbageCollection.__init__` rejected a non-positive `gc_freq` with
`assert`. `training.gc_freq` is user config. That assert disappears
under `python -O`, and `gc_freq=0` then dies as `ZeroDivisionError` on
`step_count % self.gc_freq` during training. A negative value still
collects.

Raise `ValueError` in the constructor instead. The message includes the
bad value and says `training.gc_freq` must be a positive integer. The
default stays 1000, and when GC runs is unchanged. The check stays in
the constructor (not `TrainingEngine` or `configs.py`) because #4907
rewrites the config layout.

## Test plan

- [ ] `pytest tests/unit_tests/cpu/test_gc_freq.py -q`
- [ ] `GarbageCollection(0)` and `GarbageCollection(-1)` raise
`ValueError` whose message mentions `gc_freq`
- [ ] `GarbageCollection(1)` and `GarbageCollection(1000)` still
construct, and periodic collection still runs only when `step_count > 1`
and `step_count % gc_freq == 0`

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl 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