Repository navigation
Conversation
|
@claude review |
There was a problem hiding this comment.
Verdict: Needs discussion -- the PR is an explicit maintainers' choice between two designs. I'd lean toward this one: one RDMA stack, the CUDA-context workaround goes away, and it deletes code. But first it should fail at setup when generator rank 0 can't use NIXL.
What this PR does. With rdma_min_image_bytes set, a rollout worker used to keep large prompt image files as Monarch RDMABuffers. Now it copies them into the same NIXL RDMAByteBuffers pool that #6323 uses for packed groups. Each file is laid out as | tag | file | tag |, where the tag is (group_id, generation). Generator rank 0 reads the files on a single reader thread, with a transport it creates lazily. This deletes the RDMAObject protocol, its Monarch implementation, and the GPU 0 CUDA context each worker made.
Example. A 5 MB image, group of 8, 2 turns:
before: worker: RDMABuffer(file) + a CUDA context on GPU 0 (~250 MiB per worker)
rank 0: 16 Monarch reads; worker: drop() deregisters after the last call
after: worker: pool.allocate(5 MB + 32) -> tagged copy, one handle shared by all 16 prompts
rank 0: 16 NIXL reads on one thread (tags checked); worker: release() -> free list, stays registered
same group's pack: may reuse that buffer if the size class matches
Must fix
- PR description: the human-written summary is still
TODO (Jiani), and the commit title says "(prototype)". Also, "A generator without NIXL fails on its first kept image file" is not what happens (see 2). torchtitan/rl/generator/generator.py:468-- nothing checks at setup that generator rank 0 has NIXL. A missing NIXL or a broken RDMA path doesn't fail the run:_run_single_rolloutcatches the error and marks every image rolloutERROR. Fix: extend the existingRDMAProbegate to the images knob and probe from each generator's rank 0.
Should consider
torchtitan/rl/rollout/rollouter.py:430-- the two pool users keep separate generation counters and duplicate tag structs, so(group_id, generation)is not unique within the shared pool. Letallocatestamp a generation on each handle instead; this deletes code.tests/rl/unit_tests/cpu/test_torch_transport_rdma.py:380-- the NIXL image test duplicates existing loopback and NIXL coverage; delete it.
Questions
- The pool never shrinks. Image buffers used to be freed per group; now they stay registered at their per-size-class peak, so worker CPU registered memory rises. The results report only GPU memory. Can you report the rollout workers'
pool_bytes/ RSS? And with only the images knob on, nothing logs the pool metrics: they are emitted fromRolloutGroupBuffers.pack. - With both knobs on, each image file is copied into the pool twice per group: once as an
RDMAImageFileand again as the packed group's image regions. Was keeping the file buffers until the group's release, and pointingPackedRolloutGroupHandle.image_regionsat them, considered? That would finish the "one pool" idea, but it needs handles that span several buffers.
Details
- Gate: the problem is real (two RDMA stacks in one worker, plus a ~250 MiB per-worker CUDA-context hack on GPU 0). Building on torch transport matches principle 3 (PyTorch-native). Net production LoC is negative. The cost is a NIXL dependency on generator rank 0, and slower p50 reads (17-26 ms vs 12 ms) from one GIL-bound reader thread, about 0.1% of a generate call. That is a maintainer judgment.
- The
RDMAImageFiledocstring says the release order rules out a read racing a reuse. That holds today only because nothing cancels a generate call (controller.py:734). If that changes, the failure mode is worse than with Monarch. A torn read (old tags, new middle) passes the tag check, and the engine would store the result in_pixel_values_lru_cacheunderhash_value(vllm/engine.py:479-491). With Monarch, a read of a dropped buffer errors. Worth a TODO next to the existing one, not a blocker. - Pool thread-safety: every worker-side use (
_keep,release, pack, probe) runs on the actor's event loop thread. The generator side runs on one dedicated thread. Consistent with "Use from one thread at a time".
Not verified: cross-host NIXL image reads (not measured in the PR either); worker CPU memory growth.
|
|
||
| def _read_prompt_on_reader_thread(self, prompt: RDMAPrompt) -> Prompt: | ||
| if self._image_file_buffers is None: | ||
| self._image_file_buffers = RDMAByteBuffers() |
There was a problem hiding this comment.
This PR adds a new requirement: generator rank 0 needs NIXL. But nothing checks for it at setup, and when it's missing the run doesn't fail the way the description says ("fails on its first kept image file").
What happens instead: the ValueError from RDMAByteBuffers() here, or a read failure on a host that reports RDMA but can't transfer (the case RDMAProbe exists for), goes back through generate to _run_single_rollout. That function catches Exception (rollouter.py:720), logs it and marks the rollout ERROR. So every rollout with an image file >= rdma_min_image_bytes errors, and training keeps going on whatever is left. That breaks principle 8 (unsupported config -> clear error at setup).
Smallest fix: reuse the existing probe.
- In
controller.py:858, gate the probe onrdma_min_image_bytes is not None or rdma_min_group_bytes is not None. - When the images knob is set, also send the probes to each generator's rank 0 through a small
check_rdma_probesendpoint. That endpoint builds_image_file_bufferson the reader thread and callscheck_rdma_probes. - Make
check_rdma_probes's message name the reader role and the knob, not only "trainer DP replica leader" /rdma_min_group_bytes.
Building the transport at setup also takes the NIXL init and connect cost off the first generate call.
| rdma_byte_buffers if config.rdma_min_image_bytes is not None else None | ||
| ) | ||
| # Tags each group's kept image files (`RDMAImageFiles`), so a stale read is caught. | ||
| self._image_file_generations = itertools.count(1) |
There was a problem hiding this comment.
Two users now share one pool, but each keeps its own tag counter: this _image_file_generations, and RolloutGroupBuffers._generations (packed_group_handle.py:117). They also have duplicate struct.Struct("<qq") tags (_IMAGE_FILE_TAG, _REGION_TAG).
Both counters start at 1 and tag with the same group_id. And the normal next user of a released image buffer is the same group's packed buffer, since run_group releases the files right before finish_rollout_group packs. So (group_id, generation) no longer names one use of a pooled buffer, which is what both docstrings promise. Catching a stale read now depends on the two counters drifting apart and on where the region tags land, not on how the tag is built.
Simpler and unique by construction: let the pool stamp each allocation. Add e.g. RDMAByteBuffer.generation = next(counter) in RDMAByteBuffers.allocate, and have both users tag with handle.generation. This deletes:
- this counter;
- the
group_id/generationparams ofRDMAImageFilesand fields ofRDMAImageFile; RolloutGroupBuffers._generations;- one of the two tag structs.
|
|
||
|
|
||
| @requires_nixl | ||
| def test_nixl_image_file_reaches_the_reader_as_a_handle() -> None: |
There was a problem hiding this comment.
This test duplicates coverage that already exists.
RDMAImageFiles/RDMAPrompt.readdon't depend on the transport, and the loopback tests above already cover them: keep once, release, tags.- A whole-buffer NIXL read of a pooled buffer is already covered by the existing
requires_nixltests, e.g.test_nixl_reads_new_bytes_from_reused_buffers_without_registering.
If no regression would get past those, delete this one (.claude/rules/tests.md: no duplicate coverage).
1addde2 to
0d370c2
Compare
0d370c2 to
5ac68e6
Compare
|
@claude review again |
There was a problem hiding this comment.
Verdict: Needs discussion -- the round-1 commit resolves the earlier blocker. This PR versus #6323 is still a maintainers' call. I'd still lean toward this PR, once the author writes the human summary.
What changed since the last review (5ac68e6).
- The pool stamps each allocation with a generation (
RDMAByteBuffer.generation). Image files and group regions now tag with it through one sharedREGION_TAG. - Generator rank 0 now reads every worker's probe at setup.
- The pool metrics are now logged with either knob.
- The TODO on the cancel race is added.
- The duplicate NIXL image test is removed.
Example (the tag fix). One group, both knobs on, with the file and the packed group in the same size class:
before: file buffer tag (7, 1) <- the worker's image-file counter
packed group tag (7, 1) <- the group counter, same buffer -> a stale file read passes the tag check
after: file buffer tag (7, 41) <- pool allocation #41
packed group tag (7, 42) <- pool allocation #42 -> a stale file read raises
Earlier findings
- Resolved: generator rank 0's NIXL fails at setup. The setup probe now runs
Generator.check_rdma_probesthroughInterGeneratorRouter, under the same timeout as the leaders, and the error names the reader and the knob. - Resolved: the tags are unique within the shared pool (the per-allocation generation). This also deletes both callers' counters and one of the two tag structs.
- Resolved: the duplicate NIXL image test is deleted.
- Answered: the description now reports worker RSS and
pool_bytes, and gives the reason for the second copy. - Still open: the "Summary (human-written)" section is still
TODO (Jiani). The author has to write it; an agent must not fill it in.
Should consider (new)
torchtitan/rl/generator/generator.py:326-- the comment still says the transport is made on the first kept prompt. It is now made by the setup probe.torchtitan/rl/torch_transport_rdma.py:232--pool_metricsputsrollout_worker/...keys and a stateful registration counter into the generic transport. Its only consumer is the worker actor, so build the metrics there.
Details
- Probe placement: the probe now runs after
generator_start_engine_loop, so a broken group path is reported after the vLLM engine build, not before it. That is needed for the generator probe (a generator answers only once its engine is built). For the leaders, it only delays the error, which is acceptable. PackedRolloutGroupHandle.generationandRDMAImageFile.generationare now properties overbuffer.generationon frozen slots dataclasses. They aren't annotated, so they don't become fields, and pickling over Monarch carriesbuffer.generation. No otherRDMAByteBuffer(...)construction exists besidesallocate.check_rdma_probes_within_timeoutuses one reader label for all generators ("Rank 0 of a generator"), becauseInterGeneratorRouter.check_rdma_probesgathers them. A hang therefore doesn't say which generator. A read failure (not a hang) still names the host throughcheck_rdma_probes. Fine for a setup check.
Not verified: cross-host NIXL reads from generator rank 0; the setup probe on a multi-generator run.
| # transport reads block, and one transport serves one thread. The transport is made on | ||
| # the first such prompt, so runs without kept files never start NIXL here. |
There was a problem hiding this comment.
This comment went stale in the round-1 commit. With rdma_min_image_bytes set, the transport is now made at setup by check_rdma_probes, not on the first kept prompt. A reader who trusts the comment would expect the NIXL init cost on the first generate call.
| # transport reads block, and one transport serves one thread. The transport is made on | |
| # the first such prompt, so runs without kept files never start NIXL here. | |
| # transport reads block, and one transport serves one thread. The transport is made by | |
| # the setup probe (`check_rdma_probes`), so runs without the images knob never start NIXL. |
| # other process reads it, so replacing it (unregistering the old one) is safe. | ||
| self._staging: tuple[torch.Tensor, Memory] | None = None | ||
|
|
||
| def pool_metrics(self) -> list[m.Metric]: |
There was a problem hiding this comment.
RDMAByteBuffers is the generic transport. The trainer leaders and generator rank 0 use it too. But this method hard-codes rollout_worker/... metric keys, makes the transport module import observability.metrics, and gives every instance a _num_registrations_logged counter that only the worker actor uses. The name also hides a side effect: every call resets the registration delta, so a second caller would see 0.
The only consumer is RolloutWorkerActor (rollout_worker.py:135). Build the three metrics there from self._rdma_byte_buffers.pool, and keep the counter on the actor. That keeps the transport module free of rollout concepts, and this method and its import go away.
|
@claude review again |
There was a problem hiding this comment.
Verdict: Needs discussion -- round 2 resolves both should-considers from the last review and adds no new problems. What's left is the maintainers' choice between this PR and #6323, plus the human-written summary, which only the author can write.
What changed since the last review (5ac68e6 -> 5fd8564).
pool_metricshas moved out ofRDMAByteBuffersand intoRolloutWorkerActor._pool_metrics, along with its registration counter.torch_transport_rdma.pyno longer importsobservability.metricsor hasrollout_worker/...keys.- The comment on the generator's image-file reader now says the setup probe creates the transport.
- The metrics test moved with the code, from
test_torch_transport_rdma.pytotest_rollouter_pool.py. Its assertions are the same.
Example (where the metrics live).
before: RDMAByteBuffers.pool_metrics() -> rollout_worker/* keys in the generic transport,
used by leaders and generator rank 0 too
after: RolloutWorkerActor._pool_metrics() -> reads self._rdma_byte_buffers.pool;
the counter is on the actor, its only consumer
Must fix
- PR description: the "Human note" / human-written summary is still
TODO (Jiani). The author has to write it, not an agent.
Earlier findings
- Resolved: the stale reader-thread comment at
torchtitan/rl/generator/generator.py:325. - Resolved: rollout metrics no longer live in the generic transport (
torchtitan/rl/actors/monarch/rollout_worker.py:142). - Resolved earlier and still in place at HEAD: the setup probe on generator rank 0, per-allocation generation tags, and deletion of the duplicate NIXL test.
Details
_pool_metricsruns only fromrun_group's training path, on the actor's event-loop thread, so the read-and-reset of_num_pool_registrations_loggedhas a single caller, as the old method did.- The moved test builds the actor with
object.__new__and sets two private fields. That ties it to__init__'s attribute names, but it is the smallest way to test the delta reset without building a worker. It isn't worth churning. - The decision between designs is unchanged from the previous two reviews. This PR runs one RDMA stack and deletes the
RDMAObject/ Monarch code. Its costs are a NIXL dependency on generator rank 0 (now checked at setup) and slower p50 image reads (17-34 ms vs 12 ms, about 0.1-0.2% of a generate call).
Not verified: cross-host NIXL reads from generator rank 0; the setup probe on a multi-generator run.
5fd8564 to
29779f5
Compare
29779f5 to
67c225b
Compare
|
@claude review again |
There was a problem hiding this comment.
Verdict: Needs discussion -- this round adds nothing new to fix. Two things are still open: the maintainers' choice between this PR and #6323, and the human-written summary, which only the author can write.
What changed since the last review.
- The stack was rebased onto a base that has one more commit, 93aef80, which changes only the
rdma_min_group_bytesdocstring. - The PR's first three commits look the same as at the last review. I re-read the full diff at HEAD and found no change from the merge.
- New commit 67c225b changes only a comment.
RolloutWorkerActor.make_rdma_probe(torchtitan/rl/actors/monarch/rollout_worker.py:163) now names both readers of the probe: every trainer DP replica leader whenrdma_min_group_bytesis set, and rank 0 of each generator whenrdma_min_image_bytesis set. That matches the controller's gate atcontroller.py:943-305.
Example (who reads the probe at setup, from the controller).
rdma_min_group_bytes set -> Trainer.check_rdma_probes on each DP replica leader
rdma_min_image_bytes set -> InterGeneratorRouter.check_rdma_probes -> Generator.check_rdma_probes on each rank 0
both set -> both, gathered under one rdma_probe span; each read has its own 60 s timeout
Must fix
- PR description: the "Human note" is still
TODO (Jiani). The author has to write the human-written summary; an agent must not.
Earlier findings
- Still resolved at HEAD:
- the setup probe on generator rank 0;
- generation tags stamped per allocation (
RDMAByteBuffer.generation, sharedREGION_TAG); - the pool metrics on the worker actor (
_pool_metrics), logged with either knob; - the reader-thread comment;
- the TODO on the cancel race;
- the duplicate NIXL test is deleted.
Details
- Rebase check: the base's knob docstring still says "Setup reads a probe from each worker on each leader" (
rollouter.py:385). That is still true for the groups knob. This PR'srdma_min_image_bytesdocstring covers generator rank 0, so the two don't contradict each other. - The description says the Results ran before #6323 took its read-ahead commits. Read-ahead changes only when trainer leaders read group columns. Image files are read by generator rank 0 and released before the group is packed, so the comparison still holds. Nothing in this diff interacts with read-ahead.
- The design choice is unchanged from earlier rounds. This PR runs one RDMA stack and deletes
RDMAObject/MonarchRDMAObject(235 lines). Its costs are a NIXL dependency on generator rank 0, now checked at setup, and slower p50 image reads: 17-34 ms vs 12 ms, about 0.1-0.2% of a generate call.
Not verified: cross-host NIXL reads from generator rank 0; the setup probe on a multi-generator run.
8955c73 to
95cbed0
Compare
95cbed0 to
828272a
Compare
828272a to
bba9829
Compare
bba9829 to
346fce0
Compare
|
from claude: Rebased onto #6301's new head 6e2d4ba, where each rollout worker records its own groups ( |
|
Claude finished @wwwjn's task in 2m 59s —— View job Needs discussion -- re-review posted: the rebase onto #6469 / #6301 is sound and the new [0:16] group tag closes the stale-file case; one mechanical must-fix (test-only |
There was a problem hiding this comment.
Verdict: Needs discussion -- the code is sound after the rebase. What's left is a maintainer call: should NIXL replace Monarch for prompt image files, given that image reads are now measured at 2.7-2.0x slower per call (101 vs 38 ms p50) and #5862 lands the Monarch path first?
What changed since the last review (314f9be). The PR is rebased onto #6469 (#6323 is closed), and #6301's new head no longer has recorder_lines; nothing here referenced them. Since the previous head, the code changes are:
- The pool moved from
RolloutWorkerActorintoBaseRolloutWorker, which builds it when either knob is set. RolloutGroupStoretakes an optional pool (rdma_min_group_bytesNone, images only) and logs the pool metrics with every kept group.- The probe is now made by
BaseRolloutWorker.make_rdma_probe. - A serialized group now also stamps its tag at bytes [0:16] of its buffer. A new test covers this.
I re-read the full production diff (+466/-373 in torchtitan/*.py, +93 net) and the test diff.
Example (why the [0:16] stamp is needed). A 4x-sized image file is released, and a smaller serialized group of the same size class takes its buffer:
file use: [0:16] (1, gen 1) | file ............................ | (1, gen 1)
group use: [0:16] ??? | pad | (1,2) rollouts (1,2) | (old file bytes, untouched) ... (1, gen 1)
before: both of the file's tags survive -> a stale file read passes with a torn middle
after: the group writes (1, gen 2) at [0:16] -> the stale read raises
The reverse case is also caught: an image file writes contiguously from byte 0, so any stale group region it overlaps loses its head tag.
Must fix
torchtitan/rl/rollout/rollouter.py:482-- only a test passes the newrdma_byte_bufferskwarg onBaseRolloutWorker/MessageEnvRolloutWorker. Delete it and monkeypatch in the test (inline).
Earlier findings
All still resolved at HEAD:
- the setup probe on generator rank 0 (
controller.py:958-998); - the per-allocation generation with one shared
REGION_TAG; - the pool metrics, logged with either knob (now in
RolloutGroupStore._keep); - the reader-thread comment and the cancel-race TODO;
- the duplicate NIXL test, which is gone.
No leftovers of the deleted path (RDMAObject, register_rdma_object, _REGION_TAG, check_rdma_probes_on_leaders) anywhere in torchtitan/ or tests/.
Questions
- With this PR, does
rdma_min_image_bytesbeat sending images by value at all? The knob's docstring now says the crossover "is not measured yet". The Results compare only against Monarch, and per-call reads went from 38 to 101 ms. Without a knob-off row on the same run, a user has no basis to set this knob.
Details
-
Overlap search:
gh pr list --search "rdma_min_image_bytes"finds only #5862 and this PR. #6323 is closed; its group path now lives in #6469, the base. -
The design trade, updated to the new numbers:
- for: one RDMA stack instead of two, -216 lines of
RDMAObject/ Monarch code, worker RSS 3.0 -> 2.5-2.6 GB; - against: generator rank 0 needs NIXL (checked at setup), per-call image reads are 2-2.7x slower (0.6-0.7% of a generate call), and the pool's registered memory grows 4-10%.
- Step-time deltas (21.23 -> 20.31, swapped 20.66 -> 20.90) flip sign between lanes, so they are noise.
- Landing #5862's Monarch image path and then deleting it here is the maintainers' call.
- for: one RDMA stack instead of two, -216 lines of
-
Behavior change with only
rdma_min_group_bytesset:- the leader probe now runs after
generator_start_engine_loop, so a broken trainer path fails later in setup; - every training group carries the pool metrics, not only the ones kept in registered memory.
Both are stated in the description.
pool_registrationsis aSumof per-call deltas, so logging it on more groups doesn't double-count it. - the leader probe now runs after
-
run_groupreleases the files infinally, after theTaskGroupexits. The only cancellation path isstop_rollout_workersat shutdown (rollouter.py:281), and it cancels the controller-side call, not the generator's read. So the existing TODO still describes the only race. -
Pre-existing in #6469, not this PR: alignment padding inside a serialized group is never written. When a smaller group reuses a larger group's buffer, a stale region whose head tag falls in the new group's padding keeps its tags. This PR's image-file writes are contiguous, so they don't add such a case.
Not verified: cross-host NIXL reads from generator rank 0; the setup probe on a multi-generator run.
Before merge: fill in the human-written summary.
| rdma_byte_buffers: RDMAByteBuffers | None = None, | ||
| ) -> None: | ||
| if config.rdma_min_image_bytes is not None and register_rdma_object is None: | ||
| raise ValueError( | ||
| "rdma_min_image_bytes is set, but no register_rdma_object was given: the " | ||
| "rollout worker must run in an actor system that provides RDMA." | ||
| ) | ||
| self._rdma_min_image_bytes = config.rdma_min_image_bytes | ||
| self._register_rdma_object = register_rdma_object | ||
| self._rdma_min_group_bytes = config.rdma_min_group_bytes | ||
| # Used only from the event loop's thread. | ||
| if rdma_byte_buffers is None and ( | ||
| config.rdma_min_image_bytes is not None | ||
| or config.rdma_min_group_bytes is not None | ||
| ): | ||
| rdma_byte_buffers = RDMAByteBuffers() |
There was a problem hiding this comment.
Only one caller passes this kwarg, and it's a test: test_rollout_worker.py:498, which needs a loopback pool. RolloutWorkerActor builds the worker without it (rollout_worker.py, worker_config.build(**worker_kwargs)), and so does VerifiersRolloutWorker. MessageEnvRolloutWorker.__init__ (line 786) only forwards it. In production the worker always makes its own pool, so the kwarg and the "made here unless given" branch have no production consumer (.claude/rules/design.md: every new symbol needs a current consumer).
Smallest fix:
- Drop the parameter from both
__init__s. - Build the pool unconditionally:
self._rdma_byte_buffers = RDMAByteBuffers() if (image knob or group knob) else None. - In the test,
monkeypatch.setattr("torchtitan.rl.rollout.rollouter.RDMAByteBuffers", lambda: worker_buffers). - Also drop "made here unless given" from the class docstring at line 413.
There was a problem hiding this comment.
from claude: Dropped the kwarg from both __init__s: the worker builds its pool when either knob is set, the test monkeypatches rollouter.RDMAByteBuffers, and the class docstring no longer says "made here unless given". cf6cee8
346fce0 to
ef681ab
Compare
ef681ab to
cf6cee8
Compare
There was a problem hiding this comment.
Verdict: Needs discussion -- the code in cf6cee8 is sound. Two comments still describe the [0:16] stamp this round dropped, which is a mechanical fix. The open question is still the maintainers': should NIXL replace Monarch for prompt image files, given that image reads are 2-2.7x slower per call?
What changed since the last review.
- The test-only
rdma_byte_bufferskwarg is gone fromBaseRolloutWorkerandMessageEnvRolloutWorker. The worker now builds its pool when either knob is set, and the test monkeypatchesrollouter.RDMAByteBuffers. - The [0:16] group stamp is dropped. #6469 now zeroes every byte a serialized group doesn't write, including [0:48) before region 0's head tag. That clears a released image file's head tag.
Example (why a stale file read still raises without the stamp). A released 4x-sized file buffer is taken by a smaller serialized group:
file use: [0:16] (1, gen 1) | file ................................. | (1, gen 1)
group use: [0:48] 0 ... 0 | (1,2) rollouts (1,2) | (old file bytes, untouched) | (1, gen 1)
stale file read: head (0, 0) != (1, 1) -> RuntimeError
I checked the other reuse orders too:
- file after file: the new file's head tag overwrites the old one;
- group after group: already covered by #6469's zeroing;
- file over a stale group: the file is written contiguously from byte 0, so any group region it overlaps loses its head tag, and regions past the file's end keep their original bytes and tags.
Must fix
torchtitan/rl/transport/torch_transport_rdma.py:55-- theREGION_TAGcomment still says files and groups "stamp their tag at bytes [0:16]".torchtitan/rl/transport/rdma_rollout_group.py:19-- the module docstring has the same stale claim ("the worker also writes it at bytes [0:16]").torchtitan/rl/transport/torch_transport_rdma.py:13-- the docstring path should berl/transport/rdma_rollout_group.py, notrollout/....
Earlier findings
- Resolved: the test-only
rdma_byte_bufferskwarg (rollouter.py:482). - Still resolved at HEAD:
- the setup probe on generator rank 0;
- the per-allocation generation with one shared
REGION_TAG; - the pool metrics, logged with either knob;
- the cancel-race TODO;
- no leftovers of
RDMAObject/register_rdma_object.
Questions
- Still open: does
rdma_min_image_bytesbeat sending images by value at all on this path? The knob's docstring says the crossover "is not measured yet", and Results compare only against Monarch (38 -> 101 ms p50 per call).
Details
- Overlap search:
gh pr list --search "rdma_min_image_bytes"finds #5862 (the Monarch path this PR deletes) and #6469 (the base), nothing else. - With this round, catching a stale file read depends on #6469's zeroing loop (
rdma_rollout_group.py:213-216) covering [0:48).test_a_file_read_after_a_serialized_group_reused_its_buffer_raisesguards it and expects(0, 0), so a regression in the base's zeroing would fail this test. RolloutGroupStore's assert is loosened tordma_min_group_bytes is None or rdma_byte_buffers is not None, and_keepnow logs pool metrics whenever buffers exist. Both match the description.- Design trade, unchanged since the last round:
- for: one RDMA stack, -216 lines of Monarch /
RDMAObjectcode, worker RSS 3.0 -> 2.5-2.6 GB; - against: generator rank 0 needs NIXL (checked at setup), 2-2.7x slower per-call image reads (0.6-0.7% of a generate call), and 4-10% more registered pool memory.
- for: one RDMA stack, -216 lines of Monarch /
Not verified: cross-host NIXL reads from generator rank 0; the setup probe on a multi-generator run.
Before merge: fill in the human-written summary.
| # What an owner writes before and after each region a reader must tell from a later use of the | ||
| # same pooled buffer: (group_id, `RDMAByteBufferHandle.generation`). Image files and serialized groups share | ||
| # the pool, so the generation, numbered per allocation, is what makes a tag name one use. Image | ||
| # files and serialized groups also stamp their tag at bytes [0:16] of the buffer, where an image | ||
| # file's head tag sits, so any later use of the buffer overwrites that tag. |
There was a problem hiding this comment.
This comment went stale in cf6cee8. It says "image files and serialized groups also stamp their tag at bytes [0:16]", but _serialize / keep_in_registered_buffer no longer write a tag there. A stale image-file read is now caught because the group zeroes its unwritten bytes (rdma_rollout_group.py:213-216), which include [0:48). The new test expects exactly that: (0, 0) .... A reader who trusts this comment would look for a stamp that doesn't exist, and would miss that the check now depends on #6469's zeroing.
| # What an owner writes before and after each region a reader must tell from a later use of the | |
| # same pooled buffer: (group_id, `RDMAByteBufferHandle.generation`). Image files and serialized groups share | |
| # the pool, so the generation, numbered per allocation, is what makes a tag name one use. Image | |
| # files and serialized groups also stamp their tag at bytes [0:16] of the buffer, where an image | |
| # file's head tag sits, so any later use of the buffer overwrites that tag. | |
| # What an owner writes before and after each region a reader must tell from a later use of the | |
| # same pooled buffer: (group_id, `RDMAByteBufferHandle.generation`). Image files and serialized | |
| # groups share the pool, so the generation, numbered per allocation, is what makes a tag name one | |
| # use. An image file's head tag is the buffer's bytes [0:16]: a later image file overwrites it with | |
| # its own tag, and a serialized group zeroes it (the bytes before its first region). |
There was a problem hiding this comment.
from claude: Applied your wording. e4e3c7a
| tag = REGION_TAG: (group_id, the buffer allocation's generation), written by the worker, | ||
| checked by the reader; the worker also writes it at bytes [0:16], before region 0's | ||
| tag at 48, where an image file's head tag sits if the buffer held one before |
There was a problem hiding this comment.
This is the same stale claim, in the module docstring: "the worker also writes it at bytes [0:16]". After cf6cee8 nothing writes a tag at [0:16]. The bytes before region 0's tag at 48 are zeroed together with the rest of the unwritten padding (lines 213-216).
| tag = REGION_TAG: (group_id, the buffer allocation's generation), written by the worker, | |
| checked by the reader; the worker also writes it at bytes [0:16], before region 0's | |
| tag at 48, where an image file's head tag sits if the buffer held one before | |
| tag = REGION_TAG: (group_id, the buffer allocation's generation), written by the worker, | |
| checked by the reader; every byte the worker doesn't write is zeroed, including | |
| [0:48) before region 0's tag, where an image file's head tag sits if the buffer held one |
There was a problem hiding this comment.
from claude: Applied your wording. e4e3c7a
| - prompt image files (`BaseRolloutWorker.Config.rdma_min_image_bytes`): `RDMAImageFiles` keeps a | ||
| group's large files, and generator rank 0 reads them whole (`RDMAPrompt.read`); | ||
| - serialized training groups (`BaseRolloutWorker.Config.rdma_min_group_bytes`, | ||
| `rollout/rdma_rollout_group.py`): the trainer's DP replica leaders read only the rollouts they |
There was a problem hiding this comment.
Wrong path: the module is torchtitan/rl/transport/rdma_rollout_group.py. There is no rl/rollout/rdma_rollout_group.py.
| `rollout/rdma_rollout_group.py`): the trainer's DP replica leaders read only the rollouts they | |
| `rl/transport/rdma_rollout_group.py`): the trainer's DP replica leaders read only the rollouts they |
cf6cee8 to
c5d7f3f
Compare
c5d7f3f to
e4e3c7a
Compare
|
from claude: @claude review This round (e4e3c7a): the three stale comments. The knob-off row you asked for, same head and recipe, both with rdma_min_group_bytes = 1, two lanes then swapped: So on one host the pool does not beat sending the files by value; the knob docstring now says to keep it off unless sending is measured to cost more (e.g. across hosts). |
|
Claude finished @wwwjn's task in 1m 21s —— View job Needs discussion -- re-review posted: e4e3c7a fixes the three stale comments, but the by-value row shows this image path has no measured gain. The maintainers need to decide whether to keep |
There was a problem hiding this comment.
Verdict: Needs discussion -- e4e3c7a fixes all three stale comments, and the code has nothing left to fix. But the new by-value row shows this PR's image path has no measured benefit. So whether to keep rdma_min_image_bytes at all is now a maintainer decision, not just "NIXL vs Monarch".
What changed since the last review (cf6cee8 -> e4e3c7a).
- The three comments are fixed: the
REGION_TAGcomment (torch_transport_rdma.py:55), therdma_rollout_group.pymodule docstring, and the module path. - The
rdma_min_image_bytesdocstring (rollouter.py:441-446) drops the GB300 Monarch crossover. It now says that on one host the knob does not beat sending files by value, and to keep it off unless sending is measured to cost more. - The description gains the knob-off row.
I couldn't fetch cf6cee8, so I re-read the full production diff at HEAD. No leftovers of the old path: no RDMAObject, register_rdma_object, rdma_object, or "[0:16] stamp".
Example (what the new row says, Geometry3K 2048 px, 3.4-6.4 MB files, one host).
images by value: generate p50 16.06 s (swapped 16.14) image read: none
images in the NIXL pool: generate p50 16.12 s (swapped 16.33) image read p50 97 ms (84.6)
cross-host, NIXL: not measured
cross-host, Monarch: ~2x faster than by value from 5 MB (GB300, #5862) -- the only measured gain
Must fix
- Gate (value): this PR replaces the only image-RDMA path with a measured gain (Monarch, cross-host, #5862) with one that has none. The knob's own docstring now tells users to keep it off.
.claude/rules/config.mdsays to "expose only options a verified recipe uses". Yet the PR still adds NIXL on generator rank 0, a setup probe through the router, a reader thread, andRDMAImageFiles/RDMAPromptto serve the knob. One of these has to happen before this lands, and choosing between them is the maintainers' call:- (a) measure NIXL image reads across hosts, where #5862 saw Monarch's gain, and show the knob beats by value there;
- (b) drop prompt images by RDMA entirely. Close the image half of #5862, and here delete
rdma_min_image_bytes,RDMAImageFiles,RDMAPrompt,Generator.check_rdma_probes, and the router and actor endpoints. The pool then serves only groups, and this PR shrinks to roughly nothing; - (c) keep Monarch for images (#5862 as is) and close this PR.
Earlier findings
- Resolved: the
REGION_TAGcomment, therdma_rollout_group.pydocstring, and the module path. - Answered: the knob-off comparison. It is the basis for must-fix 1.
- Still resolved at HEAD:
- the generator rank 0 setup probe;
- one
REGION_TAGwith a per-allocation generation; - pool metrics with either knob;
- the cancel-race TODO;
- no test-only
rdma_byte_bufferskwarg.
Details
- Overlap search:
gh pr list --state open --search "rdma_min_image_bytes"finds #5862 (Monarch image path), #6469 (base), and this PR. - Reading the new numbers:
- The generate-call deltas (+0.06 s, +0.19 s) are within lane-to-lane noise. Step time flips sign between lanes (+0.6 s, -0.8 s).
- The images knob doesn't gain on one host, and it doesn't clearly lose. Its cost is the NIXL dependency, plus 85-97 ms of per-call reads that the generate call absorbs.
- If (b) is chosen, the shared-pool machinery this PR adds for images also goes: the [0:48) zeroing argument for image head tags, and the generator's
image-file-readerthread. Only #6469's group path is left. - Why (a) matters: per-call reads queue on rank 0's one GIL-bound reader thread (the description's NOTE). Cross-host latency adds to each round trip, so NIXL may not reproduce Monarch's cross-host gain. Unverified.
Not verified: cross-host NIXL image reads; the setup probe on a multi-generator run.
Before merge: fill in the human-written summary.
Human note: TODO (Jiani)

TLDR: Prompt image files move from Monarch
RDMABufferonto the NIXL pool that #6469 uses for large rollout groups, so rollout workers run one RDMA stack. One file at a time on one CPU host, the pool reads 5 MB in 7.4 ms (Monarch 15.4) and keeps/releases a group's files in 1.6/0.04 ms (3.0/1.0). On A100 (a busy shared host), per-call image read p50 rises from 38-54 to 101-111 ms, 0.6-0.7% of a 16 s generate call, and rollout worker RSS drops from 3.0 to 2.5-2.6 GB. Against sending the files by value (the default), the pool does not gain on one host either: a generate call takes 16.1-16.3 s p50 both ways.Merge bottom-up.
Problem
rdma_min_image_bytesset, a rollout worker keeps each large prompt image file as a MonarchRDMABuffer(MonarchRDMAObject, [WIP][rl] One RDMA object for microbatches and prompts; rollout workers send images as RDMA handles #5862); generator rank 0 reads it.rdma_min_group_bytesset, [WIP] [rl] Trainer leaders read large rollout groups by RDMA over torch transport #6469 keeps each large rollout group in a NIXL-registered pool (RDMAByteBuffers); the DP replica leaders read slices of it.RDMAObjectprotocol with its Monarch implementation (216 lines), and a torch transport module.Solution
RDMAImageFilescopies each file of at leastrdma_min_image_bytesinto the worker'sRDMAByteBuffersonce per group, keyed byPromptImage.hash_value;release()returns them after the group's last generate call, before the group is kept (RolloutGroupStore.keep).RDMAByteBuffers.allocate), and the worker writes a(group_id, generation)tag before and after each file, as on group regions. A file's head tag is the buffer's first 16 bytes, and a serialized group zeroes the bytes before its first region ([WIP] [rl] Trainer leaders read large rollout groups by RDMA over torch transport #6469), so a group that reuses a file's buffer overwrites the file's head tag.RDMAPrompt.read(buffers)reads all kept files in oneRDMAByteBuffers.readcall and raises on a reused buffer.Generator.check_rdma_probes); a failed or hung read fails setup.BaseRolloutWorkermakes oneRDMAByteBufferswhen either knob is set, shares it betweenRDMAImageFilesand itsRolloutGroupStore, and makes the setup probe every reader reads (make_rdma_probe). The store logsrollout_worker/pool_bytes,pool_bytes_in_useandpool_registrationswith every training group, with either knob.rl/transport/rdma_object.py(RDMAObject,RegisterRDMAObject),rl/actors/monarch/rdma_object.py(MonarchRDMAObject) and their test file.RDMAPromptandRDMAImageFilesmove torl/transport/torch_transport_rdma.py. Net production code: +80 lines.rdma_min_group_bytesset, two things change: the leaders' setup probe now runs with the generators', after the engine loops start (a generator answers only once its engine is built), so a broken trainer path fails setup later; and every training group carries the pool metrics, not only the ones kept in registered memory.Results
NOTE:
BaseRolloutWorker; the image path's code is unchanged. The host was busy (load average 25-60 from other users), so both sides read slower than in earlier runs (12 -> 17-34 ms on a quieter host); the ratio held.rollout_worker/pool_bytesgrows 4-10% (rows above).Test plan
pytest tests/rl/unit_tests/cpu: 830 passed, 8 skipped, 4 failed, with nixl ([WIP] [rl] Trainer leaders read large rollout groups by RDMA over torch transport #6469: 828; -3test_rdma_object.py, +3test_torch_transport_rdma.py, +2test_rdma_rollout_group.py). The 4 also fail on main076f2e88b(770 passed): recipe tests whosetorch_checkpointing.storage.fsspec_storageimport fails locally.pytest tests/rl/unit_tests/gpu/test_cp_images.py(2 A100s, this head): 4 passed.test_torch_transport_rdma.py:test_a_read_after_the_worker_reused_the_files_buffer_raisesfails without the tag check; intest_a_probe_read_that_fails_raises_at_setupthe message names the reader and the knob.test_rdma_rollout_group.py::test_a_file_read_after_a_serialized_group_reused_its_buffer_raises: a smaller group takes the file's buffer; fails (no raise) without [WIP] [rl] Trainer leaders read large rollout groups by RDMA over torch transport #6469's zeroed padding.