fix: keep pretrain validate lockstep on empty ranks (#2319) - #2321
Open
ShamikOfficial wants to merge 2 commits into
Open
fix: keep pretrain validate lockstep on empty ranks (#2319)#2321ShamikOfficial wants to merge 2 commits into
ShamikOfficial wants to merge 2 commits into
Conversation
Avoid FSDP deadlock and torch.stack([]) crashes when some validation shards are empty by MIN-reducing has_batch before each step. Co-authored-by: Cursor <cursoragent@cursor.com>
ShamikOfficial
requested review from
andyland,
k223kim,
lianakoleva and
t-vi
as code owners
September 4, 2026 03:36
for more information, see https://pre-commit.ci
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
pretrain.validatewhen some ranks get zero validation batches (sharded streaming), as reported in litgpt pretrain crashes or deadlocks when a rank's val_dataloader yields zero batches (multi-GPU FSDP) #2319.has_batchflag so they stop together; if no rank had data, return NaN instead oftorch.stack([]).extensions/thunder/pretrain.pyand adds regression tests (empty loader, lockstep protocol, threaded uneven-shard deadlock coverage).Test plan
pytest tests/test_pretrain_validate_empty_rank.py -v— 6 passed locally (CPU)stack([])crash)