Repository navigation
[AUTOGENERATED] [release/2.12] Fix post-local SGD checkpoint reload race (#194614) - #3603
Merged
rocm-repo-management-api-6[bot] merged 1 commit intoAug 29, 2026
Conversation
) (#3600) ## Summary Fixes pytorch#84886. There was a race in the post-local SGD checkpoint reload test. Rank 0 created the temporary checkpoint and all ranks synchronized after it was written. However, there was no synchronization after loading. Rank 0 could complete the test first, leave the temporary-file context, and delete the checkpoint before another rank opened it, causing FileNotFoundError. Serialize the checkpoint into an in-memory buffer on rank 0 and broadcast the bytes through the process group. Each rank then loads from its own BytesIO buffer. This removes the rank-0-owned file and its lifetime race instead of adding another barrier around temporary-file cleanup. It also removes the unnecessary shared-filesystem dependency while preserving coverage of serialization, device remapping, optimizer state restoration, and the missing-step fallback. The same changes applied to test_ddp_hook_pickling_powerSGD and unskipped the test. ## Reproduction On `main`, add a 3s delay on non-zero ranks between the post-save `dist.barrier()` and `torch.load` in `_test_post_localSGD_optimizer_step_reload`: ```python dist.barrier() if self.rank != 0: time.sleep(3) map_location = {"cuda:0": f"cuda:{self.rank:d}"} checkpoint = torch.load(chkpt_file, map_location=map_location) ``` And then execute the test: ``` BACKEND=nccl WORLD_SIZE=2 TEMP_DIR=/tmp/dist python test/distributed/test_distributed_spawn.py -v \ TestDistBackendWithSpawn.test_post_localSGD_optimizer_step_reload ``` Without the changes, the test returns: ``` FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmptsfocehr' ``` Pull Request resolved: pytorch#194614 Approved by: https://github.com/jeffdaily (cherry picked from commit 7658834) ## Motivation <!-- Explain the purpose of this PR and the goals it aims to achieve. --> ## Technical Details <!-- Explain the changes along with any relevant GitHub links. --> ## Test Plan <!-- Explain any relevant testing done to verify this PR. --> ## Test Result <!-- Briefly summarize test outcomes. --> ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
rocm-repo-management-api-6
Bot
deleted the
autogenerated/release/2.12_cherry-pick_pr-3600
branch
August 29, 2026 08:25
1 task
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.
Cherry-pick of #3600