Skip to content

[rl] Rollout groups reach the trainer by RDMA handle - #6323

Closed
wwwjn wants to merge 2 commits into
wwwjn/data-plane/4-trainer-packsfrom
wwwjn/data-plane/5-group-rdma-handle
Closed

wwwjn wants to merge 2 commits into
wwwjn/data-plane/4-trainer-packsfrom
wwwjn/data-plane/5-group-rdma-handle

Conversation

@wwwjn

@wwwjn wwwjn commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Human note: TODO (Jiani)
6323_flow

TLDR: Rollout workers can keep each large training group in a registered buffer and return only a handle (opt-in BaseRolloutWorker.Config.rdma_min_group_bytes); each DP replica leader reads its rollouts over torch transport (NIXL). The controller then moves none of those bytes, an enabler for large payloads (top-k logprobs, routed experts, images). At 4K score-centering completions, the leader's column hop drops 556 -> 12 ms and send_replica_columns 783 -> 20 ms per step.

# PR Independent? Needs
0 RDMA object for microbatches and prompts (#5862) yes -
1 Rollout workers compute each group's rollout metrics and recorder lines (#6301) yes - (stacked on 0 for merge order only)
2 Split the batcher into a metadata half and a bytes half (#6302) yes 0 (its batcher code)
3 Trainer DP replica leaders pack their own microbatches from the plan (#6303) no 1, 2
4 Rollout groups reach the trainer by RDMA handle (#6323, this PR) no 3
5 Read the next step's rollout groups during the optimizer step (#6324) no 3 (stacked on 4 for merge order only)
6 Prompt image files share the rollout worker's torch transport pool (#6334) no 4 (stacked on 5 for merge order only)

Merge bottom-up. #6269 is on main and independent of this stack.

Problem

  1. After [WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303, every training group's serialized bytes cross the controller twice by value: in the worker's run_group reply, then in each DP replica leader's column.
  2. With score centering at k=32, a 16-rollout group packs to 17.3 MB at 4K completions; at 32 groups per step, each leader's column is 277 MB (dp 2), pickled on the controller's event loop.
  3. Cost: the column hop takes 556 ms per leader and send_replica_columns 783 ms per step, before the trainer's first microbatch; controller RSS reaches 2.18 GB and its event loop stalls up to 416 ms.

Solution

  1. Worker. Packs each training group of at least rdma_min_group_bytes (about 1 MiB suggested; many small reads cost more than sending the bytes) into a registered torch transport (NIXL) buffer.
  2. Reply. serialize_rollout_group gains allocate and region_padding; the worker tags each region with (group_id, generation) and replies with the metadata and a SerializedRolloutGroupHandle (rollout/serialized_group_handle.py), not the bytes.
  3. Controller. Keeps the handle where [WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303 keeps the serialized group and sends each leader its plan column plus only the handles it names (ReplicaColumn.rollout_group_handles).
  4. Leader. Before its first microbatch, reads its regions with RemoteBuffer.slice (all in flight, adjacent ones merged), checks the tags, then runs [WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303's unchanged deserialize_rollout_group (read_serialized_rollout_group_handles).
  5. Pool. torch_transport_rdma.RegisteredBufferPool never unregisters (a NIXL reader keeps stale metadata, [torch.distributed._transport] NIXL: unregister_memory does not invalidate a reader's loaded sections, so a new registration over a freed range fails with NIXL_ERR_NOT_FOUND pytorch#206300) and gives a group the smallest free buffer that fits; after the weight pull, Rollouter.release_groups returns buffers.
  6. Setup. Knob off keeps [WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303's by-value path. Knob on: each leader probes every worker at setup; a failed read or a 60 s timeout raises ValueError naming the hosts.
before:  worker --metadata + regions--> controller --column: regions--> leader: deserialize, pack
after:   worker: pooled buffer --metadata + handle--> controller --column: handles--> leader: slice read, deserialize, pack
         after pull N: controller --release(group ids)--> every worker: buffers back to its pool

Results

4K, Qwen3-0.6B alphabet sort, score centering (k=32), 32 prompts x 16, 8 GPUs, steps 3-8; knob off -> on (=1)
  receive_replica_column transfer per leader   556 ms  -> 12 ms
  send_replica_columns per step                783 ms  -> 20 ms
  leader read, inside first-microbatch wait    -       -> 234 ms (wait 109 -> 321 ms; #6324 hides it)
  controller RSS                               2.18 GB -> 1.52 GB
  controller event-loop lag max                416 ms  -> 14 ms
correctness vs main af04091d6 (seed 42, 10 steps), non-timing TensorBoard tags equal: TP 2 off 52/52, on 52/52; PP 2 x FSDP 2 off 53/53 (#6324's head)

NOTE:

Test plan

  • pytest tests/rl/unit_tests/cpu: 813 passed, 8 skipped, 4 failed ([WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303: 793 passed), with nixl installed so the requires_nixl tests run. The 4 failures also fail on main 076f2e88b (770 passed): recipe tests whose torch_checkpointing.storage.fsspec_storage import fails in the local env.
  • pytest tests/rl/unit_tests/gpu/test_cp_images.py (2 A100s, this head): 4 passed.
  • test_nixl_reads_slices_after_freeing_small_buffers_for_larger_ones: the stale-section sequence through the pool over real NIXL, every byte checked; without the pool it fails with NIXL_ERR_NOT_FOUND.
  • test_a_request_takes_the_smallest_free_buffer_that_fits: fails when a group takes only its own size class.

@wwwjn

wwwjn commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 5m 13s —— View job


Needs discussion: see the review (a maintainer still needs to review).

@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 -- the RDMA path is careful and the release ordering checks out, but the maintainers need to decide two things first: whether to add a third RDMA mechanism alongside Monarch RDMAObject and ModelStateDictTransport, and whether to land about 1,000 source lines before their payload consumers (#5760, #5255) and without a step-time gain. The description's numbers also predate the rebase.

What this PR does. With rdma_min_group_bytes set, each rollout worker packs every large training group into a pooled buffer registered with NIXL and returns only a handle. The controller forwards each DP leader just the handles its plan column names. The leader slice-reads those regions, checks the (group_id, generation) tags, and unpacks them as before. After pull N, the controller broadcasts the trained group ids, and each worker returns those buffers to its pool. The pool never unregisters a buffer.

Example. A 16-rollout group is 69 MB at 16K, with dp=2.

before: worker --summary + 69 MB--> controller --(rollouts 0-7, 34 MB)--> leader 0
                                               --(rollouts 8-15, 34 MB)--> leader 1
after:  worker packs into pool buffer B (80 MiB class)
        --summary + handle(B, offsets)--> controller --handle.select({0..7})--> leader 0
                                                     --handle.select({8..15})--> leader 1
        leader 0: read B[tag|r0|tag ... tag|r7|tag] in one merged range -> unpack
        after pull N: release_groups([g]) -> worker puts B back on its 80 MiB free list

Must fix

  1. Description. "Human note: TODO" still needs the author's summary. Every number, and the bitwise run (fe7b58297), predates the rebase ("reruns pending"). Before merge, please rerun loss/grad_norm bitwise at HEAD with the knob off and on (TP 2, and PP 2 x FSDP 2).
  2. A third RDMA path in one worker (design). With images, a worker now registers the same image bytes twice: once as a Monarch RDMAImageFiles for generators (rdma_min_image_bytes), and once in the packed-group pool for leaders. A whole-value read is just a slice read of the full range. The generators already run a torch transport for ModelStateDictTransport. So one RDMAByteBuffers per worker could plausibly serve both readers, and that would delete rl/rdma_object.py + actors/monarch/rdma_object.py (about 264 lines) and one of the two knobs. Please either build the shared version, or say in the PR why generators can't read from the pool.
  3. torch_transport_rdma.py:79 -- the TODOs need upstream issue links (inline).
  4. test_torch_transport_rdma.py:12 -- points at a reports/ path that isn't in the repo (inline).

Should consider

  • controller.py:620 -- _handle_group_ids and the failure-path release can go: broadcast all ids when the knob is on (inline).
  • packed_group_handle.py:93 -- select duplicates PackedRolloutGroup.select (inline).
  • controller.py:1685 -- three always-zero metric keys with the knob off (inline).
  • torch_transport_rdma.py:198 -- the backend is hardcoded to NIXL, while the sibling transport defaults to Mooncake (inline).
  • test_torch_transport_rdma.py:137 -- trim the low-value tests (inline).
  • trainer.py:347 -- check_rdma_probes also creates the leader's transport. Leader reads silently depend on the probe having run first. Create RDMAByteBuffers explicitly where the knob is known, and keep the probe a check.

Questions

  • Most of the measured win is the controller leaving the data path: RSS 2.89 -> 1.52 GB, loop lag 492 -> 21 ms, and the column hop. Meanwhile the leader read (243 ms) moves into the first-microbatch wait. Did you compare against workers pushing each leader its rollouts by value, worker -> leader with no controller hop? That would avoid the pool, the tags, the probe and the NIXL workaround.
Details
  • Release order. I traced it and it holds. Step N's reads finish inside forward_backward N. _release_groups(trained) runs in _pull_model_state_dict_and_release_groups, after push N and pull N. Untrainable groups are never in a column. A failed group is finalized as an empty group, the batcher marks it untrainable, and that releases its id again (which is why the explicit failure-path release becomes redundant once releases broadcast every id).
  • Worker thread safety. run_group packs synchronously on the actor's event loop, and so does release_groups, so the pool's one-thread rule holds.
  • Stale bytes in reused buffers. The alignment gaps inside reused buffers keep stale bytes. unpack_rollout_group reads only headers, arrays and images, so this doesn't affect numerics.

Not verified: cross-host InfiniBand reads (the PR says these weren't run end to end), and whether the knob-off TensorBoard tags match main at HEAD.

Comment thread torchtitan/rl/torch_transport_rdma.py Outdated
Comment on lines +79 to +83
# TODO: free idle buffers once torch transport invalidates a reader's loaded sections when their
# owner unregisters them. Today it does not (module docstring), so freeing a buffer a reader has
# read can make a later buffer at the same addresses unreadable; that is why this pool never
# unregisters, and why its memory never shrinks. A pytorch/pytorch issue is to be filed; add its
# link here.

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 whole pool design (never unregister, size classes, a footprint that never shrinks) works around an upstream bug: a reader's cached sections aren't invalidated when the owner unregisters. This TODO says the issue is "to be filed", and the one at line 40 for the private torch.distributed._transport API says "no upstream issue yet". Principle 3 asks for an issue link on both. Please file the NIXL/torch-transport issue (the PR body says a repro is drafted) and link it in both TODOs before merge. Then the pool's memory cost has a tracked way out.

try:
from torch.distributed._transport import new_transport

transport = new_transport("nixl", "cpu")

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 backend is hardcoded to "nixl", but the sibling ModelStateDictTransport.Config.backend defaults to "mooncake" (model_state_dict_transport.py:326). So a run on the default weight transport that turns this knob on needs a second RDMA stack installed and working on every worker and leader. Two questions:

  • Does the stale-section bug that motivates the never-unregister pool also happen on Mooncake? If it doesn't, the pool's design constraint is NIXL-specific, and the docstrings should say so.
  • Why not use the same backend as ModelStateDictTransport, or one Literal["mooncake", "nixl"] choice shared by both? If only NIXL works here, say so in the knob's docstring and raise at config time when model_state_dict_transport.backend != "nixl", rather than at setup.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +618 to +620
# Groups that stay in a rollout worker (`BaseRolloutWorker.Config.rdma_min_group_bytes`):
# releasing one tells the workers.
self._handle_group_ids: set[int] = set()

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.

_handle_group_ids can go. RolloutGroupBuffers.release already ignores ids its worker doesn't hold, and every worker gets every id. So _release_groups can broadcast whenever the knob is on:

await self._group_buffer.release_slots(group_ids, reason=reason)
if self.config.rollouter.worker.rdma_min_group_bytes is not None:
    self._rollouter.release_groups(group_ids)

That deletes this set, the isinstance(..., PackedRolloutGroupHandle) bookkeeping at 1347-1348, and the filter at 1735-1740. It also makes the explicit release in the _rollout_loop failure branch (around line 1292) redundant: the replacement empty group is finalized, the batcher marks it untrainable, and the untrainable_group release then broadcasts its id. The cost is a few dozen ints per step to each worker.

Comment on lines +93 to +122
def select(self, rollout_ids: set[int]) -> PackedRolloutGroupHandle:
"""Only the rollouts in `rollout_ids` and the images they show, as
`PackedRolloutGroup.select`."""
kept = [
index
for index, rollout_id in enumerate(self.rollout_ids)
if rollout_id in rollout_ids
]
if len(kept) == len(self.rollout_ids):
return self
image_hashes = {
hash_value
for index in kept
for hash_value in self.rollout_image_hashes[index]
}
return PackedRolloutGroupHandle(
buffer=self.buffer,
group_id=self.group_id,
generation=self.generation,
rollout_ids=tuple(self.rollout_ids[index] for index in kept),
rollout_regions=tuple(self.rollout_regions[index] for index in kept),
rollout_image_hashes=tuple(
self.rollout_image_hashes[index] for index in kept
),
image_regions={
hash_value: region
for hash_value, region in self.image_regions.items()
if hash_value in image_hashes
},
)

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 is a line-for-line copy of PackedRolloutGroup.select (packed_group.py:95-123). The two classes share group_id, rollout_ids, rollout_regions, rollout_image_hashes and image_regions, and differ only in the region type plus buffer/generation. One shared implementation would do. For example, put a module-level helper in packed_group.py that returns the four selected fields, and have both selects call dataclasses.replace(self, **selected). Or make PackedRolloutGroup generic over its region type, so the handle is PackedRolloutGroup[PackedRegion] plus two fields.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +1685 to +1689
# What each leader reads from the rollout workers instead (groups that stay there).
m.Metric(
"payload/replica_column_rdma_bytes",
m.Mean.from_list(column_rdma_bytes),
),

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.

With the knob off (the default), this PR still adds three metric keys that are always 0: payload/replica_column_rdma_bytes here, plus timing/trainer/read_rollout_groups/max and payload/trainer_read_bytes/max in trainer.py:455-460. The latter two also widen the max all-reduce on every step. The description says knob-off "non-timing TensorBoard tags equal main", but that was measured on fe7b58297, and these payload/ tags are non-timing. Please emit them only when rdma_min_group_bytes is not None.


Most tests use `LoopbackTransport`, an in-process stand-in for torch transport. The tests marked
`requires_nixl` use the real NIXL backend (two transports in this process) and skip without it;
locally, run them with the nixl overlay (reports/19_rl_data_plane/14, section "Environment").

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.

reports/19_rl_data_plane/14 isn't in the repo; it looks like a private notes path. Point to torchtitan/rl/MODEL_STATE_DICT_TRANSPORT.md, which documents the nixl==1.5.0 / nixl-cu13 install, or to scripts/install_rl_env.sh.

Comment on lines +137 to +146
def test_buffer_size_class_rounds_up_by_at_most_a_quarter() -> None:
assert buffer_size_class(1) == 64 * 1024
assert buffer_size_class(64 * 1024) == 64 * 1024
assert buffer_size_class(64 * 1024 + 1) == 80 * 1024
assert buffer_size_class(16 * MiB) == 16 * MiB
assert buffer_size_class(17 * MiB) == 20 * MiB
assert buffer_size_class(66 * MiB) == 80 * MiB
for num_bytes in range(64 * 1024, 64 * MiB, 997 * 1024 + 13):
size = buffer_size_class(num_bytes)
assert num_bytes <= size <= num_bytes * 1.25

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 file is 401 lines for a 339-line module, and several tests don't guard an invariant that would break silently:

  • test_buffer_size_class_rounds_up_by_at_most_a_quarter re-asserts the docstring's constants.
  • test_a_buffer_released_twice_asserts tests an assert.
  • test_a_torch_transport_that_fails_to_start_..., test_a_probe_read_that_fails_... and test_a_probe_that_reads_wrong_bytes_... check error-message substrings.
  • test_a_released_buffer_is_reused_only_by_its_size_class and test_a_request_no_free_buffer_fits_... are covered by the random-workload half of test_registered_bytes_are_each_size_classes_peak_in_use.

The ones that earn their cost are the real-NIXL stale-section and reuse tests, the peak-in-use bound, and the "later submission raises, earlier reads still awaited" test. Please trim to those (.claude/rules/tests.md).

@wwwjn

wwwjn commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 1m 38s —— View job


Needs discussion: see the review. A maintainer still needs to review.

@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 -- 6d3bc1d fixes most of the earlier code findings. Still open: the description, the TODO links, a GPU test the new required Trainer argument breaks, and the maintainers' call on a third RDMA mechanism.

What changed since the last review. Releases now go to every worker whenever the knob is on, and the controller's _handle_group_ids bookkeeping is gone. A failed group is released through the untrainable path. Both selects share selected_rollout_fields. The three RDMA metric keys, and the wider max all-reduce, appear only with the knob on. Leaders create RDMAByteBuffers in Trainer.__init__. The knob docstring says NIXL is required. The low-value tests are trimmed.

Example (release path at HEAD).

group 7 kept in worker A; its run_group reply fails in the controller
  before: controller -> release_groups([7]) right away (explicit failure branch)
  after:  finalized empty -> batcher: untrainable -> _release_groups([7]) -> broadcast
          worker A: frees its buffer; worker B: pop(7, None) -> ignored

Resolved

  • controller.py: _handle_group_ids and the failure-path release are removed.
  • packed_group_handle.py: the duplicate select is gone.
  • controller.py / trainer.py: the always-zero metric keys are logged only with the knob on.
  • trainer.py: the transport is created at construction, and the probe is only a check.
  • NIXL backend: the knob docstring documents it.
  • test_torch_transport_rdma.py: the tests are trimmed, and the reports/ path now points to scripts/install_rl_env.sh.

Must fix

  1. Description (still open). "Human note: TODO" is still there. Every number and the bitwise run (fe7b58297) predate the rebase. Please rerun loss/grad_norm bitwise at HEAD with the knob off and on (TP 2, and PP 2 x FSDP 2) before merge.

  2. tests/rl/unit_tests/gpu/test_cp_images.py:244 (new). Trainer.__init__ now requires a keyword-only rollout_groups_by_rdma: bool with no default (trainer.py:168). This call still omits it, so every test_cp_images case fails with TypeError before it tests CP. The rl_cpu suite can't catch this. Add rollout_groups_by_rdma=False there. That is the only other direct Trainer(...) call; test_trainer.py:212 is updated.

  3. torch_transport_rdma.py:40 and :79 (still open). Both TODOs still have no upstream issue link ("no upstream issue yet" / "to be filed"). The never-unregister pool, and a memory footprint that never shrinks, depend on that issue being tracked.

  4. A third RDMA path in one worker (maintainer decision). The description now explains why generators keep Monarch RDMAObject:

    • the two buffers are never live together;
    • moving images would add a second torch transport in each generator, next to ModelStateDictTransport's;
    • it would change #5862's image path.

    These are costs, not blockers. The two buffers never being live together also argues for one pool. A maintainer needs to accept a worker that runs both Monarch RDMABuffer and a NIXL pool, plus two knobs, or ask for the shared version. That version would delete rl/rdma_object.py, actors/monarch/rdma_object.py and rdma_min_image_bytes.

Questions

  • An untrainable group now triggers one release_groups broadcast to every worker, per group, at add_group time. That is fine at 32 groups per step. Did the 256-groups-per-step T1 run (4.6 KB groups) run with the knob on at this HEAD? If so, did per-group broadcasts show up in controller loop lag?
Details
  • Release correctness at HEAD. RolloutGroupBuffers.release pops with a default (packed_group_handle.py:194), so ids a worker doesn't hold, and repeated ids, are no-ops. A worker frees a buffer only for an untrainable group (never in a column) or a trained group after pull N, and step N's reads end inside forward_backward N. That ordering is unchanged from the last review.
  • Metric all-reduce. _rollout_groups_by_rdma comes from one config value that every rank receives, so the max_reduced_timing keys and their order match across ranks.
  • Trainer construction. self._is_replica_leader is assigned at trainer.py:252, before the RDMAByteBuffers() construction at :279. A missing NIXL now raises at trainer spawn, on leaders only.

Not verified: GPU and cross-host runs, and whether the knob-off TensorBoard tags match main at HEAD. A maintainer still needs to review.

@wwwjn

wwwjn commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 43s —— View job


Needs discussion: see the review. The GPU test fix and the bitwise rerun at HEAD are resolved. Still open: the human summary, the upstream issue links in the TODOs, and the maintainers' call on adding a third RDMA mechanism. A maintainer still needs to review.

@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 -- a82926d fixes the GPU test break, and the description now has numbers and a bitwise run at HEAD. Still open: the human summary, the two upstream issue links, and the maintainers' call on a third RDMA mechanism.

What changed since the last review. The only new commit, a82926d, adds rollout_groups_by_rdma=False to the Trainer(...) call in test_cp_images.py. That was the last direct construction left without it; test_trainer.py was already updated. The description was rewritten: the 4K and T1 runs are on this head (plus #5235), and loss/grad_norm match main bitwise at a82926d47, knob off and on, at TP 2 and at PP 2 x FSDP 2. It also now answers the release-broadcast cost question.

Example (what the remaining decision is about).

one rollout worker with images, rdma_min_image_bytes and rdma_min_group_bytes set
  prompt time: image files -> Monarch RDMABuffer        (read whole by generators)
  after score: packed group -> NIXL RegisteredBufferPool (slice-read by DP leaders)
  -> two RDMA stacks and two knobs in one process, plus ModelStateDictTransport (Mooncake by default)

Resolved

  • tests/rl/unit_tests/gpu/test_cp_images.py:255 now passes rollout_groups_by_rdma=False.
  • Description numbers and the bitwise check are now measured at HEAD. The 16K GB300 numbers are still from an earlier version, and the description says so.
  • Question on per-group untrainable broadcasts: answered, at about 31 us per call. The T1 knob-on loop lag max was 81 ms, inside the knob-off range of 63-95 ms.

Must fix

  1. Description (still open). "Human note: TODO (Jiani)" still needs the author's summary.
  2. torchtitan/rl/torch_transport_rdma.py:40 and :83 (still open). Neither TODO has an upstream issue link: they still say "no upstream issue yet" and "to be filed". The pool's never-unregister design, and its memory that never shrinks, depend on that issue being tracked.
  3. A third RDMA path in one worker (still open, maintainer decision). A maintainer needs to either accept a worker that runs Monarch RDMABuffer for images and a NIXL pool for groups, with two knobs, or ask for one shared pool. A shared pool would delete rl/rdma_object.py, actors/monarch/rdma_object.py and rdma_min_image_bytes. The description's reasons for keeping the two paths apart are costs, not blockers.

Not verified: the cross-host InfiniBand reads, and the GPU test run at HEAD. A maintainer still needs to review.

@wwwjn

wwwjn commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 39s —— View job


Needs discussion: see the review. The upstream issue links are now resolved. Still open: the human summary and the maintainers' call on adding a third RDMA mechanism. A maintainer still needs to review.

@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 -- 422dca6 links the upstream unregister issue, so the code-level must-fix items are all resolved. Two items remain: the human summary, and the maintainers' call on adding a third RDMA mechanism.

What changed since the last review. The only new commit, 422dca6, changes comments only, in torchtitan/rl/torch_transport_rdma.py:

  • The pool's never-unregister TODO (:79) now links pytorch/pytorch#206300.
  • The private-API TODO (:40) now points to the matching TODO in model_state_dict_transport.py:24-26.

Example (what the remaining decision is about).

one rollout worker with images, rdma_min_image_bytes and rdma_min_group_bytes set
  prompt time: image files -> Monarch RDMABuffer         (read whole by generators)
  after score: packed group -> NIXL RegisteredBufferPool (slice-read by DP leaders)
  -> two RDMA stacks and two knobs in one process, plus ModelStateDictTransport (Mooncake by default)

Resolved

  • torch_transport_rdma.py:79: the never-unregister pool, and its memory that never shrinks, are now tied to pytorch/pytorch#206300.
  • torch_transport_rdma.py:40: this follows main's existing TODO for the same private torch.distributed._transport API, which also has no issue. One upstream issue covering both TODOs would be better, but this PR need not block on it.

Must fix

  1. Description (still open). "Human note: TODO (Jiani)" still needs the author's summary.

  2. A third RDMA path in one worker (still open, maintainer decision). A maintainer needs to choose one of two options:

    • Accept a worker that runs a Monarch RDMABuffer for images and a NIXL pool for groups, with two knobs.
    • Ask for one shared pool. That would delete rl/rdma_object.py, actors/monarch/rdma_object.py and rdma_min_image_bytes.

    The description's reasons for keeping the two paths apart are costs, not blockers. They are: the buffers are never live together, a second torch transport would sit in each generator, and #5862's image path would change.

Not verified: the cross-host InfiniBand reads, and the GPU test run at HEAD. A maintainer still needs to review.

@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 422dca6 to 2d045e0 Compare November 23, 2026 20:35
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 25dead1 to 4e38191 Compare November 23, 2026 20:35
@wwwjn
wwwjn added this pull request to stack #6343 November 23, 2026 21:31
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 4e38191 to 770c439 Compare November 24, 2026 17:53
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 2d045e0 to 295ae89 Compare November 24, 2026 17:53
@wwwjn
wwwjn removed this pull request from stack #6343 November 24, 2026 20:05
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 295ae89 to 93aef80 Compare November 24, 2026 20:05
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 770c439 to 376acf8 Compare November 24, 2026 20:05
@wwwjn

wwwjn commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 1m 9s —— View job


Needs discussion: see the review. The knob-on bitwise run is now done at this head. Two things are still open: your human summary, and the maintainers' call on landing this before the features that use it. A maintainer still needs to review.

@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 -- the knob-on bitwise run now has numbers at this head, and the only new code is a comment fix. Two things are left: the author's summary, and the maintainers' call on landing this enabler before the features that will use it.

What changed since the last review. The stack was rebased again. The parent is now f924ca2, with the same title as the earlier 010822b. This PR has two commits:

  • 1bfff77, the handle commit. Its size is the same as the a0373e8 I reviewed last round, and I found nothing new in it. I couldn't fetch a0373e8 to diff the two directly.
  • 2476778, which changes one comment in controller.py:1492: "By value: the leaders now hold the bytes" becomes "...these groups' bytes (or handles)". The new wording is correct for both paths.

The description now gives TP 2 bitwise results against main at this head, knob off and knob on: 52/52 tags, plus the 3 pool_* tags with the knob on, and matching rollout_samples.jsonl md5s.

Example (what the knob-on bitwise run now covers at this head).

rl_grpo_qwen3_0_6b_varlen_batch_invariant, seed 42, 10 steps, TP 2
  knob off: column carries PackedRolloutGroup bytes     -> 52/52 tags == main
  knob on:  column carries PackedRolloutGroupHandle(s)  -> leader slice-reads -> unpack
                                                         -> 52/52 tags == main (+3 pool_* tags)
  PP 2 x FSDP 2: knob off only, at #6324's head

Resolved

  • Knob-on bitwise at this head. The Results section and the NOTE now say the knob-off and knob-on runs ran at this head, so the TLDR claim is backed.

Must fix

  1. Description (still open). "Human note: TODO (Jiani)" still needs your own summary; agents don't write that part. It should make the case for merging: this is an enabler for #5760, #5255 and image payloads, with no step-time gain yet (238.0 vs 238.3 s at 4K, 1118 vs 1116 s at 16K).

Should consider (still open from last round)

  • torchtitan/rl/trainer/microbatch_group_reader.py:81 and :132 -- ReplicaColumn.rollout_group_handles still defaults to [], and MicrobatchGroupReader(rdma_byte_buffers=None) still has a default. Both callers always pass them (controller.py:1651, trainer.py:421). Without the defaults, a call site that forgets them fails loudly instead of silently dropping handles.
  • tests/rl/unit_tests/cpu/test_rollout_worker.py:453 -- test_rdma_min_group_bytes_must_be_none_or_positive only matches the error message of a one-line __post_init__ check, so it can go.

Questions

  • Landing before the consumers (maintainer decision, still open). This adds about 1,000 source lines and a NIXL dependency for leaders and workers, with the knob off by default. Should it land now, or together with #5760 / #5255? The shared image pool (#6334) is a separate choice.

Not verified: the GPU suite at this head, and cross-host InfiniBand reads. A maintainer still needs to review.

@wwwjn

wwwjn commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 44s —— View job


Needs discussion: see the review. The last two code suggestions are fixed: the defaults are removed and the message-only test is deleted. Still open: your human summary, and the maintainers' call on landing this before the features that use it. A maintainer still needs to review.

@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 -- 4e5c82b resolves both should-consider items from last round, and every code-level finding is now resolved. Two things are left: the author's summary, and the maintainers' call on landing this enabler before the features that will use it.

What changed since the last review. One new commit, 4e5c82b:

  • ReplicaColumn.rollout_group_handles no longer has a default (microbatch_group_reader.py:81), and neither does MicrobatchGroupReader(rdma_byte_buffers=...) (:133).
  • Every call site now passes both explicitly: controller.py:1644, trainer.py:415, the docstring examples, test_async_controller.py:199, test_microbatch_group_reader.py, and test_cp_images.py:309. I grepped for every ReplicaColumn( and MicrobatchGroupReader( and found none left that omits them.
  • test_rdma_min_group_bytes_must_be_none_or_positive is deleted, along with its now-unused imports.

Example (what the required fields catch).

before: ReplicaColumn(microbatch_groups=..., rollout_groups=...)   # a caller that forgets handles
        -> rollout_group_handles=[] -> the leader packs without the handle groups' rollouts
           -> fails later, far from the cause, on a spec with no sample
after:  the same call -> TypeError: missing 'rollout_group_handles' at construction

Resolved

  • microbatch_group_reader.py:81 / :133: the defaults are removed, so a caller that forgets them fails loudly.
  • test_rollout_worker.py: the test that only matched an error message is gone.

Must fix

  1. Description (still open). "Human note: TODO (Jiani)" still needs your own summary; agents don't write that part. It should make the case for merging: this is an enabler for #5760, #5255 and image payloads, with no step-time gain yet (238.0 vs 238.3 s at 4K, 1118 vs 1116 s at 16K).

Questions

  • Landing before the consumers (maintainer decision, still open). This adds about 1,000 source lines and a NIXL dependency for leaders and workers, with the knob off by default. Should it land now, or together with #5760 / #5255? The shared image pool (#6334) is a separate choice.

Not verified: the GPU suite at this head (test_cp_images.py changed again), and cross-host InfiniBand reads. A maintainer still needs to review.

@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 4e5c82b to ff839bf Compare November 25, 2026 01:13
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from ab0d975 to 2a7b0ba Compare November 30, 2026 19:58
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch 2 times, most recently from dba5c61 to 4d902e6 Compare November 30, 2026 20:29
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 2a7b0ba to 02a5cf8 Compare November 30, 2026 20:29
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 4d902e6 to cdddd68 Compare November 30, 2026 20:52
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 02a5cf8 to 264353d Compare November 30, 2026 20:52
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 264353d to ed7f924 Compare November 30, 2026 21:23
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch 2 times, most recently from 1acb2c0 to 1fa70a3 Compare November 30, 2026 21:36
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from ed7f924 to 348545f Compare November 30, 2026 21:36
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 1fa70a3 to 4d1c3b3 Compare November 30, 2026 22:00
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 348545f to 03981a2 Compare November 30, 2026 22:00
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch from 4d1c3b3 to bd7a62e Compare November 30, 2026 22:29
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 03981a2 to 007ac00 Compare November 30, 2026 22:29
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/5-group-rdma-handle branch from 007ac00 to fe85588 Compare November 30, 2026 23:01
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/4-trainer-packs branch 2 times, most recently from 46b574a to e36318f Compare December 1, 2026 15:38
@wwwjn

wwwjn commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #6303, which now includes this change.

After review, #6303 keeps each training group in the rollout worker that ran it. The controller holds only a small ref per group, and each trainer DP replica leader fetches the rollouts it trains on directly from the workers. This PR's RDMA read is now the optional large-group path of that same store (BaseRolloutWorker.Config.rdma_min_group_bytes, in rollout/rdma_rollout_group.py), so it no longer stands alone. The buffer pool, region tags, setup probes and their tests moved with it.

#6324 and #6334 are now stacked on #6303.

@wwwjn wwwjn closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant