Repository navigation
[rl] Read staged pieces packed instead of restaging on the trainer - #6097
Conversation
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Each staged piece is now one read into the generator's prefetch buffer. Keys whose pieces are not contiguous runs of the generator shard are packed and copied into place on load (copy_prefetched_), so the trainer no longer redistributes DTensors before staging and stage() has no collectives. ghstack-source-id: 8fd17b9 Pull-Request: #6097
…5996) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.18.0) (oldest at bottom): * #6097 * #5997 * __->__ #5996 ## 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 RL syncs the trainer's model state dict to the generators through TorchStore, which adds a store, controller and extra copies around the transfer. With 14B on one 8xB200 host (trainer FSDP 4, generator TP 2, NIXL) a TorchStore pull takes 10-13 s (2.3-3.0 GB/s); with this transport the same pull takes 0.6-0.9 s (RDMA read at ~60 GB/s per generator rank). `torch.distributed._transport` now provides one-sided RDMA reads over Mooncake/NIXL, so the generators can read the trainer's shards directly. ## What changed - `torchtitan/rl/model_state_dict_transport.py` (new): - `shard_layout` / `_staged_pieces`: each trainer rank stages, per generator rank, the intersection of its FSDP box with the generator rank's box, cast to the generator dtype and 16 B aligned, in one registered pinned CPU buffer (pinned with cudaHostRegister, since `pin_memory=True` rounds up to a power of two). Generator ranks that need the same piece (e.g. a TP-replicated tensor) share one staged copy, so the buffer is about the trainer shard size at the transfer dtype. - `_staged_placements`: where a trainer shard cuts a generator shard on a dim after the first sharded dim, the trainer stages that DTensor with its later-dim shards moved to the first sharded dim, via one `redistribute` (an all-to-all within its mesh) in `stage`; e.g. a row-parallel weight (FSDP `Shard(0)`, TP `Shard(1)`) read by a generator split on dim 0 is staged as `(Shard(0), Shard(0))`: one read per piece instead of one per row. A generator TP on dim 1 matching the trainer's needs no restage. The decision uses every trainer rank's box, so all trainer ranks agree (the redistribute is a collective). - `_plan_reads`: each generator rank plans reads from every trainer rank straight into its prefetch buffers, one contiguous read per piece per index of the dims before its sharded dim (1 for a 2-D weight, 2 for a stacked `[2, F, D]` w13 sharded on F). HSDP replicas are spread round-robin across generator ranks. Raises if the trainer does not cover a shard exactly, and on `Partial` or uneven `_StridedShard` placements. - `shared_rank_layouts`: checks every generator reports the same per-rank layout. - `ModelStateDictTransport`: `register_trainer_source` + `stage` (trainer; a collective when restaging), `connect_generator` + `read` (generator). `read` fails after `Config.read_timeout_s` (default 600 s) instead of hanging on a stuck transfer; the job must then restart. - Every generator key must be fully covered by the trainer, or init raises (TorchStore loads with `strict=False`). Trainer keys no generator has (e.g. ones the generator drops) are not staged. - `Config.backend` selects the `torch.distributed._transport` backend: `"mooncake"` (default) or `"nixl"`. - Unused until the next PR wires it in behind a config flag. - Mooncake needs a PyTorch nightly from 2026-11-10 or later (Mooncake transport pytorch/pytorch#202780, multi-peer pytorch/pytorch#202536 and pytorch/pytorch#203461, poller fix pytorch/pytorch#203623). The staging buffer is laid out per staged piece, so a later delta sync can stage and read a subset of pieces without changing the plan. ## Alternatives considered - Keep TorchStore: its extra hop and copies are the bottleneck measured above. - Read directly from trainer GPU memory: a pull would then race the next optimizer step, and dtype casts would still need a staging copy. - Monarch RDMA (as `rdma_microbatch.py` uses for microbatches): ties the trainer and generator cores to Monarch and offers no Mooncake backend; `torch.distributed._transport` is PyTorch-native and backend-selectable. ## Related drafts - #5751, #5872 (delta sync), #5778 (TorchStore control plane), #5484 (pinned prefetch buffers), #5844 and #5846 (LoRA syncs) change the TorchStore path. They are independent of this PR; delta and LoRA syncs can move onto this transport by staging and reading a subset of pieces. ## Size Implementation +544, tests +451. ## Testing - `pytest tests/rl/unit_tests/cpu/test_model_state_dict_transport.py` (19 pass): checks `Config.backend` reaches `new_transport`, and runs `register_trainer_source`/`stage`/`connect_generator`/`read` over an in-process fake transport and checks every element lands in the right place and every read targets a connected trainer rank, with a bf16 cast, for HSDP 3x4 -> TP 1/2 on either dim (replica assignment across two generators), a stacked `[2, F, D]` weight sharded on F -> TP 1/2 on F or D (multi-run reads), mixed dtypes with `preserve_dtype_keys` and an odd-sized key (alignment), generator ranks sharing a replicated piece (one staged copy), a generator rank with an empty shard, incomplete or overlapping coverage and dtype mismatches (raise), mismatched generator layouts, and rejecting `Partial`/uneven `_StridedShard`. A 4-rank gloo test stages real FSDP 2 x TP 2 DTensors (row-parallel `(Shard(0), Shard(1))`, colwise FSDP over TP `(_StridedShard(0), Shard(0))`, stacked w13 `(_StridedShard(1), Shard(1))`, and a small `(Shard(0), Shard(1))` key on which 2 ranks have no pieces but must still join the restage) and reads them into generator TP 2 shards on two layouts, asserting the restage decision per layout (none when generator TP matches trainer TP on dim 1; `(Shard(0), Shard(0))` for row-parallel and the small key when the generator splits dim 0). This catches layout/offset bugs that would otherwise silently corrupt weights. - End-to-end numbers are in the next PR. AI-assisted (Claude).
Each staged piece is now one read into the generator's prefetch buffer. Keys whose pieces are not contiguous runs of the generator shard are packed and copied into place on load (copy_prefetched_), so the trainer no longer redistributes DTensors before staging and stage() has no collectives. ghstack-source-id: 8fd17b9 Pull-Request: #6097
Each staged piece is now one read into the generator's prefetch buffer. Keys whose pieces are not contiguous runs of the generator shard are packed and copied into place on load (copy_prefetched_), so the trainer no longer redistributes DTensors before staging and stage() has no collectives. ghstack-source-id: 8fd17b9 Pull-Request: #6097
Each staged piece is now one read into the generator's prefetch buffer. Keys whose pieces are not contiguous runs of the generator shard are packed and copied into place on load (copy_prefetched_), so the trainer no longer redistributes DTensors before staging and stage() has no collectives. ghstack-source-id: 8fd17b9 Pull-Request: #6097
…config flag (#5997) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.18.0) (oldest at bottom): * #6097 * __->__ #5997 ## 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 Wires the previous PR's `ModelStateDictTransport` into the RL loop as an opt-in replacement for TorchStore, so it can be rolled out per job. With 14B on one 8xB200 (183 GB) host it cuts the generator pull from 10-13 s to 0.6-0.9 s with pytorch/pytorch#204113 (1.7-2.35 s without it). ## What changed - `Controller.Config.model_state_dict_transport: ModelStateDictTransport.Config | None`. None (the default) keeps TorchStore. Setting it requires `generator.model_state_dict_load_mode="cpu_prefetch"`, which is validated at config time. - `ActorSystem.initialize_model_state_dict_transport` (Monarch impl): every generator reports its ranks' `shard_layout`s (which must match), the trainer ranks register staging buffers for it, and every generator rank connects and plans its reads. - Trainer: `push` stages (cast and, where needed, restage on GPU, D2H into the staging buffer) on the push stream from the actor thread before its first `await`, then awaits the stream in a worker thread. Restaging is a collective, so the controller sends the push before the next `forward_backward`; Monarch starts concurrent endpoints from one sender in send order, so every rank stages before its training collectives. - `scripts/install_rl_env.sh` installs `mooncake-transfer-engine-cuda13==0.3.14`, `nixl==1.5.0` and `nixl-cu13==1.5.0` with `--no-deps` (nixl-cu13 requires torch). - Generator prefetch: `read()` into the registered prefetch buffers replaces the TorchStore get. The load into the model is unchanged. - `torchtitan/rl/MODEL_STATE_DICT_TRANSPORT.md`: layout diagram and lifecycle. ## User-facing changes | Before | After | | --- | --- | | TorchStore only | `config.model_state_dict_transport = ModelStateDictTransport.Config(backend="mooncake" or "nixl")` | ## Numerics The trainer casts every tensor not in `preserve_dtype_keys` to `transfer_dtype` before the transfer; buffers and `preserve_dtype_params` keep their dtype. A dtype mismatch with the generator raises at init. The generator load is unchanged. `scripts/rl/loss_compare.py` (Qwen3-0.6B, deterministic, seed 42, 10 steps) with this flag matches TorchStore exactly: `--assert-equal` passes on loss for all 10 steps. ## Performance 14B (29.6 GB bf16), one 8xB200 (183 GB) host with 8x400G NICs, trainer FSDP 4 (GPUs 0,2,3,4), one generator TP 2 (GPUs 5,6), 10 steps. Baseline: `main` 8a33dbf + TorchStore 804ae43 over NIXL. | | TorchStore + NIXL | This PR (Mooncake) | | --- | --- | --- | | Generator pull | 10.0-13.2 s | 0.62-0.90 s | | of which RDMA read | 9-12 s | 0.20-0.35 s (~60 GB/s per generator rank, ~120 GB/s total) | | of which H2D load | - | 0.37-0.49 s | | Trainer push | 3.2-4.0 s | 0.5-0.9 s | | blocking the trainer | 2.1-3.2 s | ~0 | | Throughput | 60-74 tok/s | 610-880 tok/s | | Peak GPU, trainer / generator | 85.0 / 37.4 GB | 78.3 / 37.4 GB | | Peak RSS, trainer / generator | 10.4 / 38.6 GiB | 11.2 / 25.4 GiB | | Init span | 63.3 s | 62.5 s | Qwen3.5 27B (53.8 GB bf16) on MAST, 2 GB300 hosts (4 NICs each), DAPO-Math recipe: trainer FSDP 2 x TP 2 on one host, 4 TP 1 vLLM generators on the other (each pulls the full model), 6 steps of 4 prompts x 16 samples. Baseline: same recipe on TorchStore over NIXL. Pull times are for the slowest generator. | | TorchStore + NIXL | This PR (Mooncake) | This PR (NIXL) | | --- | --- | --- | --- | | First pull | 22.5 s | 4.6 s | 0.95 s | | Steady pulls (pulls 2-7) | 15.6-16.8 s | 2.2-2.8 s (fastest generator 1.2-1.4 s) | 0.96-1.08 s | | Effective rate, all 4 generators | ~13 GB/s | 77-98 GB/s | ~200-225 GB/s (50-56 GB/s per generator) | | Blocking pull / step time (steps 2-6) | 0.20-0.28 | 0-0.064 | 0-0.034 | | tok/s full step, mean of steps 2-6 | 13.0k | 16.9k | 15.7k | | Trainer model GPU memory | 31.75 GiB | 31.75 GiB | 31.75 GiB | | Generator KV cache | 196.22 GiB | 196.22 GiB | 196.22 GiB | The tok/s values vary with rollout length (baseline 7.8k-15.8k per step, Mooncake 11.2k-20.8k, NIXL 3.2k-20.1k). The MAST logs do not record host RSS. Trainer staging, same 27B runs (trainer rank 0). Staging runs on the push stream overlapped with the next `forward_backward`; the trainer blocks only on `push`'s wait (`timing/step/blocking_trainer_push_model_state_dict`). This layout (FSDP 2 x TP 2 -> TP 1) still restages row-parallel weights. | | TorchStore + NIXL | This PR (Mooncake / NIXL) | | --- | --- | --- | | Trainer blocking per step | 0-3 ms | 0-3 ms | | Full stage, not overlapped | 0.39-0.41 s | 0.12 s | | `forward_backward` incl. overlapped staging | 44.8-45.3 s | 44.5-45.3 s | | Init push | 2.19 s | 0.17-0.19 s | The Mooncake numbers depend on pytorch/pytorch#203623 (poller race; without it the run hangs) and pytorch/pytorch#204113 (register host memory with a NUMA-detected location; without it numa1 buffers use numa0 NICs and the read takes 1.3-1.7 s). ## Size Implementation +230/-22 (incl. 8 lines in `scripts/install_rl_env.sh`), docs +104/-8, tests +46 (a trainer test checking `push` stages on the push stream from the actor thread before its first `await` and synchronizes in a worker thread, plus a new attribute in existing tests); the unit tests in the previous PR cover the layout and read plan. ## Testing - 10-step 14B runs on 8xB200 with both configurations (table above); the transport run completed with rc=0. - 6-step 27B runs on MAST with all three configurations (table above); all completed 6 steps. The NIXL run used the same torch and this stack's `model_state_dict_transport.py`, nixl 1.5.0 over UCX with `UCX_NET_DEVICES` set to the 4 NICs, `UCX_TLS=rc,cuda_copy,self` and `UCX_MAX_RMA_RAILS=4`. - Loss compare above on 8xB200 (TorchStore arm exported, transport arm imported with `--assert-equal`), on a revision whose `torchtitan/` code is identical to this stack (later changes are tests and docs only). - The 14B runs used an earlier revision of this stack whose staging buffer used `pin_memory=True` (rounded up to a power of two) instead of cudaHostRegister; later review fixes (names, read timeout, hardcoded backend, docs/tests) do not change the transfer path. The 27B MAST run uses a revision with the same staging, read and stream-sync code, differing only in names, config plumbing and the generator-layout check, with torch 2.16.0.dev20261030+cu132 plus pytorch/pytorch#203623 and pytorch/pytorch#204113. - `pytest tests/rl/unit_tests/cpu/{test_generator,test_model_state_dict_transport,test_trainer,test_engine_loop,test_async_controller,test_shutdown}.py` (188 pass). - `pre-commit run` on the changed files passes (pyrefly skipped; it also fails on `main`). ## Known issues / follow-ups - Only `model_state_dict_load_mode="cpu_prefetch"` is supported; `gpu_fetch` still needs TorchStore, so the TorchStore path stays until this covers it. - The torch pinned by `scripts/install_rl_env.sh` (via vLLM, 2026-11-07) predates pytorch/pytorch#203623, so the stock env can time out on a read until the pin moves to 2026-11-10 or later. - No CI job runs the flag end to end (it needs RDMA NICs); the unit tests cover the layout, read plan and trainer staging. - Delta sync: stage and read only the changed pieces. - The H2D load from the prefetch buffers (0.4 s) now dominates the pull. - Restaging a tensor whose first sharded dim is not the outermost sharded mesh axis (e.g. MoE experts `(Shard(1), Shard(0))` -> `(Shard(0), Shard(0))`) can make DTensor gather it over that axis on the GPU during staging (untested at scale), costing transient memory at large EP. - Reads per pull scale with keys x trainer ranks (one per contiguous run); a batched read upstream in `torch.distributed._transport` would cut the per-read overhead. Init metadata (every trainer rank's pieces for every generator rank) scales the same way. - Every trainer DP rank keeps its own pinned staging copy of its shard; with replicated parameters (HSDP replicas, EP replicas of dense weights) this duplicates host memory across replicas. AI-assisted (Claude).
|
@claude review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. Moving the reshard from a trainer-side collective to a strided copy on the generator removes a per-tensor collective from every push. It also deletes net code, and the packed/in-place classification is correct.
What this PR does. Each staged piece is now read whole into the key's prefetch buffer, at consecutive offsets in sorted piece order. If every piece is a contiguous run of the generator shard, the buffer already holds the shard in place. Otherwise the key is marked packed, and copy_prefetched_ copies each piece into its slice of the parameter at load, with one stream sync per call. _staged_placements and the trainer redistribute are deleted, so stage() has no collectives.
Example. A row-parallel [D_out, D_in] weight has trainer placements FSDP Shard(0) and TP Shard(1). Generator ranks are split on dim 0, so each holds a [D_out/8, D_in] shard.
#5997: trainer redistributes to (Shard(0), Shard(0)) on every push (a collective),
and the generator reads 1 piece [D_out/8, D_in] in place
this PR: trainer copies its local shard only,
the generator reads 2 pieces [D_out/8, D_in/2] into a packed buffer,
and load copies each piece into param[:, 0:D_in/2] and param[:, D_in/2:]
A [8, 6] shard covered by [2, 6] row pieces stays in place. Covered by [8, 3] column pieces, it is packed.
Must fix
- The "Summary (human-written)" section of the PR description is empty. The author needs to fill it in.
tests/rl/unit_tests/cpu/test_trainer.py:170: with the collective gone, the "stage before the first await" invariant this test guards has lost its reason. Either drop those assertions or state what still needs the ordering (see the inline comment).
Questions
- Both PRs in this stack are still open. Would you fold this into #5997, so the restage machinery (
_staged_placements, the actor-thread ordering argument inpush_model_state_dict) never lands onmain?
Details
- In-place classification (
_plan_reads): a piece is a contiguous run iff it has size 1 on every dim before its last dim that is narrower than the shard. For non-overlapping in-bounds pieces that tile the shard, sorting by offset gives the same order as their flat start positions. So when every piece is a run, the packed offset of each piece equals its flat start, and the in-place read is correct. - Load path:
Generator._copy_prefetched_model_state_dictis called once per FSDP group, on that group'ssharded_params. The sync at the end ofcopy_prefetched_means the H2D copies finish before the next read can overwrite the prefetch buffers. FSDP unshard afterwards is stream-ordered after the copies. For quantized params,_ShardedFSDPTensorkeeps its wrapper throughaten.sliceandcopy_, solocal[index].copy_(view)writes the high-precision shard. - The +22% reads on dim-0 generators matter most with cross-host RDMA, where each read costs more. The benchmark only used loopback.
Not verified: load-time and read-count cost with cross-host RDMA on large models, which needs a multi-host run.
|
|
||
| # Staging must finish before the push's first await: Monarch starts the | ||
| # next forward/backward on this rank once the push yields. | ||
| # Staging is enqueued before the push's first await. |
There was a problem hiding this comment.
This PR removes the only reason test_push_model_state_dict_stages_before_first_await existed. Staging had to be issued before the first await so that every rank ran the restage collective ahead of the next forward/backward's collectives. Now stage() makes no collectives, so "before the first await" isn't an invariant anymore. The comment just restates what the test checks, and the test still pins push_model_state_dict to that shape. Either delete the before-first-await assertions (and rename the test to whatever it still guards: staging runs on the push stream, and the wait happens off the event loop), or say here what still needs this ordering.
| if placements is not None: | ||
| tensor = tensor.redistribute(placements=placements) |
There was a problem hiding this comment.
This PR sounds good!
Curious what are we going to do with the "trainer CPU -> generator GPU" case then?
It was invented because of the generator CPU memory limitation for "trainer CPU -> generator CPU" path (Kimi K3). So alternatively if we add chunked transfer, we can deprecate that path as well?
## 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
#5997 restages each DTensor on the trainer (a redistribute collective per tensor) whenever a staged piece would not be a contiguous run of the generator shard, e.g. a row-parallel weight read by generator ranks split on dim 0. Scalability concern: #5996 (comment) (tracked in #6096). This is the third option from #5996 (comment): an intermediate buffer on the generator side.
What changed
_plan_reads: each piece is one read into the key's prefetch buffer, at consecutive offsets in piece offset order. A key stays in place iff every piece is one contiguous run of the generator shard; otherwise it is packed.copy_prefetched_(called byGenerator._copy_prefetched_model_state_dict): plain keys copy as before; packed keys copy each piece into place (async H2D, one stream sync per call before the next read can reuse the buffers).stage()only casts and copies local shards;_staged_placementsand the redistribute are removed, so staging has no collectives.No extra bytes are read: each piece is still read exactly once. The cost moves to a strided copy per packed piece at load.
Lines: implementation +137/-168, tests +32/-37.
Test plan:
pytest tests/rl/unit_tests/cpu/test_model_state_dict_transport.py tests/rl/unit_tests/cpu/test_trainer.py: 35 passed._transfernow loads throughcopy_prefetched_;TestStageDTensors.test_fsdp_tp_to_tpchecks which keys are packed for two generator layouts.test_stacked_pieces(3 cases) andtest_fsdp_tp_to_tp._plan_reads/read/copy_prefetched_: values match; packed classification matches a brute-force contiguity check.[2, 4096, 2048]bf16 key in 4 pieces loads in ~0.18 ms (vs 0.11 ms unpacked); overwriting the prefetch buffer right aftercopy_prefetched_leaves the result intact (fails without the sync).ModelStateDictTransportonly, no RL loop; Llama3-8B shapes, 32 layers, fp32 trainer DTensors with the torchtitan FSDP+TP plan, bf16 generator, NIXL, median of 5 iterations, max over ranks, 0 mismatched keys everywhere). Reads are single-host UCX loopback (UCX_TLS=rc,sm,self,cuda_copy) on shared GPUs, so read times are not representative of cross-host RDMA. 8x B200, trainer FSDP 4 x TP 2: