Repository navigation
[checkpoint] Wait for async saves during close - #4270
Merged
tianyu-l merged 1 commit intoSep 1, 2026
Merged
Conversation
taking-lying-flat
marked this pull request as ready for review
August 21, 2026 19:18
taking-lying-flat
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
August 21, 2026 19:18
ivy-zhou
reviewed
Aug 31, 2026
| self.close() | ||
|
|
||
| def _close(self): | ||
| self.maybe_wait_for_staging() |
Contributor
There was a problem hiding this comment.
Makes sense to but would you mind moving this into the base class in base.py instead? This looks like common functionality. Thank you!
ivy-zhou
approved these changes
Aug 31, 2026
tianyu-l
approved these changes
Aug 31, 2026
Contributor
|
may need to rebase |
taking-lying-flat
force-pushed
the
fix/checkpointer-close-await-save
branch
from
August 31, 2026 23:14
6c90147 to
4a4a97c
Compare
saforem2
added a commit
to saforem2/torchtitan
that referenced
this pull request
Sep 6, 2026
Surveyed, not merged -- two 80B captures are mid-flight and folding in 64 commits would make any new failure ambiguous. This records the analysis so the merge is cheap later. Diverged at 6ee6d5d (2026-08-30), upstream tip 966befc. ZERO upstream commits touch experiments/ezpz, so there are no conflicts in our own code. The risk is entirely in core files we import from. Of those, components/loss.py matters most: we import BaseLoss, CrossEntropyLoss, ChunkedLossWrapper and IGNORE_INDEX, all four still present, with one method renamed (typecheck_forward -> spmd_typecheck). zloss.py overrides only __init__ and __call__, so it does not inherit that rename -- checked rather than assumed, since a preserved name with a changed contract is the dangerous case, not a deleted one. Corrects my earlier risk ranking. I called pytorch#4328 (refactor max_context_length) the highest risk; that was wrong. max_context_length is UNCHANGED upstream -- same field, same default, plus a validation guard. The PR changes seq_len in model specs and registries, not the --training.max-context-length flag we pass. The single seam is agpt/config_registry.py:291, where our own agpt(seq_len=...) assigns cfg.training.max_context_length. The real risks, ordered: pytorch#4398 (valid-token counts move into collation -- that is the gradient-accumulation path), then the checkpoint cluster (pytorch#4187/pytorch#4188/pytorch#4197/pytorch#4270/pytorch#4474, which we subclass and where pinned clones have already broken on optim-statedict changes), then pytorch#4382 (Adam first-step state). Includes a merge order: smoke at 2N, then a resume from a real checkpoint, a seeded loss/grad_norm comparison, and config_registry.py:291 by inspection.
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
Wait for in-flight asynchronous checkpoint staging and saving before CheckpointManager releases its background resources.
Root cause
CheckpointManager tracks asynchronous work in staging_future and save_future. Normal checkpoint cycles wait for the previous save before starting the next one, but _close() only stopped the purge thread and closed the stager.
Shutdown paths do not necessarily start another save. In particular, dataloader exhaustion breaks out of training before the final-step save, while exceptions and explicit close calls also proceed directly to teardown. The last asynchronous upload could therefore still be running when close returned and the process group or process was torn down.
DefaultStager.close() drains its staging executor, but it does not await the checkpoint upload future or explicitly surface completion through the tracked futures. The close path now drains staging_future and save_future before releasing the purge and staging resources.