Skip to content

Implement delta model state dict transport - #6309

Open
tushar00jain wants to merge 1 commit into
mainfrom
fs-head/tushar00jain/9
Open

tushar00jain wants to merge 1 commit into
mainfrom
fs-head/tushar00jain/9

Conversation

@tushar00jain

@tushar00jain tushar00jain commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Compared various approaches. Given these constraints

  • low fixed memory overhead small relative to model size on trainer and generator
  • keep the quantization on generator
  • no new libraries besides zstd

This seems like a decent approach

  • sparse xor delta encoding
  • applying delta thresholds to fixed sized windows
  • group the decoding on the generator by fsdp groups and allow quantization to happen in parallel with the pull

torchtitan/rl/MODEL_STATE_DICT_DELTA_TRANSPORT.md works through an example to illustrate the design.

Why

Every pull reads the whole model state dict, though an RL optimizer step changes
about 2% of bf16 words. On Qwen3.5-27B each generator reads 53.8 GB per pull;
with delta sync it reads 0.75-1.00 GB, and generator weights stay bitwise
identical to full sync.

What changed

A new ModelStateDictDeltaTransport (model_state_dict_delta_transport.py, doc
MODEL_STATE_DICT_DELTA_TRANSPORT.md), selected by placing
ModelStateDictDeltaTransport.Config where ModelStateDictTransport.Config
goes. Its Config adds capacity_divisor (default 16: the most changed words a
64 MiB window sends, as a fraction of its words) and codec_threads (default 32:
compression and decompression threads per process). Mechanical:
prepare_transfer returns per-push metadata that the controller forwards to
each generator's read; connect_generator takes the generator's FSDP load
groups; three transport helpers become public.

 TRAINER RANK                                     GENERATOR RANK
 model shards (GPU)                               prefetch buffer (CPU, push N-1)
   | stage: per 64 MiB window, on the GPU             |
   |   changed words -> positions, XORs               |
   v                                                  |
 staging buffer (CPU, push N)                         |
   | prepare_transfer: one zstd record per            |
   | changed StagedPiece: [gaps | XORs]               |
   v                                                  |
 delta buffer (CPU) ----------- RDMA ------> receive buffer (CPU)
   |                                                  | decompress (CPU threads)
 metadata: {byte_offset: DeltaRecord}                 v
   '--> controller --> router --> read      load: prefetch -> GPU copy, XOR changes
                                                  = push N weights (bf16, before FSDP all-gather)
                                                  then CPU threads XOR prefetch -> push N

Read whole, as full sync: the first push, a missed push, more than
1 / capacity_divisor of a 64 MiB window changed, records over the trainer's
delta buffer, or a generator rank's records over its share of the receive buffer.

Alternatives considered

