Skip to content

[config] Reject validation.steps=-1 when data-parallel degree > 1 - #4807

Merged
tianyu-l merged 4 commits into
pytorch:mainfrom
YeonwooSung:pr/validate-steps-neg1-dp
Sep 22, 2026
Merged

tianyu-l merged 4 commits into
pytorch:mainfrom
YeonwooSung:pr/validate-steps-neg1-dp

Conversation

@YeonwooSung

@YeonwooSung YeonwooSung commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

validation.steps=-1 consumes a finite dataset once. Ranks then stop independently, so a DP degree > 1 can hang on validation collectives (dist_sum of token counts / loss). GrainDataLoader already rejects repeat=False with dp_world_size > 1; that error names dataloader repeat, not validation.steps.

This PR:

  1. Replaces the assert on validation.steps with a ValueError, matching validation.freq. assert disappears under python -O.
  2. Raises the same constraint in Validator.__init__ once the real DP degree is known, naming validation.steps. Config __post_init__ cannot do this because data_parallel_shard_degree defaults to leftover -1.

The existing dataloader repeat guard is left in place. #4301 zero-batch / zero-token errors are unchanged. The Flux validator warning is unchanged.

Test plan

  • pytest tests/unit_tests/cpu/test_validate.py tests/unit_tests/cpu/test_validator_frequency.py (13 passed locally, including 8 subtests)
  • Lint

User-facing config errors should not use assert, which disappears under -O.
A finite validation pass with DP>1 can exhaust ranks at different steps and
hang collectives. Fail as soon as the DP degree is known, with an error that
names validation.steps, instead of waiting for the dataloader repeat guard.
@pytorch-bot pytorch-bot Bot added ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl labels Sep 20, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pytorch-bot

pytorch-bot Bot commented Sep 20, 2026

Copy link
Copy Markdown

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/rl
  • ciflow/fake-pg

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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 20, 2026
Comment thread torchtitan/components/validate.py Resolved
A finite pass sets the loader to repeat=False, so DP ranks can exhaust
at different steps and hang on validation collectives. Name that in the
error and the steps docstring instead of only stating the DP=1 constraint.
Drop the helper and the Trainer-level call. GrainDataLoader already
rejects repeat=False under DP.
@tianyu-l
tianyu-l merged commit 90b2591 into pytorch:main Sep 22, 2026
16 checks passed
@YeonwooSung
YeonwooSung deleted the pr/validate-steps-neg1-dp branch September 23, 2026 01:46
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