Repository navigation
[rl] Default to ModelStateDictTransport - #6125
Conversation
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
`ModelStateDictTransport` (one-sided `torch.distributed._transport` reads) replaced TorchStore for `cpu_prefetch` but was opt-in. On GB300 Muse18 (trainer 10 hosts, 2 generators x 4 hosts, 11 steps, Mooncake backend) it beats TorchStore on every measured axis:
| | TorchStore | ModelStateDictTransport |
|---|---|---|
| Trainer push n=1 (median/max) | 5.05/5.38 s | 0.33/0.33 s |
| Trainer push n>=2 (median) | 0.39 s | 0.33 s |
| Generator pull n=1 (median/max) | 30.4/37.7 s | 14.9/26.1 s |
| Generator pull n>=2 (median/max) | 13.1/19.9 s | 11.4/21.0 s |
| Trainer RSS steady | 89.2 GB | 48.0 GB |
| Full-step tok/s (median) | 630 | 725 |
On a GB300 27B run, NIXL pulled faster than Mooncake (first pull 0.95 s vs 4.56 s; TorchStore 22.5 s). GPU memory is identical in both arms. Pulled weights were checked bitwise against the trainer across FSDP/TP/EP layouts (0 mismatches).
## What changed
| | Before | After |
|---|---|---|
| `Controller.Config.model_state_dict_transport` default | `None` (TorchStore) | `ModelStateDictTransport.Config()` (NIXL) |
| `generator.model_state_dict_load_mode="gpu_fetch"` | works by default | requires `model_state_dict_transport=None` (ValueError says so) |
- `ModelStateDictTransport.Config.backend` defaults to `"nixl"` instead of `"mooncake"`. On a GB200 devserver, Mooncake's default RDMA path took 25-39 s per small read vs about 1 ms for NIXL, and RL CI (torch 2026-11-07) cannot load Mooncake (`transport 'mooncake' is not supported`) and lacks the Mooncake fix pytorch/pytorch#203623.
- Docs, README and a test comment updated.
Lines: implementation +20/-14 (controller +10/-6, transport +1/-1, docs +9/-7), tests +1/-1.
Test plan:
- `pytest tests/rl/unit_tests/cpu --ignore=tests/rl/unit_tests/cpu/test_vllm_wrapper.py`: 657 passed; 4 failures are a local env ImportError (`torch_checkpointing.CallbackArgs`), unrelated.
- Audited in-repo `Controller.Config` users: no recipe or integration test uses `gpu_fetch`; existing `gpu_fetch` tests build engines directly.
- NIXL and Mooncake real-backend read smoke on GB200 (pinned CPU and GPU buffers, packed and contiguous keys, bitwise compare): both pass.
- RL integration tests: via `ciflow/rl` CI.
ghstack-source-id: ddb205d
Pull-Request: #6125
|
|
@claude review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. Making the faster transport the default is a small, well-measured change, and the gpu_fetch combination it doesn't support now fails with a ValueError at config time.
What this PR does. Controller.Config.model_state_dict_transport now defaults to ModelStateDictTransport.Config() instead of None (TorchStore), and ModelStateDictTransport.Config.backend now defaults to "nixl" instead of "mooncake". Anyone who relies on generator.model_state_dict_load_mode="gpu_fetch" must now set model_state_dict_transport=None explicitly, and the error message says so. The rest of the PR updates docs and comments.
Example.
# Before: Controller.Config() -> TorchStore put/get for weight transfer
# After: Controller.Config() -> ModelStateDictTransport(backend="nixl")
cfg = Controller.Config(..., generator=Generator.Config(model_state_dict_load_mode="gpu_fetch"))
# Before: OK (TorchStore)
# After: ValueError: model_state_dict_transport requires ...="cpu_prefetch";
# set model_state_dict_transport=None to use TorchStore with "gpu_fetch"Must fix
- PR description -- the "Summary (human-written)" section is empty. Per
CONTRIBUTING.md, the author has to fill it in.
Should consider
torchtitan/rl/controller/controller.py:368-- no CI job runs the TorchStore path anymore, and it is still the only path forgpu_fetch(see inline comment).torchtitan/rl/README.md:64-- the wording suggestsgpu_fetchswitches to TorchStore automatically; it actually needsmodel_state_dict_transport=None(see inline comment).torchtitan/rl/MODEL_STATE_DICT_TRANSPORT.md:33-- theMC_FORCE_TCPnote is unrelated to this change (see inline comment).
Questions
- The default is NIXL, but the main Muse Spark comparison only measures Mooncake ("NIXL arm pending"). On Qwen3.5 27B, NIXL pulls faster but its mean tok/s is lower (15.7k vs 16.9k, with one outlier step). Will the Muse Spark NIXL numbers be posted before this lands, so the default is backed by data from the larger run?
Details
- @tushar00jain asked about generator RSS, GPU memory and peaks, and whether pull got faster. The updated description answers all of these: there are rows for generator RSS steady/peak, trainer and generator GPU peak alloc/reserved, and generator pull at n=1 and n>=2. Pull is faster in every reported configuration.
- Callsite audit: none of the recipes in
torchtitan_recipes/tests/rl/alphabet_sort.pysetsmodel_state_dict_transportorgpu_fetch, so the new default breaks no in-repo config.scripts/install_rl_env.shinstallsnixl==1.5.0/nixl-cu13==1.5.0, and all three RL integration workflows run it. - The batch-invariant RL integration tests check trainer/generator bitwise parity, so they now also cover the NIXL path's numerics.
Not verified: whether NIXL/UCX reads work on the single-node CI runners (results pending on ciflow/rl). A maintainer still needs to review.
| model_state_dict_transport: ModelStateDictTransport.Config | None = field( | ||
| default_factory=ModelStateDictTransport.Config | ||
| ) |
There was a problem hiding this comment.
No recipe in torchtitan_recipes/tests/rl/ sets model_state_dict_transport, so this default moves every RL integration test (8gpu, H100, B200) from TorchStore to NIXL. After this PR, no CI job runs the TorchStore path (initialize_torchstore, put_state_dict, the generator's StorageVolume reads). That path is still the only one that supports gpu_fetch. The gpu_fetch GPU unit tests (e.g. test_sglang_bitwise_parity.py) build engines directly and never touch TorchStore.
If the TorchStore path needs to keep working until the TODO lands, add model_state_dict_transport=None plus model_state_dict_load_mode="gpu_fetch" to one existing entry in tests/integration_tests/rl.py, e.g. one run of rl_grpo_checkpoint_resume. Don't add a new entry. If the path is allowed to go untested until it's deleted, say so in the PR description.
|
|
||
| - **[Monarch](https://github.com/meta-pytorch/monarch) as the controller:** orchestrates trainers and generators on separate GPU meshes with asynchronous communication. | ||
| - **[TorchStore](https://github.com/meta-pytorch/torchstore) for model state dict transfer:** efficiently publishes the model state dict from the trainer to generators, including direct GPU-to-GPU RDMA transfers. | ||
| - **[`ModelStateDictTransport`](MODEL_STATE_DICT_TRANSPORT.md) for model state dict transfer:** generators read the trainer's model state dict with one-sided RDMA reads over `torch.distributed._transport` (NIXL or Mooncake). [TorchStore](https://github.com/meta-pytorch/torchstore) is still used with `model_state_dict_load_mode="gpu_fetch"`. |
There was a problem hiding this comment.
"TorchStore is still used with gpu_fetch" makes it sound like the switch is automatic. It isn't: with the new default, gpu_fetch raises ValueError in Controller.Config.__post_init__ unless the user also sets model_state_dict_transport=None. Suggested wording:
| - **[`ModelStateDictTransport`](MODEL_STATE_DICT_TRANSPORT.md) for model state dict transfer:** generators read the trainer's model state dict with one-sided RDMA reads over `torch.distributed._transport` (NIXL or Mooncake). [TorchStore](https://github.com/meta-pytorch/torchstore) is still used with `model_state_dict_load_mode="gpu_fetch"`. | |
| - **[`ModelStateDictTransport`](MODEL_STATE_DICT_TRANSPORT.md) for model state dict transfer:** generators read the trainer's model state dict with one-sided RDMA reads over `torch.distributed._transport` (NIXL or Mooncake). `model_state_dict_load_mode="gpu_fetch"` requires `model_state_dict_transport=None`, which uses [TorchStore](https://github.com/meta-pytorch/torchstore) instead. |
| hostnames over IPv4. Without RDMA devices Mooncake falls back to its NVLink | ||
| transport, which cannot read pinned CPU memory, and reads fail with | ||
| `Mooncake transfer submission failed`; set `MC_FORCE_TCP=1`. |
There was a problem hiding this comment.
This Mooncake troubleshooting note (fall back to MC_FORCE_TCP=1 when there are no RDMA devices) is unrelated to changing the default, and it now documents the non-default backend. The PR description doesn't mention it either. Move it to its own PR, or list it under "What changed".
…vered in CI [ghstack-poisoned]
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Why
`ModelStateDictTransport` (one-sided `torch.distributed._transport` reads) replaced TorchStore for `cpu_prefetch` but was opt-in. It beat TorchStore on every measured axis in two GB300 runs.
GB300 Muse Spark 18 hosts (trainer 10 hosts, 2 generators x 4 hosts, 11 steps). ModelStateDictTransport NIXL arm pending:
| | TorchStore (NIXL) | ModelStateDictTransport (Mooncake) |
|---|---|---|
| Trainer push n=1 (median/max) | 5.05/5.38 s | 0.33/0.33 s |
| Trainer push n>=2 (median) | 0.39 s | 0.33 s |
| Generator pull n=1 (median/max) | 30.4/37.7 s | 14.9/26.1 s |
| Generator pull n>=2 (median/max) | 13.1/19.9 s | 11.4/21.0 s |
| Full-step tok/s (median) | 630 | 725 |
| Trainer RSS steady/peak (median/max) | 89.2/89.7 GB | 48.0/48.8 GB |
| Trainer node MemAvailable drop, push n=1 | 168 GB | 0 |
| Generator RSS steady/peak (median/max) | 105.5/105.7 GB | 106.6/106.8 GB |
| Trainer GPU peak alloc/reserved | 197/248 GB | 197/248 GB |
| Generator GPU peak alloc/reserved | 245/246 GB | 245/246 GB |
GB300 Qwen3.5 27B (separate, smaller run; pull is the slowest generator; memory identical across arms; push not recorded):
| | TorchStore (NIXL) | ModelStateDictTransport (Mooncake) | ModelStateDictTransport (NIXL) |
|---|---|---|---|
| Generator pull n=1 | 22.5 s | 4.56 s | 0.95 s |
| Generator pull n>=2 | 15.6-16.8 s | 2.2-2.8 s | 0.96-1.08 s |
| tok/s (mean) | 13.0k | 16.9k | 15.7k (one 3.2k outlier step) |
Memory is per rank, sampled every 50 ms during push/pull/load. On H100 32x8 Muse (trainer FSDP CPU offload, Mooncake): generator pull n=1 102 -> 8.3 s (median), generator RSS 54.1 -> 56.1 GB (max 54.3 -> 58.2), trainer RSS 124 -> 109 GB, GPU identical. Pulled weights were checked bitwise against the trainer across FSDP/TP/EP layouts (0 mismatches).
## What changed
| | Before | After |
|---|---|---|
| `Controller.Config.model_state_dict_transport` default | `None` (TorchStore) | `ModelStateDictTransport.Config()` (NIXL) |
| `generator.model_state_dict_load_mode="gpu_fetch"` | works by default | requires `model_state_dict_transport=None` (ValueError says so) |
- `ModelStateDictTransport.Config.backend` defaults to `"nixl"` instead of `"mooncake"`. On a GB200 devserver, Mooncake's default RDMA path took 25-39 s per small read vs about 1 ms for NIXL, and RL CI (torch 2026-11-07) cannot load Mooncake (`transport 'mooncake' is not supported`) and lacks the Mooncake fix pytorch/pytorch#203623.
- Mooncake doc: set `MC_FORCE_TCP=1` on hosts without RDMA devices (Mooncake's NVLink fallback cannot read pinned CPU memory).
- Run 2 of the `rl_grpo_checkpoint_resume` integration test sets `model_state_dict_transport=None`, so CI keeps covering TorchStore until it is deleted; run 1 covers `ModelStateDictTransport`.
- Docs and README updated.
Lines: implementation +20/-14 (controller +10/-6, transport +1/-1, docs +9/-7), tests +8/-4.
Test plan:
- `pytest tests/rl/unit_tests/cpu --ignore=tests/rl/unit_tests/cpu/test_vllm_wrapper.py`: 657 passed; 4 failures are a local env ImportError (`torch_checkpointing.CallbackArgs`), unrelated.
- Audited in-repo `Controller.Config` users: no recipe or integration test uses `gpu_fetch`; existing `gpu_fetch` tests build engines directly.
- NIXL and Mooncake real-backend read smoke on GB200 (pinned CPU and GPU buffers, packed and contiguous keys, bitwise compare): both pass.
- RL integration tests (NIXL in every entry except run 2 of `rl_grpo_checkpoint_resume`, which uses TorchStore): via `ciflow/rl` CI.
ghstack-source-id: d3fa5c6
Pull-Request: #6125
| @dataclass(kw_only=True, slots=True) | ||
| class Config(Configurable.Config): | ||
| backend: Literal["mooncake", "nixl"] = "mooncake" | ||
| backend: Literal["mooncake", "nixl"] = "nixl" |
There was a problem hiding this comment.
anecdotally I also heard NIXL should be faster than MoonCake
There was a problem hiding this comment.
results with muse spark open show it at 8x faster, will follow up with the mooncake team on why
There was a problem hiding this comment.
I think the perf gap may be in our Mooncake integration
[ghstack-poisoned]
[ghstack-poisoned]
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Problem
`ModelStateDictTransport` (the default since #6125) only supports `model_state_dict_load_mode="cpu_prefetch"`; `gpu_fetch` (for hosts with little CPU memory, e.g. GB300) raises at config time and must fall back to TorchStore (#6070).
## Change
With `gpu_fetch`, each generator rank registers one GPU fetch buffer sized to the largest FSDP load group. During the load, `fetch_` reads each group's pieces from the trainer's pinned CPU staging buffers into it (one-sided RDMA, deadline `read_timeout_s`) and copies them into the sharded params, unpacking packed keys. Trainer GPU -> trainer pinned CPU -> generator GPU; no generator CPU copy.
- `ModelStateDictTransport.connect_fetching_generator` / `fetch_`.
- `ModelStateDictLoader.load_groups` (+ engine property) gives the per-group layouts.
- `Generator` uses them for its layout and for the gpu_fetch load; TorchStore remains the `None` path.
- Removes the cpu_prefetch-only `ValueError`.
Depends on #6097 (packed reads) and #6125.
| | Before | After |
|---|---|---|
| `gpu_fetch` + transport | `ValueError` | RDMA reads into GPU |
Lines: impl +223/-50 (incl. docs), tests +66/-6.
Numerics: unchanged; reads are exact copies (checked bitwise).
Test plan:
- `pytest tests/rl/unit_tests/cpu`: 658 passed (4 pre-existing env failures). New `test_gpu_fetch`: 4 trainer -> 2 generator ranks, contiguous bf16, packed stacked and preserved-fp32 keys across two groups.
- Real NIXL/Mooncake GB200 smoke (trainer pinned CPU -> generator GPU fetch buffer, packed + contiguous keys): bitwise match.
- RL integration tests via `ciflow/rl` (regression only: no CI config runs `gpu_fetch` with the transport; the GB200 smoke above is the end-to-end check).
ghstack-source-id: b0c51d2
Pull-Request: #6127
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why
this approach, and what you checked yourself. -->
## Problem
`ModelStateDictTransport` (the default since #6125) only supports `model_state_dict_load_mode="cpu_prefetch"`; `gpu_fetch` (for hosts with little CPU memory, e.g. GB300) raises at config time and must fall back to TorchStore (#6070).
## Change
With `gpu_fetch`, each generator rank registers one GPU fetch buffer sized to the largest FSDP load group. During the load, `fetch_` reads each group's pieces from the trainer's pinned CPU staging buffers into it (one-sided RDMA, deadline `read_timeout_s`) and copies them into the sharded params, unpacking packed keys. Trainer GPU -> trainer pinned CPU -> generator GPU; no generator CPU copy.
- `ModelStateDictTransport.connect_fetching_generator` / `fetch_`.
- `ModelStateDictLoader.load_groups` (+ engine property) gives the per-group layouts.
- `Generator` uses them for its layout and for the gpu_fetch load; TorchStore remains the `None` path.
- Removes the cpu_prefetch-only `ValueError`.
Depends on #6097 (packed reads) and #6125.
| | Before | After |
|---|---|---|
| `gpu_fetch` + transport | `ValueError` | RDMA reads into GPU |
Lines: impl +223/-50 (incl. docs), tests +66/-6.
Numerics: unchanged; reads are exact copies (checked bitwise).
Test plan:
- `pytest tests/rl/unit_tests/cpu`: 658 passed (4 pre-existing env failures). New `test_gpu_fetch`: 4 trainer -> 2 generator ranks, contiguous bf16, packed stacked and preserved-fp32 keys across two groups.
- Real NIXL/Mooncake GB200 smoke (trainer pinned CPU -> generator GPU fetch buffer, packed + contiguous keys): bitwise match.
- RL integration tests via `ciflow/rl` (regression only: no CI config runs `gpu_fetch` with the transport; the GB200 smoke above is the end-to-end check).
ghstack-source-id: 3be2885
Pull-Request: #6127
Stack from ghstack (oldest at bottom):
Summary (human-written)
Why
ModelStateDictTransport(one-sidedtorch.distributed._transportreads) replaced TorchStore forcpu_prefetchbut was opt-in. It beat TorchStore on every measured axis in two GB300 runs.GB300 Muse Spark 18 hosts (trainer 10 hosts, 2 generators x 4 hosts, 11 steps):
Setup is measured from the last generator becoming ready (slowest rank). Pinning is the same code for both backends, so the trainer gap (7.0 vs 2.2 s) is NIXL agent creation and UCX registration. Mooncake's generator connect is the largest setup cost. Trainer registration includes the generator layout RPC.
GB300 Qwen3.5 27B (separate, smaller run; pull is the slowest generator; memory identical across arms; push not recorded):
Memory is per rank, sampled every 50 ms during push/pull/load. On H100 32x8 Muse (trainer FSDP CPU offload, Mooncake): generator pull n=1 102 -> 8.3 s (median), generator RSS 54.1 -> 56.1 GB (max 54.3 -> 58.2), trainer RSS 124 -> 109 GB, GPU identical. Pulled weights were checked bitwise against the trainer across FSDP/TP/EP layouts (0 mismatches).
What changed
Controller.Config.model_state_dict_transportdefaultNone(TorchStore)ModelStateDictTransport.Config()(NIXL)generator.model_state_dict_load_mode="gpu_fetch"model_state_dict_transport=None(ValueError says so)ModelStateDictTransport.Config.backenddefaults to"nixl"instead of"mooncake". On a GB200 devserver, Mooncake's default RDMA path took 25-39 s per small read vs about 1 ms for NIXL, and RL CI (torch 2026-11-07) cannot load Mooncake (transport 'mooncake' is not supported) and lacks the Mooncake fix [Transport] [Mooncake] Don't drop a reused batch id when settling a transfer pytorch#203623.MC_FORCE_TCP=1on hosts without RDMA devices (Mooncake's NVLink fallback cannot read pinned CPU memory).rl_grpo_checkpoint_resumeintegration test setsmodel_state_dict_transport=None, so CI keeps covering TorchStore until it is deleted; run 1 coversModelStateDictTransport.Lines: implementation +20/-14 (controller +10/-6, transport +1/-1, docs +9/-7), tests +8/-4.
Test plan:
pytest tests/rl/unit_tests/cpu --ignore=tests/rl/unit_tests/cpu/test_vllm_wrapper.py: 657 passed; 4 failures are a local env ImportError (torch_checkpointing.CallbackArgs), unrelated.Controller.Configusers: no recipe or integration test usesgpu_fetch; existinggpu_fetchtests build engines directly.rl_grpo_checkpoint_resume, which uses TorchStore): viaciflow/rlCI.