Skip to content

[checkpoint] Use the default store for torch_checkpointing barriers - #5170

Merged
ivy-zhou merged 1 commit into
mainfrom
pr5168
Oct 12, 2026
Merged

ivy-zhou merged 1 commit into
mainfrom
pr5168

Conversation

@ivy-zhou

@ivy-zhou ivy-zhou commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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.

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Oct 8, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 8, 2026
@ivy-zhou
ivy-zhou marked this pull request as ready for review October 8, 2026 23:57
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 8, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants