Skip to content

[Bug] Validate checkpoint load steps - #4287

Merged
tianyu-l merged 1 commit into
pytorch:mainfrom
taking-lying-flat:fix/checkpoint-load-step-validation
Aug 22, 2026
Merged

tianyu-l merged 1 commit into
pytorch:mainfrom
taking-lying-flat:fix/checkpoint-load-step-validation

Conversation

@taking-lying-flat

@taking-lying-flat taking-lying-flat commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • reject checkpoint.load_step values below -1 during config validation
  • preserve -1 for latest and non-negative values for explicit checkpoint steps
  • prevent malformed checkpoint paths such as step--2

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 22, 2026
@tianyu-l
tianyu-l merged commit d5f414f into pytorch:main Aug 22, 2026
18 checks passed
tianyu-l pushed a commit that referenced this pull request Sep 19, 2026
…tokens (#4301)

With the default validation dataloader (concat-then-split packing,
validate.py Config), a per-rank validation split holding fewer than
num_tokens_per_batch tokens yields zero packed rows, because
`_packing_output_is_full` drops partially filled rows. The validate loop
then breaks on the first StopIteration with `accumulated_loss` still
None, and the bare `assert accumulated_loss is not None` kills the whole
training run with a message-less AssertionError at the first validation
step. Without the assert, `global_loss_sum / num_global_valid_tokens`
raises ZeroDivisionError instead.

This PR replaces the assert with a ValueError naming the cause
(validation dataset supplied fewer than num_tokens_per_batch tokens on
this rank; concat-then-split packing drops partial batches) and the
remedy (decrease training.num_tokens_per_microbatch_per_dp_rank or use a
larger validation set), and guards the zero-valid-token division the
same way. Same fail-fast-with-a-clear-message class as the merged #4287
and #4291.

No numerical path changes: this is validation-layer error handling only,
the loss computation is untouched, so no numerics proof applies. No new
CLI flags.

Tests: two unit tests in tests/unit_tests/test_validate.py construct
both zero-batch and zero-valid-token conditions using the file's
existing validator harness. On main they fail with the bare
AssertionError and ZeroDivisionError; with this change they assert the
ValueError messages. pre-commit passes on both touched files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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