Skip to content

checkpoint_skip_layers="auto": skip the planning collective under DDP.join() - #15779

Merged
danielhanchen merged 2 commits into
mainfrom
dh/gc-skip-join
Oct 28, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
dh/gc-skip-join

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Since #15545, checkpoint_skip_layers = "auto" under torchrun runs one all_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() (also accelerate's Accelerator.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 planning all_reduce on the rank that is still training pairs with a join shadow collective instead. On gloo this aborts with Received 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 Trainer and TRL never enter DDP.join(), so this only affects custom loops that use join with uneven inputs.

Change

_AutoCheckpointSkip._agree_across_ranks checks 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, inside with 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.py on 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.

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.
@danielhanchen danielhanchen self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T13:52:53.349163Z 16fbb14 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

[skip ci]
@danielhanchen
danielhanchen merged commit a14f61a into main Oct 28, 2026
@danielhanchen
danielhanchen deleted the dh/gc-skip-join branch October 28, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant