Add --debug.print_config_ranks to limit config printing to select ranks - #4023
Open
githubsgi wants to merge 1 commit into
Open
Add --debug.print_config_ranks to limit config printing to select ranks#4023githubsgi wants to merge 1 commit into
githubsgi wants to merge 1 commit into
Conversation
githubsgi
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
July 30, 2026 00:12
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--debug.print_config_ranks, which restricts the--debug.print_configdump to a chosen set of global ranks.Default is an empty list, meaning print on every rank — identical to today's behavior, so this is a no-op for existing users unless they opt in.
Motivation
loggerin torchtitan is not rank-gated. Single-host runs stay readable becausetorchrun --local-ranks-filter ${LOG_RANK}drops non-selected ranks' stdout at the launcher.That filtering isn't available everywhere. On our cluster jobs are launched with
mpiexec -n N -ppn 8 --label, which forwards every rank's stdout into one combined log.--debug.print_configthen writes the fully expanded config tree once per rank.Measured on
deepseek_v3_671b(n_layers=61), where the dump expands every per-layer sub-config:--debug.print_config_ranks 0Running with configsblockRoughly a 10x reduction in log volume, and the log becomes greppable again.
This is generally useful to anyone driving torchtitan from a launcher that doesn't do rank filtering (MPI, Slurm
srunwithout output redirection per task, and so on), rather than being specific to our setup.Changes
torchtitan/config/configs.py— newprint_config_ranks: list[int]field onDebugConfig.torchtitan/config/manager.py— newlist_int_ruletyro primitive rule solist[int]fields accept comma-separated values, mirroring the existinglist_str_rule.torchtitan/trainer.py— rank gate inmaybe_log(). Reads the rank viatorch.distributed.get_rank()when the process group is initialized, falling back to0otherwise.config.maybe_log()runs afterinit_distributed(), so the group is up in the distributed path.tests/unit_tests/test_config_manager.py— covers the default and comma-separated parsing.Usage
Testing
Parsing verified directly:
End-to-end on a 256-node / 2048-rank
deepseek_v3_671bjob : with--debug.print_config_ranks 0the log contains exactly oneRunning with configsblock instead of 2048.tests/unit_tests/test_config_manager.py::TestConfigManager::test_parse_print_config_ranksadded and passing.