Alternative Main difference Why not
One record per 64 MiB window (#6311) window records don't align with generator pieces generators translate windows -> segments -> keys and read other ranks' changes; same pull time
Dense XOR per window, zstd on the GPU with nvCOMP (#6176) compresses and decompresses on the GPU, so decoding the whole mask is fast nvCOMP is CUDA-only and not PyTorch; decode needs generator GPU memory
Same dense XOR, decoded on the generator CPU no GPU codec the generator decodes all 54 GB every pull: 2.80-2.92 s pulls (measured)
Dense XOR + Blackwell Decompression Engine on live NVFP4 weights ("weight teleportation") hardware decompression; trainer weights already in serving format Blackwell-only, nvCOMP; needs trainer-side quantization and generator layout
Sparse (position, new value) sends new values instead of XORs a 1-ulp change leaves the XOR's high bits zero, so XORs compress better
A 1/16 cap per piece instead of per window each piece has its own budget small pieces (norms) change in more than 1/16 of their words: every 27B pull read whole (measured)
No cap buffers sized for everything changing about 37.5 GiB pinned + 25 GiB delta buffer per trainer rank, 100 GiB receive buffer per generator
Compare on the trainer CPU with a second staging buffer no GPU diff, no windows +12.5 GiB pinned per trainer rank
Per-piece GPU diff with dynamic nonzero no windows, no fixed slots a host sync per piece (~740 per trainer rank per push)
Apply to the prefetch buffer before the load the load is unchanged ~1.1-1.3 s of CPU XOR lands on the pull's critical path
Per-key positions computed on the CPU at decode, copied per key (no load_groups) no plumbing through the engines, loader and connect_generator load pause 0.51-0.83 s per key vs 0.43-0.79 s per FSDP group (27B, measured); CPU positions added ~0.1 s of prefetch (local)

User-facing changes

Before After
ModelStateDictTransport.Config(backend=...): every pull reads the whole state ModelStateDictDeltaTransport.Config(backend=...): after the first pull, only changes; ModelStateDictTransport.Config stays full sync

Numerics

Bitwise exact: generator weights match full sync bit for bit (unit tests with
rtol=0, atol=0, and a local check on the 27B layout).

Performance

Qwen3.5-27B DAPO-Math, 4 generators, GB300, at 8994728.

Full sync (ModelStateDictTransport) This PR (ModelStateDictDeltaTransport)
First pull 1.42 s 1.42 s
Steady pulls (pulls 2-7) 1.54-1.73 s 0.86-1.72 s (5 of 6 at 0.86-1.16 s)
Bytes read per generator per steady pull 53.79 GB (100%) 0.75-1.00 GB (1.4-1.9%)
RDMA reads per generator per steady pull 2538 212-217
Changed words per push - 1.58-2.23%
Compression ratio (staged / compressed) - 53-72x
Prefetch per generator 0.95-1.02 s 0.19-0.77 s
RDMA wait (within prefetch) - 12-166 ms
Decompress + pack (within prefetch) - 154-563 ms
Generator load (pause, includes the GPU XOR) 0.46-0.71 s 0.43-0.67 s
Blocking pull / step time (steps 2-6) 0-0.045 0-0.025
Trainer rank 0 Full sync This PR
Trainer blocking per step 0-5 ms 0-17 ms
Stage, overlapped 0.11 s 0.26-1.59 s
Compress (CPU threads, overlapped) - 0.18-0.24 s
forward_backward incl. overlapped staging (steps 2-6) 33.2-41.0 s 36.1-42.3 s
Init push 0.14 s 0.26 s

Memory

Max over processes and steps Full sync This PR Where the difference goes
Peak GPU reserved, trainer / generator 172.96 / 261.06 GiB 173.82 / 261.06 GiB per-window GPU temporaries (~180 MiB per 64 MiB window)
Peak RSS, trainer 17.16 GiB 23.03 GiB +3.92 GiB pinned at exact size: delta buffer 1.57 + positions/XORs 2.35; ~2 GiB heap from compression temporaries
Peak RSS, generator 80.98 GiB 98.43 GiB +6.26 GiB receive buffer (exact size); +6.45 GiB caching host allocator for at most 3.3 GiB of per-pull _Group buffers (power-of-two rounding); ~4.9 GiB heap, mostly the write-back's int64 positions (~4.4 GiB at peak)
Trainer staging buffer 12.52 GiB 12.52 GiB -
Generator prefetch buffer 50.10 GiB 50.10 GiB -

The receive-buffer and pinned-allocator figures are measured (RSS and
torch.cuda.host_memory_stats() logged before and after each phase); the heap
figures are inferred from RSS growth and buffer sizes.

CPU threads

Each process uses Config.codec_threads codec threads (default 32). A GB300 host
has 144 CPUs and runs 4 ranks, each with a 72-CPU affinity, so 64 codec threads
per 72-CPU set.

Work Threads Time
Trainer compress 32 per trainer rank 0.18-0.24 s, overlapped with forward/backward
Generator decompress + pack 32 per generator rank 154-563 ms, within prefetch
Generator write-back into the prefetch buffer 32 per generator rank, saturated 32-40 s of thread time in 1.0-1.3 s, while serving

Testing

  • Unit tests: all 234 pass:
    pytest -q tests/rl/unit_tests/cpu/test_model_state_dict_transport.py
    plus the generator, engine-loop, trainer and router tests.
  • New tests (in test_model_state_dict_transport.py)
  • 2-GPU smoke: Qwen3-0.6B with delta sync.
  • 27B run: the tables above.

Known issues / follow-ups

  • Generator RSS:
    • Allocating _Group buffers at exact size would recover ~3 GiB (est.) but could slow the pull
    • Keeping write-back positions in int32 would recover ~2 GiB (est.).
  • Back-to-back pulls: when a push isn't overlapped with forward/backward, the
    previous write-back competes with the next decompress (one 1.72 s pull out of 6).
  • RDMA read count: about 215 per generator, vs 4 in Implement delta model state dict transport #6311. Records for pieces
    replicated over trainer TP are read from alternating ranks, which breaks up runs.
    Pull time isn't affected (RDMA wait 12-166 ms).

@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 21, 2026 00:15
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 21, 2026
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 21, 2026 00:49
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from f08c937 to 6d4e66d Compare November 21, 2026 00:49
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 21, 2026 00:49
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 21, 2026 03:52
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from 6d4e66d to e656bd5 Compare November 21, 2026 03:52
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 21, 2026 03:52
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 21, 2026 04:16
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 21, 2026 04:17
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from e656bd5 to abcc251 Compare November 21, 2026 04:17
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 21, 2026 06:44
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 21, 2026 06:44
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from abcc251 to 6b79270 Compare November 21, 2026 06:44
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 24, 2026 01:17
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 24, 2026 01:17
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from 6b79270 to 86e665d Compare November 24, 2026 01:17
@tushar00jain tushar00jain changed the title Implement delta model state dict transport with one record per staged piece Implement delta model state dict transport Nov 24, 2026
@tushar00jain

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tushar00jain's task in 5m 56s —— View job


Needs discussion -- three open PRs (#6309, #6311, #6176) implement delta sync, and the pull is already hidden at the measured scale; see the review for the config-selection, silent-full-read and private-import must-fixes.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Needs discussion -- three open PRs implement the same feature (#6309, #6311, #6176). Maintainers should pick one before line-level polish. At the scale measured here, the pull is already hidden behind forward/backward, so the value case still needs to be made.

What this PR does. Adds ModelStateDictDeltaTransport. After the first push, the trainer diffs its staging buffer against the previous push on the GPU, in 64 MiB windows. It then zstd-compresses one [gaps | XORs] record per changed staged piece into a registered delta buffer. Each generator rank RDMA-reads only its own pieces' records and XORs the changes in on the GPU during the load. CPU threads then write the same changes back into the prefetch buffers in the background.

Example. Qwen3.5-27B, push N+1 changes about 2% of the bf16 words.

  • Full sync: each generator reads 53.8 GB (2538 RDMA reads).
  • Delta sync: each generator reads about 1 GB (about 215 reads). It decompresses those, copies the push-N prefetch buffer to the GPU as before, and XORs the changed words in there.
  • Fallbacks to a whole read: first push, missed push, more than 1/16 of a window changed, or a buffer overflow.

Must fix

  1. PR description. "Summary (human-written)" is empty. Under Numerics, "Mean reward 0.277 vs 0.250" can only be run-to-run noise if the weights are bitwise identical. Say so, or drop it, and treat the 10.2k -> 10.7k tok/s (5 steps) result with the same caution.
  2. model_state_dict_transport.py:349 -- sync_mode string selects the subclass; use a Config subclass instead (config.md).
  3. model_state_dict_delta_transport.py:277 -- a trainer rank that stages nothing silently forces whole reads on every pull.
  4. model_state_dict_delta_transport.py:27 -- imports five _private names from the base module; decide now rather than leave a TODO.
  5. MODEL_STATE_DICT_DELTA_TRANSPORT.md:3 -- the doc says "main's" for the base class, has a typo, and leaves the fallback section empty.

Should consider

  • model_state_dict_delta_transport.py:254 -- casts the whole local shard once per piece per window; cast only the piece.
  • model_state_dict_transport.py:63 -- base metadata carries delta-only fields; move them to a delta subclass.
  • model_state_dict_delta_transport.py:408 -- pinned allocations on every pull through the caching host allocator (possible source of the unexplained generator RSS).
  • model_state_dict_delta_transport.py:54 -- 32 codec threads per rank, which at 8 ranks per node is 256 per node.

Questions

  • Which PR lands? #6311 (per-window records, also open) by your own numbers compresses 3x faster (0.08-0.12 s vs 0.23-0.35 s) and needs 4 RDMA reads instead of about 215, with "same pull time". #6176 is a third approach. The table compares against #6142 (closed), not #6311. Please close the PRs you are not pursuing, and coordinate with @wolfcomos on #6176.
  • Where does this matter? Blocking pull per step is 0-0.045 for full sync vs 0-0.032 for delta, and the pull (about 1.5 s) overlaps about 35 s of forward/backward. What configuration puts the pull on the critical path: more generators per trainer, lower bandwidth, or sync RL? A measurement or estimate there would justify the +1746 lines, the zstandard dependency, and the +5.6 / +17.8 GiB RSS on trainer / generator.
  • Is load_groups needed? It is plumbed through the engine ABC, vLLM, SGLang, the loader, the generator and the base connect_generator, and _Group exists only to batch one H2D copy and one cumsum per FSDP group. Was computing per-key positions on the CPU at decode time and copying them per key measured as too slow? That alternative would delete the plumbing in 6 files.
Details

Checked, and found no problems with:

  • Gaps -> positions. The running sum with per-piece shifts in _Group.pack / positions_on gives the right positions. Keys stay contiguous because the changes are sorted by key.
  • Window -> piece slicing. searchsorted over the sorted nonzero_static positions, plus the offset (window.lo - start) // 2, picks each piece's part of the window correctly.
  • Padding. The padding between pieces comes from old, so it never shows up as a change.
  • Odd-byte pieces. Rejected at connect_generator.
  • Ordering. The controller awaits pull N before push N+1 (controller.py:1430-1438), so overwriting the delta buffer in finish is safe. sources and metadata_by_trainer_rank both come from .values() on the same trainer mesh, so their orders match.
  • Unloaded reads. A read that was never loaded is written back by write_back_rest before the next read's deltas are applied.
  • Trainer restart. It resets push to 0, and the generator's push == last + 1 check forces a whole read.

Remaining assumption: every load is preceded by a read. A second load with no read in between would copy from the prefetch buffers while the background write-back is still running. The router never does this today, but nothing asserts it.

Not verified: GPU timings, the RSS attribution, and the thread oversubscription; these need a multi-rank-per-node run.

@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 24, 2026 06:29
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 24, 2026 06:29
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from 86e665d to cb0d20b Compare November 24, 2026 06:29
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 24, 2026 06:37
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 24, 2026 06:37
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from cb0d20b to 8994728 Compare November 24, 2026 06:37
@tushar00jain

Copy link
Copy Markdown
Contributor Author

@claude review again independent of discussion on what which implementation should be picked and mark resolved comments as resolved

@claude

claude Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tushar00jain's task in 4m 38s —— View job


Needs discussion: the earlier must-fix items are fixed. Three small items remain, and the choice between the PRs is still with the maintainers. I can't resolve review threads from this job, so the review lists which ones you can resolve. See the review.

@pytorch-bot pytorch-bot Bot added ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests labels Nov 24, 2026
@tushar00jain
tushar00jain marked this pull request as draft November 24, 2026 16:17
@github-actions
github-actions Bot requested a review from pzhan9 November 24, 2026 16:17
@pytorch-bot pytorch-bot Bot removed ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests labels Nov 24, 2026
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 24, 2026 16:24
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 24, 2026 16:25
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from 47779d4 to 534fd7a Compare November 24, 2026 16:25
@tushar00jain
tushar00jain marked this pull request as ready for review November 24, 2026 16:43
@pytorch-bot pytorch-bot Bot added ciflow/docker ciflow/fake-pg Run 1-GPU Fake PG integration tests labels Nov 24, 2026
… piece

Alternative to delta-weight-sync/1 (one record per 64 MiB window of the staging
buffer): with sync_mode="delta", each push after the first sends only the bf16
words that changed since the preceding push, as one zstd-compressed record per
staged piece: the gap before each changed word and the word XOR its old value.

The trainer compares each piece with its staging buffer on the GPU in chunks of
at most 64 MiB, which bounds its scratch memory, stages each changed word's
position and XOR, and finish_stage compresses one record per piece into a
registered delta buffer. The push returns a DeltaRecord per piece (offset, size,
gap width, count), which the controller forwards to the generators. A generator
rank reads the records of exactly the pieces it reads, decompresses them on CPU
threads, packs them per FSDP load group, and XORs them into the weights its load
copies; CPU threads then apply them to the prefetch buffers in the background.
The first push, a missed push, and a push with more than 1/16 of a chunk's words
changed are read whole.

fs-branch: tushar00jain/9
@tushar00jain
tushar00jain changed the base branch from main to fs-base/tushar00jain/9 November 24, 2026 19:16
@tushar00jain
tushar00jain changed the base branch from fs-base/tushar00jain/9 to main November 24, 2026 19:16
@tushar00jain
tushar00jain force-pushed the fs-head/tushar00jain/9 branch from 534fd7a to 0b802a4 Compare November 24, 2026 19:16
tianyu-l added a commit that referenced this pull request Nov 26, 2026
…er override; agent self-review; rl/transport (#6407)

## 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

Since #5667, `@claude review` has reviewed 459 PRs. Of the 380 PRs it
approved,
30 then got a formal "request changes" from a maintainer, and about 20
more got
substantive inline asks. In nearly all of them the bot either saw the
problem
and approved anyway, or never asked the questions maintainers ask most
("does
the repo already do this?", "who should own this?"). The opposite
failure, the
bot blocking something a maintainer was fine with, is rare: in the PRs
we
sampled, 2 of its 81 must-fix items were wrong and about a third were
minor
(the empty human-written summary was the biggest source).

**Example** (#6112, controller sizes the rollout worker pool):

```
before: bot approved 10 times; tianyu-l then blocked: "the controller reads
        rollouter.rollouts_per_worker to compute a count it hands back to the
        Rollouter -- violates encapsulation"
after:  same commit, new skill -> Request changes, must-fix #1:
        "controller.py:589 -- wrong owner for the worker count ..."
```

There was also no way for a code owner to overrule the bot except
dismissing
its review in the GitHub UI, and a later `@claude review again` would
block
again.

## What changed

**Review skill** (`.claude/skills/pr-review/`, `review-checklist.md`):
- Verdict rules: Approve only when every remaining item is an edit the
bot
could write itself. Anything the author still owes (a design change, an
unexplained golden change, evidence the PR rests on) is Request changes;
anything only a maintainer can decide is Needs discussion. A hedge like
"a
  maintainer should decide" can't come with Approve.
- Always must-fix: a violated written rule, a silent wrong result, a
second
  definition of an existing concept, a gate finding.
- Design gate: new questions for the existing counterpart, in-repo
ownership,
and the design behind a bug; "ban only what doesn't work on main"; read
the
numbers behind a claim. The overlapping-PR search is mandatory and
reported.
- Re-review covers every commit since the last full review, including
code
taken from the bot's own suggestions. A scoped question gets a
`COMMENT`, not
  a whole-PR verdict.
- The bot fact-checks its own proposed fixes, and cites a source for
claims
  about external tools or marks them unverified (never must-fix).
- An empty "Summary (human-written)" is a one-line "Before merge" note
that
  never affects the verdict.
- Checklist: config ownership direction, general shared wrappers, dead
code the
PR creates, model variants as flavors, a mechanical pass over every new
or
  changed function.

**Code owner override** (`SKILL.md`, `claude-code.yml`,
`CONTRIBUTING.md`): a
code owner comments `@claude override` (optionally `@claude override
2,3:
<reason>`); the bot approves if nothing else is open and doesn't
re-raise the
overridden items. A code owner's GitHub approval or "LGTM" is not an
override,
so a teammate can approve without the bot dropping its findings.
Dismissing the
bot's review still unblocks the PR, but isn't an override: the bot can't
tell
who dismissed it.

**Agent self-review** (`CLAUDE.md`, `pr-description`): an agent
preparing a PR
runs `pr-review` in branch mode first and records unaddressed items in
an
optional "Self-review" section. PRs written without an agent are
unaffected; a
missing section is never a finding.

Where each new rule comes from (maintainer asks the bot missed):

| Change | PRs |
| --- | --- |
| No Approve with open design/evidence items or a "maintainer should
decide" hedge | #6007, #5837, #5997, #5712, #5511, #5996 |
| Author waiver can't clear a must-fix | #6201, #6202, #6203 |
| Existing counterpart; one source of truth | #5228, #6169, #5881,
#5823, #5824, #6059, #5812 |
| Responsibility owner; config ownership direction | #6112, #6332,
#5802, #5803, #6325 |
| Fix the design behind the bug; a TODO doesn't justify a workaround |
#5572, #5689, #5657 |
| Fact-check the bot's own suggested fixes | #5740, #5802, #5511, #4819,
#5543 |
| Re-review covers all new commits; scoped asks don't approve | #5824,
#5842 |
| Mandatory overlap search | #5885, #6248 |
| Ban only what doesn't work on main | #5543 |
| Summary placeholder no longer a must-fix | #6119, #6174, #6112, #5868
|

**Rules**: `design.md` gets the one-general-wrapper rule (moved from
`models.md`, whose glob skipped `torchtitan/rl`), thin adapters, and the
consumer owning its values; `config.md` gets ownership direction and "a
Config
doesn't read runtime state"; `direction.md` calls all-to-all the MoE
reference
implementation, so a new vendor-specific dispatch path (e.g. #6242)
needs a
reason the existing backends can't serve.

**Area reviewers**: `.ci/` -> huydhn, wwwjn; `torchtitan/rl/transport/`
-> d4l3k.

**Mechanical, skim**: `torchtitan/rl/transport/` holds data movement
between RL
actors.
- `rl/model_state_dict_transport.py` ->
`rl/transport/model_state_dict.py`
- `rl/MODEL_STATE_DICT_TRANSPORT.md` ->
`rl/transport/MODEL_STATE_DICT_TRANSPORT.md`
- `rl/trainer/rdma_microbatch.py` -> `rl/transport/rdma_microbatch.py`
- tests:
`tests/rl/unit_tests/cpu/test_{model_state_dict_transport,rdma_microbatch}.py`
->
`tests/rl/unit_tests/cpu/transport/test_{model_state_dict,rdma_microbatch}.py`
- imports, READMEs and `scripts/install_rl_env.sh` updated; no code
changes.

## User-facing changes

| Before | After |
| --- | --- |
| Overrule the bot: dismiss its review in the UI, and it blocks again on
the next run | `@claude override [items]: <reason>`; the bot approves
and doesn't re-raise them |
| Empty human-written summary: bot must-fix | One "Before merge" line,
no effect on the verdict |
| `from torchtitan.rl.model_state_dict_transport import ...` | `from
torchtitan.rl.transport.model_state_dict import ...` |
| `from torchtitan.rl.trainer.rdma_microbatch import ...` | `from
torchtitan.rl.transport.rdma_microbatch import ...` |

## Testing

Backtest: the new skill run locally (nothing posted) on each PR at the
commit
and thread state the bot originally saw.

| PR | Bot then | New skill | What the maintainer asked |
| --- | --- | --- | --- |
| #6112 | Approve | Request changes | worker-count ownership (caught) |
| #5837 | Approve | Request changes | apply to `dp_shard` too (caught) |
| #5572 | Approve | Request changes | delete the injection design
(caught) |
| #6201 | Approve after author waived pins | Request changes, waiver
ignored | pins broke GPU tests after merge (caught) |
| #6007 | Approve | Request changes | fold K3.1 into K3 (caught) |
| #5543 | Request changes: "ban it" | Request changes: keep main's path
| don't break gpt-oss + DeepEP (fixed) |
| #6144, #5905 (controls) | Approve | Approve | -- |
| #6137 (control) | Approve | Needs discussion | -- (merge gate on an
upstream API) |

Code owner override, simulated on #6201: override by a code owner lifts
the
named item; `@claude override` from the author changes nothing; a code
owner's
"LGTM" approval followed by "review again" keeps Request changes.

Transport move: 83 RL CPU unit tests pass locally
(`transport/test_model_state_dict.py`, `test_trainer.py`,
`test_engine_loop.py`). `transport/test_rdma_microbatch.py`,
`test_generator.py` and
`test_batcher_actor.py` fail to collect in my env on `origin/main` too
(stale
attention-gym / Monarch), so CI is the check for those.

## Known issues / follow-ups
- Open PRs that edit the moved files rebase cleanly (git follows the
renames),
but new imports of the old module paths will break: #6309 (adds a delta
transport that should live in `rl/transport/`), #6237, #6176, #6177,
#5862,
  and drafts #6127, #6393, #6163, #5764.
- The Actions bot can't read dependency source (e.g. SGLang); follow-up
for the
  workflow.

## Self-review
pr-review (branch mode) at ad905a5: Needs discussion. Fixed: branch
mode diffs
against `origin/main` and skips description findings before a
description
exists; the "Config doesn't read runtime state" rule no longer
contradicts
hardware validation; dismissal dropped as an override form (the bot
can't tell
who dismissed); `test_rdma_microbatch.py` added to the transport area.
Not
addressed:
- One concern per PR -- the five changes ship together at the
maintainer's
  request.
- Open PRs touching the moved files -- listed above; the maintainer will
  coordinate.
assert self._trainer_delta is not None
return self._trainer_delta.compress_records()

def connect_generator(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is used by "gpu-fetch" in #6237, so it seems delta transport support both "cpu_prefetch" and "gpu_fetch" right? The diagram in PR summary seems only showing the "cpu_prefetch" path.

It's a bit hard for me to understand the details from the code. Maybe a system diagram using @felipemello1 's skill could help? https://artifacts.internalmeta.com/?source=favorites&cards=1481387240597243&full=0

In general I have some high level questions for both paths

@tushar00jain tushar00jain Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check out torchtitan/rl/MODEL_STATE_DICT_DELTA_TRANSPORT.md? it has a walkthrough with diagrams

where does the compression / decompression happen?

on the cpu in this pr - that's why the xor delta is sparse. a full xor was too slow on cpu

where do we store the generator base checkpoint

this is only for the path where we transfer from trainer gpu to generator cpu - so we're just using the buffer that already exists

the new buffers added in this pr are both bounded to the size of the largest fsdp group - that should be smaller relative to model size?

maybe we can add disk storage separately as a follow up? seems independent of delta i.e. we probably need to stream the existing cpu buffer to disk

overall a comparison

there's a table in the pr description though I can add more details

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check out torchtitan/rl/MODEL_STATE_DICT_DELTA_TRANSPORT.md? it has a walkthrough with diagrams

Sorry I couldn't follow the .md -- could you make it more accessible? Aside from the .md, I'm interested in learning justifications of the design choices you made.

there's a table in the pr description though I can add more details

I did see some table, but I didn't see the comparison with Humans& or Miles. Related to above point, I would love to understand where we are different from them.

Maybe we should also have an interactive session?

@wolfcomos wolfcomos Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, quick question adding to the discussion above: does current delta transport leave room for an accelerator option later, where the trainer encodes on the GPU/accelerator and the generator decodes and applies the changes in place into its live weights? Not for this PR, just a seam to plug it in.

self._windows = []
for (lo, hi), window_piece_list in zip(bounds, window_pieces):
capacity = _delta_capacity(hi - lo, capacity_divisor)
positions = pinned_buffer(capacity * torch.int32.itemsize)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original tensors' finalizers unpin these buffers while their int32 and int16 views are still alive, so the GPU-to-CPU copies block during staging. could we keep the original positions, XOR, and count buffers alive alongside their views?

(`old`), assemble this push's window (`new`), stage the changes, then write
`new` back.

Comparing one window at a time bounds the trainer's GPU memory: the temporaries

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locally a 64MB window peaked at about 400MB of GPU scratch, including a 256MB int64 temporary from changed.sum(). could we avoid widening the mask and update the 180MB estimate here?

"""Each 64 MiB window of the staging buffer sends at most 1 /
``capacity_divisor`` of its words; a push with more changes in a window is
read whole. It sizes the trainer's pinned buffers of changes and the
registered delta and receive buffers (1 / (2 x ``capacity_divisor``) of the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the buffers reserve 4 bytes per changed 2-byte word they allow, so a 64MB window needs 8MB at the default divisor of 16 rather than the 2MB the docstring implies. could we update the docstring to match?

|
| load_groups = [["wq", "wk"], ...] -> both in group 0
v
_Group.pack (pinned buffers, one per group)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the packing example should start with wk because _Group.pack sorts by key, and _pending is keyed by load group index. could we update the example and show that the last load group contains model buffers in their original dtypes?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker 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

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants