Repository navigation
Conversation
|
@claude review |
There was a problem hiding this comment.
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
- 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). - A third RDMA path in one worker (design). With images, a worker now registers the same image bytes twice: once as a Monarch
RDMAImageFilesfor 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 forModelStateDictTransport. So oneRDMAByteBuffersper worker could plausibly serve both readers, and that would deleterl/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. torch_transport_rdma.py:79-- the TODOs need upstream issue links (inline).test_torch_transport_rdma.py:12-- points at areports/path that isn't in the repo (inline).
Should consider
controller.py:620--_handle_group_idsand the failure-path release can go: broadcast all ids when the knob is on (inline).packed_group_handle.py:93--selectduplicatesPackedRolloutGroup.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_probesalso creates the leader's transport. Leader reads silently depend on the probe having run first. CreateRDMAByteBuffersexplicitly 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_backwardN._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_grouppacks synchronously on the actor's event loop, and so doesrelease_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_groupreads 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.
| # 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. |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 oneLiteral["mooncake", "nixl"]choice shared by both? If only NIXL works here, say so in the knob's docstring and raise at config time whenmodel_state_dict_transport.backend != "nixl", rather than at setup.
| # 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() |
There was a problem hiding this comment.
_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.
| 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 | ||
| }, | ||
| ) |
There was a problem hiding this comment.
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.
| # 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), | ||
| ), |
There was a problem hiding this comment.
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"). |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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_quarterre-asserts the docstring's constants.test_a_buffer_released_twice_assertstests anassert.test_a_torch_transport_that_fails_to_start_...,test_a_probe_read_that_fails_...andtest_a_probe_that_reads_wrong_bytes_...check error-message substrings.test_a_released_buffer_is_reused_only_by_its_size_classandtest_a_request_no_free_buffer_fits_...are covered by the random-workload half oftest_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).
|
@claude review again |
There was a problem hiding this comment.
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_idsand the failure-path release are removed.packed_group_handle.py: the duplicateselectis 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 thereports/path now points toscripts/install_rl_env.sh.
Must fix
-
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. -
tests/rl/unit_tests/gpu/test_cp_images.py:244(new).Trainer.__init__now requires a keyword-onlyrollout_groups_by_rdma: boolwith no default (trainer.py:168). This call still omits it, so everytest_cp_imagescase fails withTypeErrorbefore it tests CP. Therl_cpusuite can't catch this. Addrollout_groups_by_rdma=Falsethere. That is the only other directTrainer(...)call;test_trainer.py:212is updated. -
torch_transport_rdma.py:40and: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. -
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
RDMABufferand a NIXL pool, plus two knobs, or ask for the shared version. That version would deleterl/rdma_object.py,actors/monarch/rdma_object.pyandrdma_min_image_bytes.
Questions
- An untrainable group now triggers one
release_groupsbroadcast to every worker, per group, atadd_grouptime. 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.releasepops 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 insideforward_backwardN. That ordering is unchanged from the last review. - Metric all-reduce.
_rollout_groups_by_rdmacomes from one config value that every rank receives, so themax_reduced_timingkeys and their order match across ranks. - Trainer construction.
self._is_replica_leaderis assigned attrainer.py:252, before theRDMAByteBuffers()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.
|
@claude review again |
|
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. |
There was a problem hiding this comment.
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:255now passesrollout_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
- Description (still open). "Human note: TODO (Jiani)" still needs the author's summary.
torchtitan/rl/torch_transport_rdma.py:40and: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.- A third RDMA path in one worker (still open, maintainer decision). A maintainer needs to either accept a worker that runs Monarch
RDMABufferfor images and a NIXL pool for groups, with two knobs, or ask for one shared pool. A shared pool would deleterl/rdma_object.py,actors/monarch/rdma_object.pyandrdma_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.
|
@claude review again |
There was a problem hiding this comment.
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 inmodel_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 privatetorch.distributed._transportAPI, which also has no issue. One upstream issue covering both TODOs would be better, but this PR need not block on it.
Must fix
-
Description (still open). "Human note: TODO (Jiani)" still needs the author's summary.
-
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
RDMABufferfor 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.pyandrdma_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.
- Accept a worker that runs a Monarch
Not verified: the cross-host InfiniBand reads, and the GPU test run at HEAD. A maintainer still needs to review.
422dca6 to
2d045e0
Compare
25dead1 to
4e38191
Compare
4e38191 to
770c439
Compare
2d045e0 to
295ae89
Compare
295ae89 to
93aef80
Compare
770c439 to
376acf8
Compare
|
@claude review again |
There was a problem hiding this comment.
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 thea0373e8I reviewed last round, and I found nothing new in it. I couldn't fetcha0373e8to diff the two directly.2476778, which changes one comment incontroller.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
- 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:81and:132--ReplicaColumn.rollout_group_handlesstill defaults to[], andMicrobatchGroupReader(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_positiveonly 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.
|
@claude review again |
|
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. |
There was a problem hiding this comment.
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_handlesno longer has a default (microbatch_group_reader.py:81), and neither doesMicrobatchGroupReader(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, andtest_cp_images.py:309. I grepped for everyReplicaColumn(andMicrobatchGroupReader(and found none left that omits them. test_rdma_min_group_bytes_must_be_none_or_positiveis 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
- 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.
4e5c82b to
ff839bf
Compare
ab0d975 to
2a7b0ba
Compare
dba5c61 to
4d902e6
Compare
2a7b0ba to
02a5cf8
Compare
4d902e6 to
cdddd68
Compare
02a5cf8 to
264353d
Compare
264353d to
ed7f924
Compare
1acb2c0 to
1fa70a3
Compare
ed7f924 to
348545f
Compare
1fa70a3 to
4d1c3b3
Compare
348545f to
03981a2
Compare
4d1c3b3 to
bd7a62e
Compare
03981a2 to
007ac00
Compare
007ac00 to
fe85588
Compare
46b574a to
e36318f
Compare
|
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 ( |
Human note: TODO (Jiani)

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 andsend_replica_columns783 -> 20 ms per step.Merge bottom-up. #6269 is on main and independent of this stack.
Problem
run_groupreply, then in each DP replica leader's column.send_replica_columns783 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
rdma_min_group_bytes(about 1 MiB suggested; many small reads cost more than sending the bytes) into a registered torch transport (NIXL) buffer.serialize_rollout_groupgainsallocateandregion_padding; the worker tags each region with(group_id, generation)and replies with the metadata and aSerializedRolloutGroupHandle(rollout/serialized_group_handle.py), not the bytes.ReplicaColumn.rollout_group_handles).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 unchangeddeserialize_rollout_group(read_serialized_rollout_group_handles).torch_transport_rdma.RegisteredBufferPoolnever 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_groupsreturns buffers.ValueErrornaming the hosts.Results
NOTE:
076f2e88band squashed to one commit. On this head: the CPU suite,pre-commit, and bitwise vs main076f2e88b(rl_grpo_qwen3_0_6b_varlen_batch_invariant, seed 42, deterministic, 10 steps, trainer TP 2 + one generator TP 2): 62/62 shared non-timing TensorBoard tags equal at every step, knob off and on. The 4K numbers come from this PR's commits before the rebase ontoaf04091d6, plus [rl] Finish the weight push before forward/backward #5235 (now on main).pthrDelay = 0): one idle agent takes 0.99 cores. With the knob on, that is each rollout worker and each leader; on the 10-host GCP run ([WIP] [rl] Prompt image files share the rollout worker's torch transport pool #6334's Results), the controller host's task used 5.0 cores vs 1.0-1.1 with the knob off.enable_prog_thread=Falseis untested on RDMA hosts.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 therequires_nixltests run. The 4 failures also fail on main076f2e88b(770 passed): recipe tests whosetorch_checkpointing.storage.fsspec_storageimport 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 withNIXL_ERR_NOT_FOUND.test_a_request_takes_the_smallest_free_buffer_that_fits: fails when a group takes only its own size class.