Repository navigation
checkpoint_skip_layers="auto": skip the planning collective under DDP.join() - #15779
Merged
Merged
Conversation
A rank that runs out of inputs inside DDP.join() (or accelerate join_uneven_inputs with even_batches=False) only shadows DDP's own collectives, so the planning all_reduce(MIN) on a rank still training paired with a join shadow collective and failed with a collective mismatch. Under an enabled join every layer stays checkpointed, as before #15545.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
[skip 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.
Problem
Since #15545,
checkpoint_skip_layers = "auto"under torchrun runs oneall_reduce(MIN)on the planned layer count at the planning forward (the second training forward). That assumes every rank reaches that forward.Under
DDP.join()(alsoaccelerate'sAccelerator.join_uneven_inputs(..., even_batches=False)), a rank that runs out of inputs early sits in the join loop and only shadows DDP's own collectives. If it runs out before the planning forward, the planningall_reduceon the rank that is still training pairs with a join shadow collective instead. On gloo this aborts withReceived data size doesn't match expected size. Is there a distributed collective mismatch in your code?. Before #15545 distributed runs never planned, so this configuration used to train fully checkpointed.HF
Trainerand TRL never enterDDP.join(), so this only affects custom loops that use join with uneven inputs.Change
_AutoCheckpointSkip._agree_across_rankschecks the DDP whose forward is running (DistributedDataParallel._get_active_ddp_module()). If it was put in an enabled join context, no collective is issued and every layer stays checkpointed, with a one line message. Every rank enters the join context, so every rank takes the same branch without communicating. Runs without join are unchanged.Tests
tests/test_gc_skip_auto_dist_cells.py::test_ddp_join_with_uneven_inputs_keeps_every_layer_checkpointed: 2 gloo ranks, tiny Qwen3 under DDP with reentrant checkpointing, rank 0 has 1 batch and rank 1 has 3, insidewith ddp.join():. On main the run fails with the collective mismatch above. With this change both ranks keep every layer checkpointed and losses and weights match a run without"auto".tests/test_gc_skip_auto_dist_cells.py,tests/test_gc_skip_auto_dist_gloo.py,tests/test_gc_skip_auto.pyon CPU (torch 2.13): 41 passed, 10 skipped (CUDA only).Not covered
NCCL was not run (CPU gloo only). After a join context exits, DDP keeps its join config enabled, so a model that first plans after leaving a join also stays fully checkpointed.