Repository navigation
[rl] Spread rollout workers over the job's hosts - #5925
felipemello1 wants to merge 1 commit into
Conversation
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 3m 4s —— View job Needs discussion: this changes where rollout workers run in every multi-host job by default, and it hasn't been run on a real multi-node job yet. See the review. |
There was a problem hiding this comment.
Verdict: Needs discussion -- This changes where rollout workers run in every multi-host launcher job by default. It hasn't run on a real multi-node job, and nothing shows the controller host is a bottleneck today. Maintainers should decide whether it lands default-on before that evidence exists.
What this PR does. With a launcher's host_meshes, spawn_rollout_workers spreads the pool over every job host except trainer host 0. It spawns one CPU proc mesh per host, assigns workers to the first hosts first, and starts them with CUDA_VISIBLE_DEVICES="". Rollouter.Config.workers_on_controller_host=True keeps the old placement. The Search-R1 and Terminal-Bench recipes set it. Log ranks are offset per host.
Example.
Slurm: trainer 16 GPUs (hosts t0,t1), generators 2 x 8 GPUs (g0, g1), 8 GPUs/node
t0 (controller) t1 g0 g1
worker_pool_size=4, before ctrl+router+batcher+4 - - -
worker_pool_size=4, after ctrl+router+batcher 2 1 1
worker_pool_size=2, after ctrl+router+batcher 1 1 0
workers_on_controller_host=True ctrl+router+batcher+4 - - -
(every worker in every row after the change: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is empty.
torchtitan/rl/actors/monarch/README.md:26-- says to put secrets inlauncher.env, which is logged and saved with the config (inline).
Should consider
torchtitan/rl/actors/monarch/system.py:199-- workers now see no GPU in one-node runs too, so "One-node runs don't change" is inaccurate (inline).torchtitan/rl/controller/controller.py:1067-- a TODO for a frame cap that already applies on the base branch: drive-by in core (inline).torchtitan/rl/actors/monarch/rollout_worker.py:46,provisioning.py:298-- speculative TODOs (os.nice,MALLOC_ARENA_MAX) with no observed problem; drop them (inline).
Questions
- Default. The motivation is resource use (10.6 cores and 28 GiB on the controller host for DAPO Math with 2 generators), not a measured slowdown. A typical 8-GPU node has well over 10 cores. The simulated run doesn't settle it either: step time went from 15.9 s to 17.6 s with responses 10% longer, and tokens/s per GPU dropped about 3%. Can you show one real multi-node run where spreading helps? Until then, could the default stay on the controller host, with spreading as the opt-in?
provisioning.py:312-- "the controller is on trainer host 0" depends onSlurmJobgiving the first mesh inLayout.mesh_nodesthe allocation's first node, which runs the batch script. Does Monarch guarantee that ordering? If it doesn't, the controller's host also gets workers and one job host gets none. Placement would be suboptimal but the job would still run.
Details
- Checked, no problems found: dedup of shared meshes by
id; thehosts[1:] or [this_host()]fallback when every role is on host 0;this_host()meshes passed by aControllersubclass (flatten("hosts")); the uneven split, including hosts that get 0 workers;first_worker_indexkeeping log ranks unique;stop_rollout_workersstopping every mesh. MonarchActorSystemis the onlyActorSystemimplementation, and the fake intest_rollouter_pool.pyis updated, so the new requiredon_controller_hostargument has no other callsite to update.- Recipes that spread by default:
dapo_math,alphabet_sort,verifiers_dapo_math. The Verifiers container watchdog exits cleanly on hosts without Docker, so DAPO Math doesn't need Docker on worker hosts.
Not verified: Monarch SlurmJob node-to-mesh ordering; whether same-host channels have the same 10 GiB frame cap; any real multi-node behavior.
| | `rdma_microbatch.py` | `MonarchRDMAMicrobatch`, the `RDMAMicrobatch` (`rl/trainer/rdma_microbatch.py`) on Monarch RDMA buffers: the batcher keeps a microbatch's large tensors and each trainer rank reads its column. | | ||
| | `rollout_worker.py` | `RolloutWorkerActor`, a rollout worker in the controller-host CPU pool. | | ||
| | `provisioning.py` | Proc meshes: the trainer and generator GPU meshes (`spawn_proc_mesh`, `PerHostProvisioner`), CPU procs on the controller host (`spawn_cpu_procs`), and the Monarch client's `shutdown`. | | ||
| | `rollout_worker.py` | `RolloutWorkerActor`, one rollout worker process. With a launcher, the workers spread over every job host but trainer host 0, the controller's (`rollout_worker_hosts`), with no GPU visible; `Rollouter.Config.workers_on_controller_host` keeps them on the controller host. A worker gets its host's environment, not the controller's runtime changes, so set the secrets its env reads in `launcher.env`. | |
There was a problem hiding this comment.
"set the secrets its env reads in launcher.env" contradicts MonarchLauncher.Config.env (launcher/base.py:136-138): that field is part of the config the controller may log and save, so secrets must stay out of it and go in the submit shell. Under SlurmLauncher, every node gets the submit environment (--export=ALL). Users who follow this README line will write API keys into saved configs. Point at the submit shell instead, e.g. "...so export the secrets its env reads in the submit shell (every job host inherits it), not in launcher.env, which is logged with the config."
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
| # TODO: a group crosses here, and in the worker's `run_group` reply, as one Monarch | ||
| # message, which torchmonarch caps at 10 GiB (`codec_max_frame_length`). Send larger | ||
| # groups per rollout, or as RDMA handles to their arrays. |
There was a problem hiding this comment.
This TODO describes a limit this PR doesn't change. On the base branch, groups already cross from worker processes to the controller and the batcher as Monarch messages, so the frame cap applies there too (unverified that same-host and cross-host channels share the same codec_max_frame_length). If the cap is already there, this is a drive-by TODO in core controller.py. Either move it to its own PR, or show what changes when the message crosses hosts.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
| # TODO: os.nice(10), inherited by agent subprocesses, so ranks on a shared host win CPU | ||
| # fights; decide from a multi-node run. |
There was a problem hiding this comment.
This is an idea to evaluate later, not a known limitation or a workaround ("decide from a multi-node run"). The same goes for the MALLOC_ARENA_MAX TODO at provisioning.py:298-299 ("Not measured on a long run yet"). Speculative TODOs build up and won't be revisited. Drop both, and add them back with the measurement that shows they're needed.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
| procs = host.spawn_procs( | ||
| per_host={"cpus": num_host_workers}, | ||
| bootstrap_command=default_bootstrap_cmd().with_env(ROLLOUT_WORKER_ENV), | ||
| ) |
There was a problem hiding this comment.
Now every rollout worker gets CUDA_VISIBLE_DEVICES="", including on the controller's host and in one-node runs. On the base branch, spawn_cpu_procs workers inherit the host's GPUs. So the description's "One-node runs don't change" isn't accurate: a RolloutWorker whose env uses a GPU (e.g. a local reward model) now fails on a single node too. The change is probably what you want. Say so in the description, and in the ROLLOUT_WORKER_ENV comment, which currently only argues for trainer and generator hosts.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
|
Reply from claude: round 1 is in
RL CPU suite at |
|
Reply from claude: round 2 is in
RL CPU suite at |
|
Reply from claude: @claude review |
|
Claude finished @felipemello1's task in 1m 28s —— View job Approve: the only thing left is to fill in the human-written summary. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. Spreading is now opt-in, so the default placement is the same as before. The only remaining item is the author's summary. A maintainer still needs to review.
What this PR does. It adds Rollouter.Config.workers_on_controller_host, which defaults to True. When it is False and a launcher passes host_meshes, spawn_rollout_workers splits the pool over every job host except trainer host 0, as one CPU proc mesh per host. Log ranks are offset per host. Every worker now starts with CUDA_VISIBLE_DEVICES="", whichever placement is used.
Example.
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty, and only the author can write it.
Earlier review, at HEAD
- README secrets: fixed. It now points to the submit shell, not
launcher.env. - One-node GPU visibility: the
ROLLOUT_WORKER_ENVcomment and the description now say workers see no GPU on one node too. I found no worker-side GPU use underrl/rollout,rl/envsorrl/examples. - Frame-cap TODO in
controller.py, plus theos.niceandMALLOC_ARENA_MAXTODOs: removed. - Default: spreading is opt-in, and the TODO at the field says to flip it after a matched multi-node run.
- Slurm host order: answered (
SlurmJob._stateorder, plus the TODO atrollout_worker_hosts).
Details
- Checked, no problems found:
Layout.host_meshesgives roles that share a mesh the same object, so theiddedup inrollout_worker_hostsis correct. Trainer hosts come first because of dict insertion order, sohosts[1:]drops trainer host 0. The fallback when every role is on host 0, the split that skips hosts with 0 workers,first_worker_indexandstop_rollout_workersover all meshes also check out. MonarchActorSystemis the onlyActorSystemimplementation, and the test fake is updated, so the new requiredon_controller_hostargument has no other callsite.- No in-repo recipe sets False yet. The knob is temporary by design: the next step is to flip the default after a multi-node run. The explicit
Truein the Search-R1 and Terminal-Bench recipes is redundant today. It is kept so those recipes stay on the controller host after the flip.
Not verified: real multi-node behavior, and Monarch's guarantee about Slurm node-to-mesh order.
411fa42 to
4b1323c
Compare
fd61570 to
555bfd8
Compare
4b1323c to
166f944
Compare
|
Claude finished @felipemello1's task in 1m 37s —— View job Approve: the only thing left is to fill in the human-written summary. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. I re-reviewed the diff at 166f944 and found no new problems. The default placement is unchanged (workers_on_controller_host=True), and the only blocker left is the author's summary. The code touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review.
What this PR does. It adds Rollouter.Config.workers_on_controller_host, which defaults to True. When it is False and a launcher passes host_meshes, spawn_rollout_workers splits the pool over every job host except trainer host 0, as one CPU proc mesh per host. Log ranks are offset per host by first_worker_index. Every worker starts with CUDA_VISIBLE_DEVICES="" under either placement. The controller logs how many workers run on each host, using a new hostname endpoint.
Example.
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty, and only the author can write it.
Should consider
torchtitan/rl/actors/monarch/provisioning.py:321-- this comment, and one test docstring, say "dimension" for the mesh's"hosts"axis (inline).
Details
- I couldn't fetch the previously reviewed commit (
411fa4214) in this checkout, so I re-read the whole diff at HEAD instead of only the delta. It matches the round-2 design: opt-in default, TODO at the field, Search-R1 and Terminal-Bench recipes pinned to True through their shared_search_r1_rollouter_config/_terminal_bench_rollouter_confighelpers, secrets kept in the submit shell rather thanlauncher.env, and the speculative TODOs gone. - Checked again, no problems found: the
iddedup and insertion order inrollout_worker_hosts, and thehosts[1:] or [this_host()]fallback. The 4 parametrized cases intest_rollout_worker_hosts_are_every_host_but_trainer_host_0match the docstring table. TheProcessJobtest expects 2-2-1 ontotrainer_1,generator_0_0andgenerator_1_0.stop_rollout_workersgathers every mesh.spawn_cpu_procsis still used by the router and the batcher. - The new
hostnameendpoint is@concurrent_endpoint, asrl/README.mdrequires, and its only consumer is the startup log line. It costs one round trip per worker at setup.
Not verified: real multi-node behavior, and the Slurm node-to-mesh order (TODO at rollout_worker_hosts).
| meshes = { | ||
| id(mesh): mesh for mesh in (host_meshes.trainer, *host_meshes.generators) | ||
| }.values() | ||
| # flatten: a launcher's mesh has a "hosts" dimension, but `this_host()` has none. |
There was a problem hiding this comment.
Nit, since this push is a style pass: CLAUDE.md asks for "axis" when a comment means a specific DeviceMesh axis, and "dimension" only for tensors and mesh shape. The same applies to the test_rollout_worker_hosts_takes_this_host_meshes docstring ("no "hosts" dimension") in tests/rl/unit_tests/cpu/test_shutdown.py.
| # flatten: a launcher's mesh has a "hosts" dimension, but `this_host()` has none. | |
| # flatten: a launcher's mesh has a "hosts" axis, but `this_host()` has none. |
There was a problem hiding this comment.
Reply from claude: Fixed in 1a68345: "axis" in this comment and in the test_rollout_worker_hosts_takes_this_host_meshes docstring.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
555bfd8 to
17e4a94
Compare
166f944 to
1a68345
Compare
|
Claude finished @felipemello1's task in 32s —— View job Approve: the "dimension" -> "axis" fix is in. The only thing left is to fill in the human-written summary. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The earlier nit is fixed at 1a68345, and the rest of the diff has no new problems. The PR touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review it.
Since the last review
provisioning.py:321and thetest_rollout_worker_hosts_takes_this_host_meshesdocstring now say "axis" for the mesh's"hosts"axis. Fixed.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Details
- The commit is a squash, so I re-read every changed line at HEAD rather than only the delta. The changes match the version reviewed last time, and the only difference I found is the two wording fixes.
- The fake
_FakeHostMesh.flatten(self, dim)intest_shutdown.pykeeps upstream's parameter shape. It is a test double, and the rename rule doesn't apply to it.
Not verified: real multi-node behavior, and the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts).
17e4a94 to
d6f247a
Compare
1a68345 to
b0eeefa
Compare
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The leftover _Worker.setup_async fake is gone at d2c5419, and the spread test still checks that all 5 workers close. Nothing else changed. The PR touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review it.
Since the last review
tests/rl/unit_tests/cpu/test_shutdown.py:_Workernow has only__init__andclose, the same as on the base branch. Fixed.test_rollout_workers_spread_over_the_hosts_of_a_jobstill assertslen(closed-*) == 5afterstop_rollout_workers, under both placements. So it still guards the per-hostmesh.stop()gather, andcloseis the only methodRolloutWorkerActor.__cleanup__calls on the fake.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Details
- I re-read every changed line at
d2c5419. Apart from the deleted fake, it matches the version approved at4d27c22. That coversrollout_worker_hosts(theiddedup andhosts[1:] or [this_host()]), the even split that skips hosts with 0 workers,first_worker_index, thehostnamelog line,stop_rollout_workersover every mesh, the__supervise__TODO, and the TODO at the worker pick inrun_group_rollouts. - Callsites of
Rollouter.Config: Search-R1 and Terminal-Bench set True explicitly, the other recipes use the default (True), and no in-repo recipe sets False.
Not verified: real multi-node behavior, and the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts).
d2c5419 to
903bb3a
Compare
|
Reply from claude: @claude please review. This push puts the stack on a draft copy of the look-aside router PR, rebased onto main (row 0, DO NOT REVIEW; it closes when the original lands). The generate answer now comes from the generator, so the docs and bodies say so; each body says not to merge while row 0 is under the stack. |
|
Claude finished @felipemello1's task in 53s —— View job Approve: the rebase onto row 0 left this PR's code unchanged. The only thing left is to fill in the human-written summary. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. Rebasing the stack onto the look-aside router copy (row 0) didn't change this PR's code. The diff at 903bb3a matches the version approved at d2c5419. The PR touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review it.
Since the last review
- The 12 changed files and their contents are the same as at
d2c5419. That includes the_Workerfake, which still has only__init__andclose. run_group_rollouts(rollouter.py:298-317) now hands each worker row 0'srelease_session_fnalong withgenerate_fn. This PR doesn't touch that code. Its own TODO about reserving each group's bytes per worker host sits right aboverandom.choice. With spreading on, a worker on another host callsgenerate_fnacross hosts. That path is row 0's design, not this PR's.- The description now says its router-hop numbers come from before row 0, when the router still forwarded every generate call. It also says not to merge while row 0 is under the stack. Both statements are accurate.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Details
- Callsites at HEAD:
MonarchActorSystemis still the onlyActorSystemimplementation. Thetest_rollouter_pool.pyfake takes**kwargs. Search-R1 and Terminal-Bench setworkers_on_controller_host=Trueexplicitly, the other recipes use the default (True), and no in-repo recipe sets False. - Re-checked at HEAD, no problems:
rollout_worker_hosts(theiddedup andhosts[1:] or [this_host()]), the even split that skips hosts with 0 workers,first_worker_index, thehostnamelog line,stop_rollout_workersover every mesh, and the__supervise__TODO.
Not verified: real multi-node behavior (including cross-host generate_fn calls under look-aside routing), and the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts).
899817a to
a3a1b86
Compare
903bb3a to
b1380fa
Compare
a3a1b86 to
fbd67d7
Compare
b1380fa to
d90adad
Compare
d90adad to
d1a9e9c
Compare
|
Reply from claude: @claude please review. The stack is reordered: Verifiers groups in workers, then Verifiers 0.4.1, then worker placement come first (the stack table shows the new rows). It is also rebuilt with three reviewed passes: a code-style pass over every changed file, the rewritten placement docs (the |
|
Claude finished @felipemello1's task in 1m 8s —— View job Approve: the reorder and the three passes change no behavior, and the new docstring lines match the code. The human-written summary still needs filling in. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The reorder and the three passes change no behavior. The only new content is three lines in the VerifiersRollouter docstring, and they match the code. The PR touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review it.
Since the last review
- The diff at
d1a9e9chas 13 files. The extra file compared with903bb3aistorchtitan/rl/examples/verifiers/rollouter.py(+3): "Workers see no GPU", and, withworkers_on_controller_host=False, the workers, watchdogs and containers move to host 1, sorun_groupand the router calls cross hosts but generate doesn't. That is accurate for the docstring's two-host example:rollout_worker_hostsdrops host 0, so host 1 is the only worker host, and under look-aside routing the worker'sGenerationServercalls the generators on host 1 directly. The watchdogs areshchildren of each worker, so they move with it. - The other 12 files match the version approved at
903bb3a, apart from the style pass and theBaseRolloutWorker.Configsignatures. The verifiers README and the deleted SVG aren't in this PR's diff, so they come from a lower PR in the stack.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Details
- I re-checked these at HEAD and found no problems:
rollout_worker_hosts(theiddedup, trainer hosts first,hosts[1:] or [this_host()]), the even split that skips hosts with 0 workers,first_worker_index, thehostnamelog line (@concurrent_endpoint),stop_rollout_workersover every mesh, the__supervise__TODO, and the TODO at the worker pick inrun_group_rollouts. - Callsites:
MonarchActorSystemis the onlyActorSystemimplementation.Rollouter.setup_asyncpasseson_controller_host. Search-R1 and Terminal-Bench setworkers_on_controller_host=Trueexplicitly, the other recipes use the default (True), and no in-repo recipe sets False. - The
_Workerfake intest_shutdown.pystill has only__init__andclose.
Not verified: real multi-node behavior (including cross-host generate_fn calls when generators and workers share no host), and the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts).
|
Reply from claude: @claude please review. The stack is rebased onto main (the look-aside router PR merged), and the PRs below this one are updated. |
|
Claude finished @felipemello1's task in 49s —— View job Approve: rebasing onto main left this PR's diff unchanged at |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The rebase onto main, which now includes the look-aside router, left this PR's diff the same as the version approved at d1a9e9c. The PR touches rl/actors/system.py and rl/rollout/rollouter.py, so a maintainer still needs to review it.
Since the last review
- The 13 changed files at
d802efcmatchd1a9e9cline for line. The only differences are in the context lines that come from main. - On main,
run_group_rollouts(rollouter.py:272-283) passesgenerate_fnandrelease_session_fnto the worker. This PR adds only the TODO aboverandom.choice, which sits where it did before. - The
VerifiersRollouterdocstring lines this PR adds ("Workers see no GPU", and "run_group and the calls to the router cross hosts; generate does not") still agree with the docstring above them on main: the worker'sGenerationServercallsrouter.reserve, then calls generate on the generator it got. - The description no longer mentions row 0 and says the router-hop numbers predate look-aside routing. Both statements are accurate.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Details
- Callsites at HEAD:
MonarchActorSystemis the onlyActorSystemimplementation, andRollouter.setup_asyncpasseson_controller_host. Search-R1 and Terminal-Bench setworkers_on_controller_host=Trueexplicitly, the other recipes use the default (True), and no in-repo recipe sets False.self._host_meshesis still set inMonarchActorSystem.__init__. - Re-checked at HEAD, no problems:
rollout_worker_hosts(theiddedup, trainer hosts first, andhosts[1:] or [this_host()]), the even split that skips hosts with 0 workers,first_worker_index, thehostnamelog line (@concurrent_endpoint),stop_rollout_workersover every mesh, and the__supervise__TODO. The_Workerfake still has only__init__andclose.
Not verified: real multi-node behavior (including cross-host generate_fn calls when workers and generators share no host), and the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts).
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 1m 45s —— View job Approve: the per-host CPU check at spawn time and the stop that keeps going when one host fails are both correct, and the human-written summary still needs filling in. See the review. |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. Since d802efc, the PR adds two things: a per-host CPU check at spawn time for spread workers, and a stop that keeps stopping the other hosts when one host's stop fails. Both are correct. The default placement is unchanged (workers_on_controller_host=True). The PR touches rl/actors/system.py, rl/rollout/rollouter.py and rl/controller/controller.py, so a maintainer still needs to review it.
What this PR does. It adds Rollouter.Config.workers_on_controller_host, which defaults to True. When it is False and a launcher passes host_meshes, spawn_rollout_workers splits the pool over every job host except trainer host 0, with one CPU proc mesh per host. Every worker starts with CUDA_VISIBLE_DEVICES="" under either placement.
Since the last review
controller.py:607:Controller.Config.num_rollout_workersnow checks CPUs only whenworkers_on_controller_hostis True. Spread workers are checked inMonarchActorSystem.spawn_rollout_workers(system.py:197-203) as ceil(workers / hosts) against this host's CPUs. That covers the one-node case with False too:rollout_worker_hostsreturns[this_host()], so the check compares all the workers against this host's CPUs, andtest_too_many_spread_workers_for_one_host_raise_before_any_spawnsguards it.system.py:241-250:stop_rollout_workersgathers every mesh'sstopwithreturn_exceptions=Trueand logs each failure. This matches howRollouter.closehandles worker close failures (rollouter.py:262-267), and the new test checks that the other meshes still stop.- The base is now the Terminal-Bench package PR. The recipe change goes through the public
terminal_bench_rollouter_config, and still sets True.
Example (unchanged)
Slurm: trainer on t0,t1; generators on g0, g1; worker_pool_size=4
t0 (controller) t1 g0 g1
default (True), before and after ctrl+router+batcher+4 - - -
workers_on_controller_host=False ctrl+router+batcher 2 1 1
(all workers, either way: CUDA_VISIBLE_DEVICES="")
Must fix
- The "Summary (human-written)" section is still empty. Only the author can write it.
Should consider
torchtitan/rl/actors/monarch/system.py:194-196-- "before any spawns" is inaccurate. The trainer and generator meshes are already up when this check runs (inline).
Details
- Re-checked at
31f2a65, no problems:rollout_worker_hosts(theiddedup, trainer hosts first,hosts[1:] or [this_host()]), the even split that skips hosts with 0 workers,first_worker_index, thehostnamelog line (@concurrent_endpoint), and the__supervise__TODO. The_Workerfake still has only__init__andclose. - Callsites:
MonarchActorSystemis the onlyActorSystemimplementation, andRollouter.setup_asyncpasseson_controller_host. Search-R1 and Terminal-Bench set True explicitly, and no in-repo recipe sets False. - The spawn-time check can't move to config time: the host count is known only from
host_meshes. The wording nit is the only thing it needs.
Not verified: real multi-node behavior, the order in which Slurm nodes map to meshes (TODO at rollout_worker_hosts), and whether every job host has the same CPU affinity as the controller under Slurm.
| # `Controller.Config.num_rollout_workers` checks workers on the controller's host. Spread | ||
| # workers are checked here, before any spawns. A job's hosts are one machine type (the | ||
| # launcher's `gpus_per_node` assumes it too), so this host's CPU count stands for each. |
There was a problem hiding this comment.
Nit: "before any spawns" overstates how early this check runs. Controller.setup_async (controller.py:814-869) spawns the trainer, the generators, the router and the batcher before it calls Rollouter.setup_async. So with workers_on_controller_host=False, too many workers per host raises only after the GPU meshes are up. The config-time check skips them now (controller.py:607). The check can't run at config time anyway, because the host count isn't known there. The description item 7 and the test name ..._raise_before_any_spawns say the same thing. Say "before any worker spawns" in all three places:
| # `Controller.Config.num_rollout_workers` checks workers on the controller's host. Spread | |
| # workers are checked here, before any spawns. A job's hosts are one machine type (the | |
| # launcher's `gpus_per_node` assumes it too), so this host's CPU count stands for each. | |
| # `Controller.Config.num_rollout_workers` checks workers on the controller's host. Spread | |
| # workers are checked here, before any worker spawns (the GPU meshes are already up). A | |
| # job's hosts are one machine type (the launcher's `gpus_per_node` assumes it too), so this | |
| # host's CPU count stands for each. |
There was a problem hiding this comment.
Reply from claude: Fixed: the comment now says "before any worker spawns", and the CPU check counts each host that runs workers.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one.
|
Reply from claude: This PR is replaced by the fresh draft "[rl] Spread rollout workers over the job's hosts (opt-in)". The comments here were read when planning it. Closing this one. |
Summary (human-written)
Agent details
TLDR: In a multi-host job, rollout workers can now run on every host except the controller's, instead of all on the controller's host. This is opt-in for now:
Rollouter.Config.workers_on_controller_host=Falseturns it on. The default, True, keeps today's placement until a matched multi-node run passes.Problem
spawn_cpu_procs).Solution
rollout_worker_hostslists every job host but trainer host 0, where the Slurm launcher runs the controller.spawn_rollout_workersspawns one proc mesh per host, splits the workers evenly (5 workers on 3 hosts: 2, 2, 1) and starts them withCUDA_VISIBLE_DEVICES="".workers_on_controller_hostpicks the placement. True, the default for now, keeps every worker on the controller's host. TODO at the field: default to False once a matched multi-node run (workers home vs spread) passes.Controller.__init__checks only workers on the controller's host. Spread workers are checked inspawn_rollout_workers, before any worker spawns (the GPU meshes are already up): the busiest host gets ceil(workers / hosts), against this host's CPUs (a job's hosts are one machine type).stop_rollout_workersstops every host's workers: a host whose stop fails is logged with its traceback, and the other hosts still stop.NOTE:
workers_on_controller_host=Falsein the recipe'sRollouter.Config.ProcessJob); a local 50-step run is below.rollout_worker_hosts: consider generator hosts first.spawn_rollout_workers.run_group_rollouts: before groups of tens of GB (1M-token rollouts, 128 per group), reserve each group's bytes per worker host, or pick the worker by bytes.launcher.envis logged with the config).TokenEnvreads each image by path in the rollout worker, and Geometry3K writes its images on the controller's host. So it spreads only with a sharedimage_dir. SLAKE reads its images fromdata_dirthe same way, so it spreads only if every worker host has that folder. Theworkers_on_controller_hostdocstring names image files.Results
Test plan
pytest tests/rl/unit_tests/cpu/test_shutdown.py tests/rl/unit_tests/cpu/test_rollouter_pool.py pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config # 986 passed, 1 skippedtest_too_many_spread_workers_for_one_host_raise_before_any_worker_spawns: spreading on, more workers than one host's CPUs. The controller's check skips them; the spawn raises before any worker starts.test_the_controller_checks_host_cpus_only_for_workers_on_its_host[True|False]: 24 workers on 8 CPUs raise when the workers run on the controller's host (True), and build when they are spread (False).test_rollout_workers_spread_over_the_hosts_of_a_job[False|True](real Monarch): 4 simulated hosts started withCUDA_VISIBLE_DEVICES=99, 5 workers. Withon_controller_host=Falsethey go 2-2-1 to the 3 hosts that are not trainer host 0, with log ranks 0-4, and none sees a GPU. With True all 5 stay on this host. WithROLLOUT_WORKER_ENV = {}both cases fail. Both cases also check thatstop_rollout_workerscloses all 5 workers.test_the_other_hosts_stop_when_one_worker_mesh_fails_to_stop: 3 worker meshes, the second one's stop raises. The other 2 still stop, and "Rollout worker mesh 1 stop failed" is logged.test_setup_sets_up_every_worker_and_close_closes_each_before_the_stop: the Rollouter passesworkers_on_controller_hostto the actor system. Its config sets False, so the test fails ifsetup_asynchardcodes True.test_rollout_worker_hosts_are_every_host_but_trainer_host_0(4 cases) andtest_rollout_worker_hosts_takes_this_host_meshes.test_rollout_worker_actor_builds_its_worker_and_inits_its_logger: mesh rank 2 on a host whose first worker is worker 4 logs as rank 6.Stack (15 PRs, bottom first; merging a PR also merges every PR below it; this PR in bold)
Alone on main, not in this stack: "Validation reads each prompt at most once; ValidationConfig.steps defaults to -1" and "Terminal-Bench 35B-A3B recipe: Dist-MoE in both roles, FULL CUDA graph generators, DAPO loss".