Repository navigation
Conversation
ivy-zhou
marked this pull request as ready for review
October 8, 2026 23:57
ivy-zhou
requested review from
fegin,
tianyu-l,
wconstab and
wwwjn
as code owners
October 8, 2026 23:57
tianyu-l
approved these changes
Oct 9, 2026
Summary: `TorchCheckpointingManager` synchronized checkpoint writes with a `TCPStoreBarrier`, which starts a second TCPStore server on a hard-coded port (43001) at `MASTER_ADDR`, falling back to `localhost`. That port has to be free on the master host and agreed on by every rank, two jobs or trainers sharing a host collide on it, and a multi-node job that does not export `MASTER_ADDR` points every rank at its own host. Use `DefaultStoreBarrier` instead. Every rank opens a client handle to the store `init_process_group` already serves, so there is no second server, port, or address to configure. Its keys are namespaced under a prefix and a per-barrier generation, so they cannot collide with the process group's keys. The config captures the store's address when it is pickled into the async checkpoint process, and keeps the store alive for that process if the trainer destroys the process group before the last save finishes. A single-rank run makes it a no-op, as before. With more than one rank, the default process group must be backed by a TCPStore or FileStore, which torchrun's `env://` rendezvous provides. Test Plan: ``` pytest -q tests/unit_tests/cpu/test_torch_checkpointing.py torchrun --nproc_per_node 2 --rdzv-endpoint localhost:0 --rdzv-backend c10d smoke.py pre-commit run --files torchtitan/components/checkpointer/torch_checkpointing.py tests/unit_tests/cpu/test_torch_checkpointing.py ``` 37 passed. The smoke script initializes a gloo process group, builds the barrier from `_writer_config(use_barrier=True)`, and runs it on both ranks, then again in a spawned child that receives the config pickled, as the async checkpoint process does: both pass. pre-commit: clean apart from pyrefly errors already present on main.
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:
TorchCheckpointingManagersynchronized checkpoint writes with aTCPStoreBarrier, which starts a second TCPStore server on a hard-coded port (43001) atMASTER_ADDR, falling back tolocalhost. That port has to be free on the master host and agreed on by every rank, two jobs or trainers sharing a host collide on it, and a multi-node job that does not exportMASTER_ADDRpoints every rank at its own host.Use
DefaultStoreBarrierinstead. Every rank opens a client handle to the storeinit_process_groupalready serves, so there is no second server, port, or address to configure. Its keys are namespaced under a prefix and a per-barrier generation, so they cannot collide with the process group's keys. The config captures the store's address when it is pickled into the async checkpoint process, and keeps the store alive for that process if the trainer destroys the process group before the last save finishes. A single-rank run makes it a no-op, as before. With more than one rank, the default process group must be backed by a TCPStore or FileStore, which torchrun'senv://rendezvous provides.Test Plan:
37 passed. The smoke script initializes a gloo process group, builds the barrier from
_writer_config(use_barrier=True), and runs it on both ranks, then again in a spawned child that receives the config pickled, as the async checkpoint process does: both pass. pre-commit: clean apart from pyrefly errors already present on main.