Skip to content

Publish the final decoupled checkpoint on engine destroy - #9155

Open
tohtana wants to merge 2 commits into
deepspeedai:masterfrom
tohtana:tohtana/decoupled-checkpoint-destroy
Open

tohtana wants to merge 2 commits into
deepspeedai:masterfrom
tohtana:tohtana/decoupled-checkpoint-destroy

Conversation

@tohtana

@tohtana tohtana commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

With decoupled=True, DeepSpeed writes checkpoint files in the background. Suppose the latest file contains step100 and every rank ends training with these calls.

engine.save_checkpoint(save_dir, tag="last")
engine.destroy()

The files for last are on disk when the job exits, but latest still says step100. On the next run, engine.load_checkpoint(save_dir) reads latest and restores step100. If last was the first checkpoint, latest is missing and the call finds nothing.

With this PR, engine.destroy() now waits for every rank to finish writing its checkpoint files. For a successful save with save_latest=True (the default), rank 0 then writes the checkpoint name to latest before any rank returns. In this example, the next run restores last. A failed save or a save with save_latest=False leaves latest as it was.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T23:55:08.695278Z b95b545 PR opened
ℹ️ 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.

@auto-pr-labeler-with-jev auto-pr-labeler-with-jev Bot added the skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU. label Nov 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b95b545525

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

try:
last_submission = self.__dict__.pop("_submitted_checkpoint", None)
if last_submission is not None and self.checkpoint_engine.get_commit_info() is last_submission:
self._commit_decoupled_checkpoint(wait_for_all_ranks=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Synchronize destroy commit failures before barriers

If a data-parallel writer's checkpoint subprocess dies after an earlier checkpoint has initialized checkpoint_size, a later save_checkpoint() still returns successfully because DecoupledCheckpointEngine.save() silently returns for a dead worker. During this call, commit() then raises on that writer, while non-writer ranks complete commit() and block in _commit_decoupled_checkpoint()'s barriers; the failed rank runs cleanup in finally and never reaches them, so destroy() deadlocks instead of reporting or cleanly handling the failed save. Catch and collectively synchronize the local commit result before entering these barriers.

Useful? React with 👍 / 👎.

"""Release engine resources. All ranks must call this with a pending decoupled checkpoint."""
try:
last_submission = self.__dict__.pop("_submitted_checkpoint", None)
if last_submission is not None and self.checkpoint_engine.get_commit_info() is last_submission:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Finalize DataStates checkpoints during destroy

With datastates_ckpt enabled, DataStatesCheckpointEngine.is_decoupled() is true and create() stores self.commit_info, but it does not override get_commit_info() (the base method always returns None). Consequently this identity check can never pass: cleanup() persists the final files, but rank 0 never executes _commit_decoupled_checkpoint() and never updates latest when save_latest=True, so a restart still loads an older checkpoint. Implement the pending-info accessor/finalization for this sibling asynchronous backend as well.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-test Requires positive evidence that every changed behavior can be validated without a GPU.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant