Skip to content

[rl] Rollout workers on any host: env files on a shared folder - #6157

Draft
felipemello1 wants to merge 1 commit into
felipemello1/distribute/2-spread-workersfrom
felipemello1/verifiers-041/5-shared-folder
Draft

felipemello1 wants to merge 1 commit into
felipemello1/distribute/2-spread-workersfrom
felipemello1/verifiers-041/5-shared-folder

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

TLDR: Rollout workers now run on the generators' hosts by default (rollouter.worker_roles: generator=True), the Terminal-Bench recipe's included. Search-R1 keeps its workers on the controller's host. Each worker sets OMP_NUM_THREADS=1, so that if its code runs torch or numpy math, it uses 1 thread instead of one per CPU. Whatever a worker reads by path goes in a shared folder (a filesystem mounted at the same path on every host), or in a copy on each host as the last fallback. A host without Docker, or without a path the training dataset names (e.g. Terminal-Bench's dataset dir), fails the job at start. A host missing one task's tests/ fails that group. A host missing one image file fails that rollout. Each error or log line names the host.

Before, every rollout worker and every agent's container ran on the controller's machine (controller=True), and now the workers spread over the generators' hosts (generator=True) next to vLLM, each worker runs torch on 1 thread, each generator host runs its own Docker daemon and checks it with docker version once at start, each worker reads the task's tests/ and environment/ at the sample's path on a shared folder mounted at that path on every host (a copy on each host is the last fallback) and checks the training dataset's dir at start, Search-R1 stays on the controller's machine (generator=None, controller=True) because its retriever listens on 127.0.0.1, and packing each task's files into its sample was not taken (a TMax task's tests/ is 1.2 KB gzipped at the median, but two Terminal-Bench 2.1 tasks have 11.5 MB and 4.6 MB, and packing TMax's 14,601 tasks takes about 16 s)

before:  every rollout worker on the controller's host (`worker_roles` default `controller=True`) -> that host's Docker daemon runs every agent
this PR: workers on the generators' hosts (default `generator=True`), each with the Harbor cache at the controller's path and its own Docker daemon
         host without a usable Docker daemon   -> "`docker version` failed on host gpu-7. ..." -> the job fails at start
         host without the training dataset     -> "<dir> is missing on host gpu-7. The training dataset's samples point there ..." -> the job fails at start
         host missing one task's tests/        -> "<path>/tests is missing on host gpu-7. ..." -> the group fails, no sandbox starts
         image file missing on a worker's host -> the rollout fails (ERROR_INFRA), as before. Its log line now names the host

Problem

  1. The PR below adds rollouter.worker_roles, with one field per role (True adds the role's hosts, False vetoes them, None has no opinion), but keeps every rollout worker on the controller's host by default (controller=True). Each Verifiers env runs inside its worker.
  2. A worker reads some files by path, on its own host: the model's tokenizer, Geometry3K and SLAKE images, and each Terminal-Bench task's directory in the Harbor cache.
  3. Terminal-Bench grades a task with the tests/ at that path (Verifiers 0.4.1 verifiers/v1/tasksets/harbor/taskset.py:404-407). A missing dir becomes a TaskError (verifiers/v1/rollout.py:864), which trains as the policy's failure.
  4. Each Terminal-Bench sandbox runs in the worker host's own Docker daemon.
  5. So one host's CPUs and Docker daemon run every agent. To move the workers, each worker's host needs the files it reads and, for Terminal-Bench, a Docker daemon.
  6. Torch and numpy each start a pool of threads for their math: numpy at import (63 threads on a 144-core host, capped at 64), torch at its first parallel op (one per CPU core: 144). Today's text and image workers run no torch op, so only numpy's pool starts, and it sits idle. A worker whose code runs such math next to vLLM would compete for its CPUs.

Solution

  1. RolloutWorkerRoles defaults to generator=True, the others None: the workers spread over the generators' hosts. Search-R1's recipes set generator=None, controller=True, with a TODO: its retriever listens on 127.0.0.1. generator=False would veto the controller's host when it is also a generator host, e.g. a one-host job from a launcher. Each error message and doc line that tells users how to keep the workers on the controller's host says generator=None too. A role you don't set keeps its default: controller=True alone keeps generator=True, so it adds the controller's host to the generator hosts.
  2. Each rollout worker process starts with OMP_NUM_THREADS=1, unless its host's env sets it. apply_rollout_worker_env_defaults in torchtitan/rl/_env.py is the spawn's bootstrap, so it runs before torch or numpy loads. It lives there because that module imports neither (a new test checks that it doesn't import torch).
  3. New property RLDataset.Config.paths_on_every_host: the paths a dataset's samples point at, computed from its own fields (none by default). SLAKE names its data dir, Geometry3K its image dir, and a Verifiers Harbor taskset its cache dir. Rollouter.setup_async passes the training dataset's paths to each rollout worker actor. The actor checks them with check_paths_exist_on_this_host (rollout/data.py) before it builds the worker. A host without one fails the job at start, with the path and the host. An override of the dataset config moves the checked path with it. RolloutWorkerActor now builds its worker in setup_async, so a build error reaches the controller as an endpoint error. A new RL README section, "Rollout workers on more than one host", says what each env needs on every host.
  4. VerifiersRolloutWorker.setup_async runs docker version once when the env's agents run in Docker (agent_config_fields(...) -> vf.DockerConfig). It waits at most 60 s. A failure stops the job at start:
    RuntimeError: `docker version` failed on host gpu-7. The env's agents run in Docker (`runtime=vf.DockerConfig()`). Please give every host that runs rollout workers a Docker daemon that the job's OS user can run, or give the agents a runtime that needs no local Docker. If only the controller's host has Docker, set rollouter.worker_roles.generator=None and rollouter.worker_roles.controller=True. Docker's error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    
  5. Terminal-Bench: a worker builds each task as TerminalTask, which raises when the task's tests/ is missing on the worker's host. A task whose separate verifier image carries its own /tests is exempt: grading never reads its local tests/. The group fails before any sandbox starts.
  6. log_failed_rollout (rollout/rollouter.py) now ends its line with host=<the worker's host>. Both workers log each failed rollout through it. Before, a failure on another host didn't say where it ran.
  7. The Verifiers worker's renderer_multiplex docstring now says what it limits: the most model calls in flight that share one renderer. A rollout counts toward this limit from rendering its prompt until the model's reply arrives, not while its tools run (Verifiers 0.4.1 verifiers/v1/clients/train.py:326-336, used at :411). When every renderer is at the limit, the worker loads one more (about 170 MB of memory and 0.5-1.5 s to load, for the Qwen3.5 renderer) and keeps it until it exits. The old docstring said "concurrent rollouts". This fix is a drive-by: a docstring-only fix, here because this PR already edits examples/verifiers/rollouter.py. Checked on CPU with one real Verifiers worker and renderer_multiplex=8: 64 rollouts that mostly run tools built 1 renderer, and 9 rollouts that all wait on the model built 2.
  8. Unchanged: the native image envs need no code change: the renderer already raises FileNotFoundError with the path.

Where it runs

one host (torchtitan.rl.train)   `worker_roles` changes nothing: every role is the local host.
                                 New: each worker sets `OMP_NUM_THREADS=1`, and a Terminal-Bench worker runs `docker version` once at start.
more than one host               run once: a 4-host GB300 job with remote sandboxes (Results below).
                                 It needs the checkout, the venv, the model and the env files in a shared folder
                                 at the same path on every host, and Docker on each host for Terminal-Bench's local sandboxes.

You may ask: why not send each file's bytes in the sample? The image renderers (Qwen3.5, Muse Spark) and Verifiers' Harbor task classes would read bytes instead of a path, each sample would carry its task's files, and the controller would pack every task at load:

tests/ per task, gzipped:  median 1.2 KB (TMax, 500 of 14,601 tasks sampled), 2.1 KB (Terminal-Bench 2.1, all 89)
                           two Terminal-Bench 2.1 tasks are much larger: 11.5 MB and 4.6 MB
packing at load:           ~16 s for TMax's 14,601 tasks (1.1 s per 1,000 tasks to parse and pack, timed on CPU)

A multi-host run already needs a shared folder for the checkout, the venv and the model. The files can sit there too.

You may ask: why the generators' hosts? When each role has whole nodes, generator=True keeps the workers off the trainer's nodes. Under Slurm the controller typically runs on trainer node 0, so they stay off its machine too. The cost: they share CPUs with vLLM, hence OMP_NUM_THREADS=1 for any torch or numpy math in a worker. A role smaller than a node shares a one-node mesh with other small roles (MonarchLauncher._layout). Example, one 8-GPU node:

trainer 4 GPUs + generator 4 GPUs    both on mesh node_0    generator=True -> workers on node_0, the trainer's node too

You may ask: does the thread default work? Checked on CPU: one process spawned like a rollout worker, then one 1000x1000 matmul in it (aarch64, 144 cores):

                                            torch threads   OS threads after the matmul
no bootstrap                                144             354
bootstrap from torchtitan/rl/_env.py        1               149
the same, host env OMP_NUM_THREADS=4        4               155
bootstrap from a module that imports torch  1               356   (torch loaded first: its BLAS kept 144 threads)

Without the matmul, as in today's workers, the default only removes numpy's 63 idle threads: it is insurance for worker code that runs torch or numpy math.
You may ask: why not check the validation dataset too? The controller builds it only at validation (rollout/rollouter.py, get_validation_samples), after the workers start. Terminal-Bench downloads it then, so the check would fail on a fresh cache. It lands in the same Harbor cache root as the training dataset, and TerminalTask still fails a group whose tests/ is missing. With a copy on each host, first download the validation dataset into the controller's cache, then copy.
You may ask: why does the actor build its worker in setup_async, not in its __init__? On Monarch, an error in an actor's __init__ kills the actor, and the controller can get a KeyboardInterrupt. An error in an endpoint reaches the controller as an ActorError with the message. Checked on CPU: the real RolloutWorkerActor with a Verifiers env that fails to load (an unknown taskset id), then setup_async, 7 runs each:

worker built in the actor's __init__:  7 of 7 runs: SupervisionError, then "Unhandled monarch error on the root actor" and a KeyboardInterrupt
worker built in setup_async:           7 of 7 runs: ActorError with "taskset 'no_such_taskset' not found", nothing else

The actor's setup_async calls check_paths_exist_on_this_host before the build, because building a worker may read these paths: a Verifiers worker loads its env in __init__, so the worker's own setup_async would be too late. In test_setup_fails_naming_a_missing_dataset_dir, the controller gets an ActorError with the path and the host. After a failed setup, the controller still calls close on every host. On a host whose worker was never built, close returns.
You may ask: why not let each host download the cache? TMax is converted locally (prepare_tmax.py) and isn't on the Harbor Hub, and job hosts may have no internet.
NOTE: every recipe but Search-R1 now runs its rollout workers on the generators' hosts. On more than one host, each generator host needs the recipe's files, and Docker for Terminal-Bench. A host without Docker fails the job at start.
NOTE: a host with a partial copy, missing one task's tests/ or one Geometry3K or SLAKE image, ends each such group right away. The rollouter picks each group's worker at random, so that host's share of the groups trains nothing.
NOTE: validation drops a group that fails, and leaves out a rollout that ends ERROR_INFRA, so its reward covers only the tasks that ran elsewhere and looks normal. validation/group_failures shows a missing tests/. validation/status_rate/error_infra shows a missing image.
NOTE: the Terminal-Bench README's network lines now match Verifiers 0.4.1: containers use Docker's bridge network (runtimes/backends/docker.py:312), and the default network policy allows any outbound address (configs/runtime.py:82).
NOTE: a stale copy on one host grades with older tests, and nothing checks that the copies match. That is why a shared folder comes first.
NOTE: open PRs edit the same TerminalTaskset docstring and the same Terminal-Bench README paragraph. Whichever lands second rebases.
NOTE: not run: docker version succeeding. The multi-host run below used remote sandboxes, and the CPU tests use a fake docker.

Results

A 4-host GB300 job: Qwen3.5-27B on Terminal-Bench, 20 steps, 16 x 16 rollouts per step, 16 rollout workers, remote sandboxes. Before: all 16 workers on the controller's host. This PR: 6 / 5 / 5 on the 3 generator hosts. Means over steps 2-20, except RSS: the largest value of any worker over the run.

                                           before       this PR
vLLM inter-token latency (ITL)             36.1 ms      36.5 ms
requests in flight per engine              57.7         59.3
step time                                  412 s        416 s
reward                                     0.660        0.659
worker RSS (resident memory), max          2.54 GiB     2.37 GiB

On the generator hosts, this PR's run also measured:

  • CPU per worker process: ~9% of one core (median 8.8%, max 18.4%).
  • Host load: ~8 of 144 CPUs (1-minute load average, median 7.1-7.8 per host, max 11.6).
  • close per worker at the end: 8-26 s.
  • Each generator host had a copy of the task files at the controller's path. The path check passed on all 3.

NOTE: the run was at an earlier version of this stack, with the next PR (the least-loaded worker pick) on top. The later changes to this PR don't touch its path: where the checked paths come from (the same Harbor cache dir for Terminal-Bench), the three values per role (the run put its workers on the 3 generator hosts, which the default generator=True still picks), a log line when a host's close raises (none did), docs and tests.
NOTE: the "before" run used an earlier version of the PRs below this one, on an older main, so it is not a pure A/B. For example, a failed sandbox counted as ERROR there and as ERROR_INFRA here.
NOTE: in both runs the job's launcher already set OMP_NUM_THREADS=1 for every process, so the run doesn't test this PR's 1-thread default. The CPU check above does.

Follow up (each one is a TODO in the code)

  • Cap the Docker containers per host. Terminal-Bench's local sandboxes now share the generators' hosts with vLLM, and nothing limits how many run at once. Ways to cap them: a fixed number of slots per host (e.g. file locks), CPU reservations per container, or a lower nice priority. The TODO sits at runtime=vf.DockerConfig() in the Terminal-Bench recipe.
  • Search-R1: serve the retriever on an address every host can reach, then drop its pin.

Test plan

# New: one host, real worker processes, SLAKE's data dir overridden after the recipe set it to a dir this host lacks.
# Setup fails naming that dir and the host. Watched failing with a stale copy of the recipe's dir passed instead:
# "RuntimeError: .../assets/datasets/slake is missing on host ...".
pytest -q tests/rl/unit_tests/cpu/test_rollouter_pool.py -k missing_dataset_dir
# New: a `docker` that hangs (the wait patched to 0.2 s). Watched failing before the fix:
# "Failed: DID NOT RAISE <class 'RuntimeError'>".
pytest -q tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py -k docker_hangs
# New: a worker's `run_group` on a one-task dataset whose tests/ was renamed raises before any sandbox starts.
pytest -q tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py -k refuses_a_task_whose_tests
# New: a task whose separate verifier image carries /tests builds with no local tests/.
# Watched failing with the check unguarded: "RuntimeError: .../tests is missing on host ...".
pytest -q tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py -k verifier_image_holds_its_tests
# Changed: the setup test's fake env gets `vf.SingleAgentEnvConfig()`, which uses no Docker. Without it: AttributeError
# on `.config`.
pytest -q tests/rl/unit_tests/cpu/test_verifiers.py -k bypasses_the_proxy
# Changed: the actor builds its worker in `setup_async`, not in its `__init__`. The fake worker's setup (the base one,
# with `_NO_OP_CONFIG`) freezes the process's objects and starts the lag trackers, so the test closes the trackers
# and unfreezes, for the tests after it.
pytest -q tests/rl/unit_tests/cpu/test_rollouter_pool.py -k builds_its_worker_at_setup
# Changed: `close` before `setup_async`, as after a failed setup, returns. After setup, it reaches each worker process.
# Watched failing with `close` unguarded: "AttributeError: 'RolloutWorkerActor' object has no attribute '_worker'".
pytest -q tests/rl/unit_tests/cpu/test_shutdown.py -k close_endpoint_reaches_each_worker_process
# New: `torchtitan.rl._env` imports no torch, so its bootstrap runs before torch loads.
# Watched failing with `import torch` added to it: "assert 'True' == 'False'".
pytest -q tests/rl/unit_tests/cpu/test_runtime_env.py -k does_not_import_torch
# Changed: the spawn test expects the bootstrap and the training dataset's paths in each worker's setup call. It
# relied on the old default, so it sets its roles: generator=None, controller=True.
pytest -q tests/rl/unit_tests/cpu/test_rollouter_pool.py -k spawns_worker_pool

# Verifiers 0.4.1, renderers 0.2.0: 1109 passed, 1 skipped (test_train_loop.py, skipped on main too).
pytest -q -rs tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config
# Without Verifiers (renderers 0.1.12, the same command): 1002 passed, 7 skipped (4 Verifiers test files, the 2 Verifiers recipes, and test_train_loop.py, skipped on main too).

@felipemello1
felipemello1 added this pull request to stack #6150 November 17, 2026 04:43
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 3m 28s —— View job


Verdict: Needs discussion: the Terminal-Bench recipe drops its controller_host_only pin before there is a startup check for the Harbor cache. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Needs discussion -- the Docker check, the per-task tests/ check and the host names in logs are fine, but unpinning the Terminal-Bench recipe now makes a multi-host default that nobody has run, and it has a known stall mode. Maintainers should decide whether the pin goes in this PR or after a startup cache check exists.

What this PR does. Docs say what each env needs on every host. The Verifiers worker runs docker version at setup when an agent uses vf.DockerConfig. A TerminalTask subclass raises when a task's tests/ is missing on the worker's host. The ERROR_INFRA log lines name the host. The Terminal-Bench recipe drops worker_placement="controller_host_only".

Example. A 2-host Slurm job where ~/.cache/harbor is local to each node and was populated only on node A:

before: all workers on A -> run trains normally; A's Docker runs every agent
after:  workers on A and B; Docker check passes on both
        B: every group -> RuntimeError ".../tests is missing on host B" in run_group
        B's load drops to 0 at once -> choose() sends B most new groups
        -> training mostly stalls, possibly "consecutive untrainable batches";
           validation scores only the tasks that ran on A, so the reward looks normal

With a shared home directory (common on Slurm), "after" works and spreads the CPU/Docker load.

Must fix

  1. The PR description's "Summary (human-written)" is empty; the author needs to fill it in.
  2. torchtitan_recipes/rl/verifiers_terminal_bench.py:152 -- dropping the pin before there's a fail-fast cache check (inline). Keep the pin and let users opt in with --override. Or add the startup check now: the recipe is built on the controller and can pass the dataset's absolute dir to the worker.
  3. torchtitan/rl/examples/verifiers/terminal_bench/taskset.py:53 -- the verifier_image exemption needs a Verifiers source citation (inline).

Should consider

  • torchtitan/rl/examples/verifiers/terminal_bench/README.md:135 (and line 11) -- the network-policy wording is a separate concern; cite the source or move it (inline).
  • torchtitan/rl/examples/verifiers/terminal_bench/README.md:93 -- duplicates the new rl/README.md section; cut it to the Terminal-Bench specifics (inline).
  • torchtitan/rl/examples/verifiers/terminal_bench/taskset.py:26 -- HarborTaskConfig comes from the verifiers.v1.tasksets.harbor.taskset submodule, though HarborData/HarborTask come from the package. The same goes for agent_config_fields from verifiers.v1.configs.agent in rollouter.py. If these aren't public exports, add a TODO, so the next Verifiers bump knows where it can break.
  • tests/rl/unit_tests/cpu/test_verifiers.py:248 -- the proxy-bypass test now builds a Terminal-Bench HarborConfig only to get a non-Docker config. The smallest built-in taskset config would read less like a Terminal-Bench test.
Details
  • Gate: the problem is real (one host's Docker and CPUs run every Terminal-Bench agent), and the Verifiers bridge plus the recipe are the right layer. The core change (rollout/rollouter.py) only adds socket.gethostname() to two failure-log lines, which is cheap and feature-agnostic.
  • The tests/ check raises in run_group before slots(), so the controller turns it into rollout/group_failures (controller.py:1283-1289), not a trained failure. That is the right status. The problem is only the routing feedback loop at rollouter.py:348.
  • Docker check: subprocess.run(timeout=...) kills the child on timeout, and asyncio.to_thread keeps the event loop free. Each worker runs it once at setup, so the cost is negligible.
  • Overlap: #5865 also edits TerminalTaskset. The description already notes the rebase.

Not verified: Verifiers 0.4.1 behavior (separate-verifier tests/ handling, Docker network default, HarborTaskset.load() building plain HarborTask); any multi-host run. A maintainer still needs to review.

@@ -145,11 +150,6 @@ def _terminal_bench_rollouter_config(
# removals. 32 is Python's default thread-pool size on a host with 28+ CPUs
# (min(32, CPUs + 4)). Not tuned.
num_threads_per_worker=32,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This removes the controller_host_only pin before the run has a way to fail fast when a host is missing the Harbor cache. The PR's own NOTEs describe the failure mode: on a host without tests/, every group fails before any sandbox starts. That drops the host's in-flight count to 0, so choose() sends it most new groups (rollouter.py:348). Training then mostly makes no progress, and validation quietly scores only the tasks that ran on healthy hosts. No multi-host run has tested this path yet.

Smallest fix: keep worker_placement="controller_host_only" and its TODO in the recipe, and keep the rest of the PR (the Docker check, the TerminalTask check, the docs, host names in the logs). Users with a shared cache opt in with --override rollouter.worker_placement=all_hosts. Drop the pin in the PR that adds the startup cache check (or the "retire a failing worker" TODO), once a multi-host run has shown it works. The other route: do the startup check now. The recipe is built on the controller, so it already knows the dataset dir. Passing that one absolute path to the worker and checking is_dir() in setup_async would fail the job at start, the same way the Docker check does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Fixed by adding the startup check, in b7c4002. The recipe keeps no pin: its workers follow
the new default, the generators' hosts.

  • New BaseRolloutWorker.Config.paths_on_every_host. Each worker checks those paths when it is built, so a host
    without one fails the job at start. The error names the path and the host, like the Docker check.
  • The actor now builds its worker in setup_async, so the error reaches the controller as an ActorError.
    Raised in the actor's __init__, it made Monarch interrupt the controller (7 of 7 CPU runs).
  • The Terminal-Bench recipe lists the training dataset's Harbor dir. The recipe computes it on the controller with
    Verifiers' cache_dir. SLAKE lists its data dir, and Geometry3K its image dir.
  • The validation dataset is not listed. The controller downloads it only at the first validation, after the workers
    start, so the check would fail on a fresh cache. It lands in the same cache root, and TerminalTask still fails a
    group whose tests/ is missing.
  • New test: test_a_worker_without_the_training_dataset_fails_at_build. I watched it fail before the fix.
  • Still not run on more than one host.

# each group. Needs the controller's cache dir in the worker's config: the worker's own cache
# root follows its $HOME, which may differ, and its config names only the training dataset.
tests_dir = Path(data.task_dir) / "tests"
if data.verifier_image is None and not tests_dir.is_dir():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The verifier_image is not None exemption relies on Verifiers never reading the local tests/ when a separate verifier image is set. Nothing checks that the image actually contains /tests. test_a_task_whose_verifier_image_holds_its_tests_needs_no_local_tests only shows that the task builds; it doesn't show how grading behaves. If Verifiers 0.4.1 still uploads the local tests/ in separate mode, the exemption lets the original TaskError-trains-as-policy-failure bug back in for those tasks. Please cite the Verifiers line that skips the upload in separate mode in the comment above, the way the description cites taskset.py:404-407 for the default case. Unverified: I couldn't read the Verifiers source from this runner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Explained in the comment, in b7c4002. In Verifiers 0.4.1:

  • parse_task sets verifier_image only for a separate verifier whose image bundles its tests
    (verifiers/v1/tasksets/harbor/taskset.py:777-786, definition.bundled_tests).
  • Grading uploads the local tests/ only when verifier is None or verifier_image is None (:404).
  • Harbor's own task check skips tests/ for bundled tests too (harbor/models/task/task.py:150).

So grading never reads the local tests/ for these tasks. The test shows that the task builds, and these lines
show how grading behaves.

when they run, so the container needs outbound network while grading. With its
default network policy, Verifiers' Docker runtime uses host networking, so the
controller host needs that access.
default network policy, Verifiers' Docker runtime allows any outbound address, so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line ("host networking" -> "allows any outbound address") and the "Toy sandbox" line 11 ("share its network" -> "with outbound network access") change what the README says about Verifiers' Docker network policy. That is a separate concern from multi-host placement. If Verifiers 0.4.1 changed the default, the fix belongs in the bump PR (#4-bump). If the old text was wrong, it belongs in its own PR. Either way, it's a security-relevant claim: please cite the Verifiers source for the new wording.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Kept, with sources. In Verifiers 0.4.1:

  • Each container runs on Docker's bridge network (verifiers/v1/runtimes/backends/docker.py:312,
    --network bridge).
  • The default network policy allows any destination (verifiers/v1/configs/runtime.py:82,
    allow = ["*"]).

So "host networking" and "share its network" were stale. This PR rewrites both paragraphs anyway, because they
said the containers run on the controller host. The body cites the same lines.

- To use other datasets, change the ids passed to `_terminal_bench_rollouter_config` in the recipe file.
The training and validation datasets must differ.

## More than one host

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This section and the new "Rollout workers on more than one host" section in torchtitan/rl/README.md cover much of the same ground. Both have the shared-folder-vs-copy guidance, the "nothing checks that copies match" caveat, and the whole "a failing host gets most new groups" paragraph (also in rl/README.md:295-298). Keep the general mechanics in rl/README.md once, and cut this section to what's specific to Terminal-Bench: the controller's cache path, Docker plus registry access on each host, and validation/group_failures. Link to the general section for the rest. That saves roughly 15-20 lines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Cut, in b7c4002: the section goes from 35 to 32 lines between its headers, with one idea
per bullet. It keeps only what is specific to Terminal-Bench:

  • the controller's cache path, and the symlink case
  • what a worker reads there
  • Docker with registry and Docker Hub access on each host
  • the start check on the training dataset, and why validation is downloaded before a per-host copy
  • validation/group_failures for a partial copy.

The shared-folder guidance now lives only in torchtitan/rl/README.md, and the section links there. The "a
failing host gets most new groups" paragraph is not in this PR: the later PR in this stack that adds the
least-loaded worker pick adds it to torchtitan/rl/README.md.

@felipemello1
felipemello1 removed this pull request from stack #6150 November 17, 2026 08:21
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 597ef4f to b7c4002 Compare November 17, 2026 08:22
@felipemello1
felipemello1 changed the base branch from felipemello1/verifiers-041/4-bump to felipemello1/distribute/2-spread-workers November 17, 2026 08:22
@felipemello1
felipemello1 added this pull request to stack #6159 November 17, 2026 08:22
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. The stack was reordered (6112 -> 6116 -> 6117 -> 6118 -> 6119 -> 6113 -> 6157 -> 6114), and 6113 now picks hosts with one flag per role (RolloutWorkerRoles).

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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


Verdict: Request changes: overriding a dataset dir now fails a one-host run at start, because paths_on_every_host keeps its own copy of the dataset's dir. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Request changes -- the new paths_on_every_host keeps a second copy of each dataset's dir, so overriding a dataset dir now makes a one-host run fail at start.

What this PR does. On top of 6113's RolloutWorkerRoles, it flips the default to generator=True, so rollout workers run on the generators' hosts. Search-R1 stays pinned to the controller's host, with a TODO. Each worker process now starts with OMP_NUM_THREADS=1 through Monarch's bootstrap. Each worker checks the paths in a new BaseRolloutWorker.Config.paths_on_every_host when it is built, and the actor now builds its worker in setup_async. Verifiers workers run docker version once at setup. TerminalTask refuses a task whose tests/ is missing. Failure log lines now name the host.

Example.

Slurm, trainer on node_0 (controller there too), 2 generator nodes
before (6113 default): every worker on node_0, beside the trainer
after:                 workers on node_1 and node_2, beside vLLM, torch on 1 thread
                       node_2 has no Harbor training dir -> job fails at start, naming node_2
one host, SLAKE, --override ...dataset.data_dir=/data/slake (both datasets)
before: trains
after:  "./assets/datasets/slake (in rollouter.worker.paths_on_every_host) is missing on host ..."

Earlier review, at HEAD

  • Pin dropped before a startup check existed: resolved. paths_on_every_host fails the job at start.
  • verifier_image exemption citation: resolved (taskset.py:431-433).
  • Network-policy wording, README duplication, private-import TODOs, the proxy test's taskset: resolved.
  • The empty "Summary (human-written)": still open.

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author needs to write it.
  2. torchtitan/rl/rollout/rollouter.py:404 -- paths_on_every_host copies the dataset's dir, so it goes stale under --override (inline). Let the dataset config name its paths, and have Rollouter.setup_async pass them to the workers.

Should consider

  • tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py:323 -- repeats the generic listed-path test (inline).
  • tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py:360 -- three cases for one straight-line check. Keep the timeout case (inline).

Questions

  • For maintainers: should generator=True be the default before any multi-host run? It moves every recipe's workers (up to max_rollout_workers_per_host=128, ~0.7 GiB each) and Terminal-Bench's uncapped Docker containers next to vLLM. The description measures thread counts, not generation throughput with workers present. The alternative is to keep 6113's controller=True default and let recipes opt in.
Details
  • Gate: the problem is real. Under 6113's default, one host's CPUs and Docker daemon run every agent. The changes sit at the right layers: the worker base, the Verifiers bridge, the recipes. Core changes are the roles default, a config field, the actor building its worker in setup_async, and host names in two log lines.
  • OMP_NUM_THREADS=1 on a single host: rollout workers do no heavy torch work. The Qwen3.5 and Muse Spark renderers only call grid_thw / num_placeholder_tokens, and pixel work runs in the generator and the batcher (engine.py:482, batcher.py:85). So the 1-thread default shouldn't slow image recipes.
  • Startup ordering: Rollouter.__init__ builds the training dataloader before setup_async spawns workers, and Geometry3kDataset.__init__ writes its images then. So GEOMETRY3K_IMAGE_DIR exists before the check.
  • A failed setup_async followed by close: VerifiersRolloutWorker.close on an unstarted server is safe (GenerationServer.close checks runner), and the actor guards the unbuilt case.
  • rollout_worker_hosts with generator=True only: when the controller runs outside the job, no worker lands on the controller's machine, as documented.

Not verified: any multi-host run; generation throughput with workers on generator hosts. A maintainer still needs to review.

Comment thread torchtitan/rl/rollout/rollouter.py Outdated
"""Post-scoring advantage estimator. Default = Dr.GRPO (mean-baseline only);
set `AdvantageEstimator.Config(should_std_normalize=True)` for standard GRPO."""

paths_on_every_host: list[str] = field(default_factory=list)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This field keeps a second copy of the dataset's dir, and the docstring admits the user must keep the two in sync. That breaks the one-host path, which this PR otherwise leaves alone. Example, SLAKE on one host with its data elsewhere:

--override rollouter.training_dataloader.dataset.data_dir=/data/slake \
           rollouter.validation_dataset.data_dir=/data/slake
before: trains
after:  RuntimeError: .../assets/datasets/slake (in rollouter.worker.paths_on_every_host) is missing on host gpu-0

The same happens to Geometry3K when image_dir is overridden, and to Terminal-Bench when the training taskset id is overridden (cache_dir(training_taskset) is frozen when the recipe is built). The reverse case slips through: the stale path exists, but the new one is missing on some host.

Smallest fix with one source of truth: let the dataset config name the paths its samples point at, e.g. a paths_on_every_host property on Geometry3kDataset.Config ([image_dir]), SlakeDataset.Config ([data_dir]) and the Terminal-Bench taskset config (its Harbor cache dir). Then Rollouter.setup_async passes the training dataset's list to each worker's setup_async, and the worker checks it there. This deletes the worker field, the three recipe lines and the "must override this list too" caveat, and an override can't make the two disagree. If a maintainer would rather not add that to the dataset interface, at least make the recipes derive the list from the dataset config object they just built. That still goes stale under --override, so the docstring caveat would stay.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Fixed as you proposed, in 8c881e8.

  • RLDataset.Config.paths_on_every_host names the paths a dataset's samples point at, none by default. SLAKE
    returns [data_dir], Geometry3K [image_dir], and a Verifiers Harbor taskset its cache dir
    (VerifiersTaskDataset.Config, through Verifiers' cache_dir).
  • Rollouter.setup_async passes the training dataset's list to each worker actor's setup_async
    (RolloutWorkerActor), which checks it on that host before it builds the worker. The error still names the
    path, the host and the fix.
  • The check stays inline in the actor: a shared helper would have one caller today, since Monarch is the only
    actor system.
  • Deleted: BaseRolloutWorker.Config.paths_on_every_host, the three recipe lines and the caveat.
  • The validation dataset stays unchecked: it is built only at validation, after the workers start, and may be
    downloaded then.
  • New test, test_the_workers_check_the_overridden_dataset_dir: one host, real worker processes, SLAKE's
    data_dir changed after the recipe set it. Setup passes when the dir exists, and fails naming it when not.
    With a stale copy of the recipe's dir passed instead, both cases fail.

)


def test_a_worker_without_the_training_dataset_fails_at_build(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This duplicates test_a_worker_refuses_to_build_on_a_host_without_a_listed_path in test_rollout_worker.py. The only thing it adds is that the recipe lists cache_dir(training_taskset), which re-reads a value the recipe sets (.claude/rules/tests.md). Please drop it. If the paths move to the dataset config (see the comment on rollouter.py:404), the generic test covers the check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Dropped, in 8c881e8. test_a_worker_refuses_to_build_on_a_host_without_a_listed_path is gone
too: the worker field it tested no longer exists. The override test above now covers the check. The fresh-process
and Docker tests no longer patch the Harbor cache either: the worker's own build no longer checks it.

taskset.TerminalTask(data=task_data)


@pytest.mark.parametrize(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Three cases test three raise branches of one straight-line check. If the check regressed, the failure would still be loud: every Docker rollout would end ERROR_INFRA and its log would name the host. Consider keeping one case. docker_hangs is the one that exercises non-trivial behavior, the timeout, and it covers the to_thread path. Drop the other two.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Done, in 8c881e8. Only the hang case is left, test_a_worker_whose_docker_hangs_fails_at_setup.
It covers the timeout and the to_thread path.

@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from b7c4002 to 8c881e8 Compare November 17, 2026 09:17
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. Fixed in 8c881e8: each dataset config names its paths (RLDataset.Config.paths_on_every_host), Rollouter.setup_async passes the training dataset's paths to the workers, and the worker field is gone. Your maintainer question gets an answer with numbers from the multi-host run.

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 2m 44s —— View job


Verdict: Needs discussion: the earlier code findings are fixed. Still open: the empty human-written summary, and whether generator=True should be the default before the multi-host numbers come in. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Needs discussion -- the earlier code findings are fixed. What's left is the maintainers' call on making generator=True the default before any multi-host run. The description still says "not run: anything on more than one host".

What this PR does. It changes the default RolloutWorkerRoles to generator=True, so rollout workers run on the generators' hosts. Search-R1 stays on the controller's host. Each worker process starts with OMP_NUM_THREADS=1. Each dataset config now lists the paths its samples point at (RLDataset.Config.paths_on_every_host). Rollouter.setup_async passes the training dataset's list to every worker, and each worker checks those paths on its own host before it builds itself. Verifiers workers run docker version once. TerminalTask refuses a task whose tests/ is missing. Failure logs name the host.

Example.

one host, SLAKE, --override rollouter.training_dataloader.dataset.data_dir=/data/slake
previous HEAD: "./assets/datasets/slake (in rollouter.worker.paths_on_every_host) is missing ..."
now:           SlakeDataset.Config.paths_on_every_host -> ["/data/slake"] -> trains
Slurm, node_2 has no /data/slake -> ActorError "/data/slake is missing on host node_2 ..." at start

Earlier review, at HEAD

  • The stale paths_on_every_host copy under --override: resolved. It is now a property computed from the dataset's own fields (rollout/data.py:27, SLAKE, Geometry3K, verifiers/data.py:60), and the worker field and the recipe lines are gone.
  • The duplicate listed-path test in test_verifiers_terminal_bench.py: resolved, the test was dropped.
  • Three Docker-check cases: resolved, only docker_hangs remains.
  • The empty "Summary (human-written)": still open. The author needs to write it.

Must fix

  1. The PR description's "Summary (human-written)" is empty.

Should consider

  • tests/rl/unit_tests/cpu/test_rollouter_pool.py:870 -- the present case spawns workers but guards nothing the missing case doesn't. Keep one case (inline).

Questions

  • For maintainers, still open from the last review: should the default be generator=True before a multi-host run? The trigger comment says the answer will come with numbers from a multi-host run. The description still lists that run as not done. Once those numbers are in the description (generation throughput with and without workers on the generator hosts, plus worker RSS per host), a maintainer can decide and dismiss the earlier request-changes review. If the numbers don't arrive, the fallback is to keep 6113's controller=True default and opt recipes in.
Details
  • Audit of RLDataset subclasses: dapo_math and alphabet_sort read no files by path. Search-R1's data_path is read only on the controller when the dataset is built, so returning [] is correct for those. SLAKE, Geometry3K and Verifiers/Harbor are the only datasets whose samples point at files, and each overrides the property.
  • Rollouter.setup_async is the only caller of RolloutWorkerActor.setup_async (rollouter.py:247), so no path skips the check.
  • close after a failed setup is guarded with hasattr(self, "_worker") (rollout_worker.py:133). A worker that was built but whose setup failed partway goes through VerifiersRolloutWorker.close, which is safe on a server that never started (see the last review).
  • A relative path such as SLAKE's default ./assets/datasets/slake is checked against the worker's working directory, the same directory the renderer later opens images from. So the check matches what reads the files.

Not verified: that cache_dir(HarborConfig) in Verifiers 0.4.1 depends only on the dataset id and not on the taskset module alias (I couldn't read the Verifiers source on this runner); any multi-host run. A maintainer still needs to review.

return _NoOpWorker()


@pytest.mark.parametrize("dir_on_this_host", [True, False], ids=["present", "missing"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The present case spawns a second set of real worker processes but guards nothing the missing case doesn't. A flipped exists check would fail missing. A check that never raises would fail missing. The empty-list happy path already runs in every other setup test. Also, now that paths_on_every_host is computed from the config's own fields, staleness under an override is ruled out by how it's built. "Override" here only sets an attribute, so the test's real value is the end-to-end ActorError carrying the path and the host. Please drop the parametrize and keep one missing case, e.g. test_setup_fails_naming_a_missing_dataset_dir. That saves one Monarch spawn per CI run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: Done, in 34ca427. One case is left, test_setup_fails_naming_a_missing_dataset_dir. SLAKE's
data_dir is overridden to a dir this host lacks, and setup fails with an ActorError naming the dir and the host.
With a stale copy of the recipe's dir passed instead, it still fails (watched).

@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 8c881e8 to 34ca427 Compare November 17, 2026 11:02
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: On generator=True as the default: we ran it on a 4-host GB300 job. The numbers are in the
description now, under Results.

  • Qwen3.5-27B on Terminal-Bench, 20 steps, 16 x 16 rollouts per step, 16 rollout workers, remote sandboxes.
  • Before: all 16 workers on the controller's host. This PR: 6 / 5 / 5 on the 3 generator hosts.
  • Means over steps 2-20, except RSS: the largest value of any worker over the run.
                                           before       this PR
vLLM inter-token latency (ITL)             36.1 ms      36.5 ms
requests in flight per engine              57.7         59.3
step time                                  412 s        416 s
reward                                     0.660        0.659
worker RSS (resident memory), max          2.54 GiB     2.37 GiB
  • Generation throughput: neither run logged tokens/s. Requests in flight / ITL gives a rough
    ~1,600 tokens/s per engine in both.
  • RSS per host: at most ~14 GiB on the 6-worker host (6 x 2.37), vs ~41 GiB on the controller's host before
    (16 x 2.54). Both are upper bounds: each process's RSS counts the shared libraries again.
  • CPU: ~9% of one core per worker, host load ~8 of 144 CPUs. close took 8-26 s per worker.
  • Caveats: the run was at an earlier version of this stack, with the next PR on top. The later changes to this PR
    don't touch its path. The baseline ran on an earlier version of the PRs below, so it is not a pure A/B. Both
    runs' launcher already set OMP_NUM_THREADS=1.

At this size, workers on the generator hosts cost vLLM nothing we can measure. The default is a maintainer's call.

@claude please review.

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 10s —— View job


Verdict: Approve -- please address the items before merging: the human-written summary is still empty, and one README line is out of date. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve -- please address the items below before merging. The code findings from earlier reviews are fixed. The 4-host run answers the open question about the default for the workers themselves. What's left is two small edits that don't need another review.

What this PR does. It makes RolloutWorkerRoles default to generator=True, so rollout workers run on the generators' hosts. Search-R1 stays on the controller's host. Each worker process starts with OMP_NUM_THREADS=1. Each dataset config names the paths its samples point at (RLDataset.Config.paths_on_every_host). Every worker checks those paths for the training dataset on its own host before it builds itself. Verifiers workers whose agents use Docker run docker version once at setup. TerminalTask refuses a task whose tests/ is missing. Failure logs name the host.

Example. The 4-host GB300 run from the description: Qwen3.5-27B on Terminal-Bench, remote sandboxes, 16 workers.

before:  16 workers on the controller's host   ITL 36.1 ms   step 412 s   worker RSS max 2.54 GiB
this PR: 6 / 5 / 5 on the 3 generator hosts     ITL 36.5 ms   step 416 s   worker RSS max 2.37 GiB
         host load ~8 of 144 CPUs, ~9% of one core per worker

Earlier reviews, at HEAD

  • The present/missing parametrize in test_rollouter_pool.py: resolved. One missing case remains.
  • The maintainer question on generator=True as the default: answered with numbers. The workers cost vLLM about 1% ITL and step time at this scale. The baseline is not a pure A/B, which the description says.
  • The empty "Summary (human-written)": still open.

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author needs to write it. An agent can't.
  2. torchtitan/rl/examples/verifiers/terminal_bench/README.md:61: "No run has used more than one host yet" is now out of date. The suggestion is inline.

Questions

  • For maintainers: the run used remote sandboxes, so local Docker containers on vLLM hosts are still unmeasured. The recipe as written uses local Docker, and nothing caps the containers per host. That case has a TODO, and a host without Docker fails at start. Under the old default, the containers ran on the controller's host instead, which under Slurm is trainer node 0, and nothing capped them there either. So the new default doesn't look worse. Please confirm you're fine with leaving the cap as a follow-up.
Details
  • Only the test changed since the last review (34ca427). Re-checked at HEAD: close before setup is guarded by hasattr(self, "_worker"), and the bare annotation self._worker: BaseRolloutWorker doesn't set the attribute. Rollouter.setup_async is the only caller that passes paths_on_every_host.
  • OMP_NUM_THREADS=1: the run's launcher already set it, so the run doesn't test the default. The CPU check in the description does.
  • RSS per host: at most ~14 GiB on the 6-worker host, compared with ~41 GiB on the controller's host before. Both are upper bounds, because each process's RSS counts the shared libraries again.

Not verified: local Docker on more than one host, and docker version succeeding. This touches core RL code (rollouter.py, rollout/data.py, the Monarch actor), so a maintainer still needs to review.

16-GPU host as written; there is no multi-host launcher example yet. The 35B-A3B recipe
has not been run end to end.
16-GPU host as written. To use several hosts, see [More than one host](#more-than-one-host).
No run has used more than one host yet. The 35B-A3B recipe has not been run end to end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is now out of date. The description's Results section reports a 4-host GB300 run of this recipe. But that run used remote sandboxes, so the path that is still untested is the recipe as written: local Docker on several hosts. Please say exactly that, so a reader knows what has been run.

Suggested change
No run has used more than one host yet. The 35B-A3B recipe has not been run end to end.
One 4-host run used remote sandboxes. No multi-host run has used local Docker yet. The 35B-A3B recipe has not been run end to end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: applied as suggested, in a30adbf (terminal_bench/README.md:61).

@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 34ca427 to a30adbf Compare November 17, 2026 11:07
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from a30adbf to 18cca89 Compare November 17, 2026 20:10
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review again. What changed since your approval (one commit, 18cca891d, rebased on the new 6113):

  • The default becomes generator=True (the others None); Search-R1 pins generator=None, controller=True, and every message that said generator=False now says generator=None.
  • The renderer_multiplex docstring now says what it counts: model calls in flight per renderer, not rollouts (measured: with a limit of 8, 64 rollouts mostly in tool calls built 1 renderer; 9 rollouts all waiting on the model built 2).

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 39s —— View job


Verdict: Approve -- please address the items before merging: the generator=True default and the Search-R1 pin are applied consistently, and the only blocker left is the empty human-written summary. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve -- please address the items below before merging. The new commit's default flip to generator=True is applied consistently in the recipes, messages, docs and tests. The only open item is the human-written summary.

What changed since the last review (18cca891d). The PR now sits on the new 6113, which uses three values per role. RolloutWorkerRoles defaults to generator=True with the other roles at None. Search-R1 pins generator=None, controller=True. Every "keep the workers on the controller's host" message now says generator=None plus controller=True. The Verifiers renderer_multiplex docstring now counts model calls in flight per renderer, not rollouts.

Example. The job from the RolloutWorkerRoles docstring: t0 = trainer + controller, t1 = trainer, g0 and g1 = generators.

RolloutWorkerRoles()                                 -> g0 g1           (new default)
RolloutWorkerRoles(generator=None, controller=True)  -> t0              (Search-R1, and the fix every error message suggests)
--override rollouter.worker_roles.controller=True    -> t0 g0 g1        (the old opt-in alone no longer pins: generator stays True)
one 8-GPU node from a launcher, default              -> node_0 through this_host()

I checked all four against provisioning.rollout_worker_hosts (provisioning.py:357-363).

Earlier reviews, at HEAD

  • The terminal_bench/README.md:61 wording: resolved, the suggestion was applied.
  • The empty "Summary (human-written)": still open.

Must fix

  1. The PR description's "Summary (human-written)" is empty. The author needs to write it. An agent can't.

Should consider

  • torchtitan/rl/examples/verifiers/rollouter.py:112-119: the renderer_multiplex docstring fix has nothing to do with where workers run. Under "one concern per PR" it would go in its own small PR. If it stays, note in the description that it's a drive-by. The new wording matches the measurement in the description. Unverified against Verifiers 0.4.1 clients/train.py, which isn't installed on this runner.
Details
  • Default-flip audit: all three Search-R1 configs build their rollouter through _search_r1_rollouter_config (search_r1.py:142, 288, 416), so the pin covers every one of them. Every other recipe takes the default. The generator=False strings left in the repo are the veto test cases (test_rollouter_pool.py:525, 550), and they are meant to say False.
  • Tests that relied on the old default now set their roles explicitly: test_spawns_worker_pool sets generator=None, controller=True, and test_rollout_worker_hosts builds every case from all-None (_worker_roles). test_setup_and_sync_log_step... compares against RolloutWorkerRoles(), so it doesn't depend on which value is the default.
  • RolloutWorkerRoles.__post_init__ still rejects an override that leaves no role at True, e.g. generator=False alone. That is the intended explicit error.
  • launcher/base.py:158 (unchanged) says controller=False keeps workers off trainer host 0. That is still true, but under the new default that host isn't picked anyway. No change needed.

Not verified: the Verifiers 0.4.1 renderer-pool behavior, and local Docker on more than one host. This touches core RL code (rollouter.py, rollout/data.py, the Monarch actor), so a maintainer still needs to review.

@felipemello1
felipemello1 removed this pull request from stack #6185 November 18, 2026 20:42
@felipemello1
felipemello1 added this pull request to stack #6190 November 18, 2026 20:43
@felipemello1
felipemello1 removed this pull request from stack #6190 November 19, 2026 01:49
@felipemello1
felipemello1 added this pull request to stack #6205 November 19, 2026 01:49
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 795212f to 2faede2 Compare November 20, 2026 05:47
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 2faede2 to fffee2b Compare November 22, 2026 09:03
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 8s —— View job


Verdict: Approve -- please address the items before merging: I found nothing new at fffee2b, which is a rebase onto the new 6113. The only item left is the empty human-written summary. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve -- please address the items below before merging. At fffee2b, a rebase onto the new 6113 (3187f3d), I re-read the whole diff and found nothing new. The only item left is the human-written summary.

What this PR does. By default, rollout workers now run on the generators' hosts (RolloutWorkerRoles.generator=True). Search-R1 stays on the controller's host. Each worker process starts with OMP_NUM_THREADS=1, set through Monarch's bootstrap. Each dataset config names the paths its samples point at (RLDataset.Config.paths_on_every_host). Each worker checks the training dataset's paths on its own host before it builds. Verifiers workers whose agents use Docker run docker version once. TerminalTask refuses a task whose tests/ is missing. log_failed_rollout ends each line with host=.

Example. t0 = trainer + controller, t1 = trainer, g0/g1 = generators, SLAKE with data_dir=/data/slake:

before: every worker on t0
after:  workers on g0 g1; g1 lacks /data/slake
        -> ActorError "/data/slake is missing on host g1 ..." at setup, the job fails at start
one host, --override ...dataset.data_dir=/data/slake -> the check follows the override, and the run trains

Must fix

  1. The description's "Summary (human-written)" is empty. The author has to write it. An agent can't.
Details

Re-checked at HEAD:

  • Rollouter.setup_async (rollouter.py:263-277) is the only production caller of RolloutWorkerActor.setup_async. Every test caller passes paths_on_every_host.
  • close before setup is still guarded by hasattr(self, "_worker") (rollout_worker.py:122).
  • Five datasets subclass RLDataset. SLAKE, Geometry3K and the Verifiers dataset point their samples at files, and each overrides paths_on_every_host. Search-R1, alphabet_sort and dapo_math keep [].
  • Search-R1 is still the only recipe that sets roles (search_r1.py:105). Every "keep the workers on the controller's host" message says generator=None plus controller=True.
  • host= is added once, in log_failed_rollout (rollouter.py:443). It matches the README example at torchtitan/rl/README.md:534.

Not verified: local Docker on more than one host, and docker version succeeding. This touches core RL code (rollouter.py, rollout/data.py, the Monarch actor), so a maintainer still needs to review.

@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from fffee2b to 92c4a93 Compare November 22, 2026 12:45
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 92c4a93 to b991a77 Compare November 22, 2026 15:11
felipemello1 added a commit that referenced this pull request Nov 23, 2026
## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
     this approach, and what you checked yourself. -->

## Agent details

**TLDR:** The Rollouter now starts one rollout worker per
`rollouts_per_worker` (default 128) training rollouts in flight. Before,
every recipe started 4 workers, whatever its load.

![On main every recipe starts 4 rollout workers, so each worker runs 16
training rollouts for the batch-invariant CI recipes and 384 for
Terminal-Bench 9B, while this PR starts one worker per 128 training
rollouts in flight (1 and 12 workers) and raises for a group over 128
rollouts.](https://raw.githubusercontent.com/felipemello1/pr_images/81b3f3c5472e7afa521015485beada6a8fb24d0f/torchtitan/6112/columns.png)
<!-- pr-image drawn at c7e5aa4 -->

```python
# before: Rollouter.Config
worker_pool_size: int = 4
# after: Rollouter.Config; the Rollouter sizes its pool from the controller's max_rollouts_in_flight
rollouts_per_worker: int = 128
```

**Problem**
1. `Rollouter.Config.worker_pool_size` sets how many rollout worker
processes start. It defaults to 4, and no recipe changes it.
2. Each worker runs all its rollouts on one event loop.
3. So each worker's load follows the recipe: 16 rollouts per worker for
the batch-invariant CI recipes, 384 for Terminal-Bench 9B.

**Solution**
1. `Rollouter.Config.rollouts_per_worker` (default 128) replaces
`worker_pool_size`.
2. The controller passes `max_rollouts_in_flight` (groups in flight x
group size, a new `AsyncLoopConfig` property) to the Rollouter's
constructor. `Rollouter.setup_async` starts
ceil(`max_rollouts_in_flight` / `rollouts_per_worker`) workers and logs
the count.
3. A group runs on one worker. So a group larger than
`rollouts_per_worker` raises when the config is built: only one worker
per group in flight could run a training group at once, and the others
would sit idle. `num_samples_per_prompt < 1` now raises too; nothing
checked it.
4. Unchanged: one mesh on the controller host, and Monarch's `choose`
picks the worker, at random. So `rollouts_per_worker` is the mean load,
not a cap. A later PR in this stack picks the least-loaded worker.

Also in this PR:
- One TODO on `InterGeneratorRouter.release_groups`, which both
group-level release calls use (training loop and validation): evaluate
if that release is needed, since each rollout already releases its
session. It lists the two things only that release does today.
- The controller's per-group asyncio tasks become `rollout_loop_<i>`, so
"rollout worker" names only the process.

**Results**

```text
recipe                          max in flight   workers: main -> this PR   host memory after imports
dapo_math 30B-A3B (x2)                  2,560   4 -> 20                    ~13.9 GiB
SLAKE 816B                              4,096   4 -> 32                    ~22 GiB (on one host until #6157)
Terminal-Bench Qwen3.5-9B               1,536   4 -> 12                    ~8.5 GiB
Terminal-Bench Qwen3.5-35B-A3B          1,280   4 -> 10                    ~7.2 GiB
Search-R1 30B-A3B perf                  1,024   4 -> 8                     ~5.8 GiB
geometry3k (x2)                           512   4 -> 4                     ~3.1 GiB
dapo_math 4B, Verifiers 4B (x4)           640   4 -> 5                     ~3.8 GiB
alphabet_sort, Search-R1, ... (15)    160-256   4 -> 2                     ~1.8 GiB
batch-invariant CI (x3)                    64   4 -> 1                     ~1.1 GiB
DAPO-Math 816B GB300                       64   4 -> 1                     ~1.1 GiB
```

Counts: ceil(`async_loop.max_rollouts_in_flight` / 128) of each built
recipe config. Every recipe uses the default 128; worker counts range
from 1 to 32. Memory: one worker holds 1.13 GiB of RAM after its
imports, but ~0.46 GiB of that is shared library pages, loaded once per
host. So a host's workers take ~0.46 GiB once, plus ~0.67 GiB per
worker; the column above adds both. Main's 4 workers take ~3.1 GiB.
Memory used while running comes on top.

You may ask:
- Why 128? A starting point, not a measured optimum. RL libraries run
2-192 rollouts per worker process for sandbox envs and 320-2,560 for
light search agents; math configs have medians of 72 and 256. 128 starts
half the processes that 64 would. #6174, later in this stack, adds the
worker metrics that check it on real runs.
- Why no CPU cap in the count? The Rollouter runs in the controller's
process, so it sees only that host's CPUs, and #6113 spreads the workers
to hosts it can't see. #6113 also caps the workers per host
(`MonarchActorSystem.Config.max_rollout_workers_per_host`).
- Why does the controller pass the load, not a worker count? The
Rollouter owns `rollouts_per_worker`, so it sizes its own pool. The
controller knows the load.
- Why only training rollouts? Validation comes due every `freq` steps,
so workers sized for it would sit idle between validations. Validation
shares the workers, as on main.
- Where does a worker's memory go? torch 578 MiB, Monarch 84,
transformers 22, and ~450 MiB of the `grain` and `datasets` packages.
Those load with the `VisionProcessor` import, which runs
`torchtitan/components/data/__init__.py`; the renderer and
`rl/rollout/data.py` import them too. A TODO at that import says to
check whether a worker needs them.

NOTE:
- Every worker runs on the controller host until #6157 turns on the
generator hosts by default (#6113 adds the switch): SLAKE's 32 workers
take ~22 GiB there. These PRs should land together.
- `VerifiersRollouter.__init__` forwards `max_rollouts_in_flight`.
- Not run on GPUs.

Follow up / TODO (each is a `# TODO` in the code):
- [ ] Place single rollouts on workers, instead of groups, so there is
less idle time as rollouts finish. This needs a new home for group-level
postprocessing.
- [ ] Evaluate if we need the group-level release in
`InterGeneratorRouter.release_groups`.
- [ ] Load the `grain` and `datasets` packages only where they are used,
to save ~450 MiB per rollout worker. First check that a worker doesn't
need them.
- [ ] At 128 rollouts per worker, renders and parses (`TokenEnv`) may
queue on the worker's 4 threads. Measure that wait, then size the pool
from it.

**Test plan**

```bash
python -m pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config -q
# Verifiers 0.4.0: 1003 passed, 1 skipped (test_train_loop.py, skipped on main too).
# Without Verifiers: 946 passed, 7 skipped (the Verifiers test files and recipes).
```

New or changed:
- `test_async_controller.py`:
`test_a_group_larger_than_rollouts_per_worker_raises` (with
`rollouts_per_worker=0` too).
- `test_rollouter_pool.py`:
`test_setup_spawns_worker_pool_on_controller_host`: 20 training rollouts
in flight / 7 per worker -> 3 workers (a floor would give 2).
- `test_shutdown.py`:
`test_controller_builds_rollouter_with_training_rollouts_in_flight`: the
default config's 32 groups in flight x 8 rollouts reach the Rollouter as
256.

`pre-commit` passes. `pyrefly` skips `torchtitan/rl` and `tests`
(`project-excludes` in `pyproject.toml`), so it checks none of this PR's
files.

Co-authored-by: Felipe Mello <[email protected]>
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch 5 times, most recently from 543a154 to bae5f2c Compare November 23, 2026 19:57
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch 2 times, most recently from 1079346 to 7ab7018 Compare November 24, 2026 02:15
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-041/5-shared-folder branch from 7ab7018 to c59e428 Compare November 24, 2026 02:29
Rollout workers now run on the generators' hosts by default:
RolloutWorkerRoles defaults to generator=True, the others None. Whatever a
worker reads by path must then sit at the same path on every such host: in
a shared folder (a filesystem mounted at the same path on every host)
first, or in a copy on each host as the last fallback.

- RLDataset.Config.paths_on_every_host: the paths a dataset's samples point
  at (none by default). SLAKE names its data dir, Geometry3K its image dir,
  a Verifiers Harbor taskset its cache dir. Rollouter.setup_async passes the
  training dataset's paths to each rollout worker actor. The actor checks them
  (check_paths_exist_on_this_host in rollout/data.py) before it builds the
  worker, so a host without one fails the job at start, with the path and the
  host. RolloutWorkerActor now builds its worker in setup_async, so a build
  error reaches the controller as an endpoint error. Its close skips a worker
  that setup_async never built.
- Each rollout worker process starts with OMP_NUM_THREADS=1 unless its
  host's env sets it (apply_rollout_worker_env_defaults, the spawn's
  bootstrap), so that if worker code runs torch or numpy math, it uses 1
  thread instead of one per CPU.
- The two ERROR_INFRA log lines in rollout/rollouter.py and the Verifiers
  worker's failed-rollout line name the worker's host.
- VerifiersRolloutWorker.setup_async runs `docker version` once when the
  env's agents run in Docker. A host without a usable daemon fails the job
  at start, and the error names the host. It waits at most 60 s.
- Terminal-Bench: a worker builds each task as TerminalTask, which raises
  when the task's tests/ is missing on the worker's host (unless the task's
  separate verifier image carries its own tests). The group fails before
  any sandbox starts, instead of training as a TaskError.
- Search-R1 keeps its workers on the controller's host
  (generator=None, controller=True): its retriever listens on 127.0.0.1.
- The Verifiers worker's renderer_multiplex docstring says what it limits:
  the model calls in flight that share one renderer. A rollout counts from
  rendering its prompt until the model's reply arrives, not while its tools
  run. A renderer loaded past the limit stays until the worker exits.
- Docs: "Rollout workers on more than one host" in the RL README, "More
  than one host" in the Terminal-Bench README, and pointers to it from the
  Search-R1 README, the SLAKE and Geometry3K recipes and the Monarch README.

This branch has not been deployed

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

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant