Repository navigation
[rl] Verifiers: each rollout worker runs its Verifiers envs; the env server is gone - #5899
Conversation
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 5m 41s —— View job Needs discussion: the code reads correctly, but the Docker Terminal-Bench run that is meant to gate this draft hasn't happened, and a maintainer should decide on the RAM and group-placement trade-offs. Review |
There was a problem hiding this comment.
Verdict: Needs discussion -- the code is a net deletion and reads correctly, but it replaces how the Terminal-Bench recipe runs, and the run that would validate that hasn't happened yet: a Docker Terminal-Bench run, which the description names as the condition for leaving draft. The +4.7 GB host RAM and the move to placing whole groups on one worker are trade-offs a maintainer should accept.
What this PR does. Verifiers 0.4.1 removed the ZMQ env server (serve_env, EnvClient, the worker pool). Each VerifiersRolloutWorker now loads the Verifiers env in setup_async and holds env.serving() until a new RolloutWorker.close(), which the Monarch actor's __cleanup__ calls. It runs each rollout as env.run_slot(slot, ModelContext(...)). The PR deletes env_server.py and Rollouter.setup_async(worker_config=...). It also bumps renderers to 0.2.0, makes the generation server accept the switched-off top_k=-1/min_p=0.0, and reads trace token ids as int32 arrays. Net -213 LoC.
Example.
Terminal-Bench, Qwen3.5-9B recipe: (3+1) x 12 = 48 active groups x 32 = 1,536 episodes in flight
before: 4 rollout workers --ZMQ--> env server: 16 pool procs, max_concurrent=96 each, spread per rollout
after: 16 rollout workers, each runs whole groups; run_group.choose() puts ~3 groups (~96 episodes:
agent loop + render + interception server + Docker) on one event loop
host RAM (from the description): 21.5 GB -> 26.2 GB
Must fix
- PR description -- "Summary (human-written)" is empty. The description itself names a gate that hasn't run yet: one short Terminal-Bench run with Docker, reporting in-flight rollouts per worker, render wait, host RAM, and whether any containers are left after a cancelled group. The deleted env server was the only path this recipe has ever run on. Please add those results before taking the PR out of draft.
Should consider
torchtitan_recipes/rl/verifiers_terminal_bench.py:149-- render threads stay at 4 per worker for ~96 in-flight episodes (inline).tests/rl/unit_tests/cpu/test_verifiers_example.py:177-- no test enters and exitsenv.serving()from different tasks, as Monarch does; a one-line change to the end-to-end test would cover it (inline).
Questions
Rollouter.run_group_rolloutssends each group withrun_group.choose(...). Does Monarch'schoosebalance by load? If it picks uniformly, then at ~3 groups per worker on average, some workers will run 5-6 Terminal-Bench groups (160+ containers) while others sit idle. The env-server pool, which spread single rollouts, didn't have that problem. Per-worker in-flight counts from the Docker run would answer this.RolloutWorker.close()(torchtitan/rl/rollout/rollouter.py:359) adds a lifecycle hook to shared RL code with one implementer. I think it earns its place: it pairs withsetup_async, it closes the generation server (which before was never closed), and it letssetup_async(worker_config=...)go. A maintainer should still confirm.
Details
- Gate: the problem is real. 0.4.1 deletes the server, and renderers 0.2.0 breaks 0.4.0, so the two pins must move together. Copying the 1.3k-line server into the repo would be the bigger change. The rollout worker is the right layer.
- No references remain anywhere in the repo to the env server,
HarborEnv,run_program,connection_timeout_sec, or the 0.4.0/0.1.12 pins. - The new raise in
run_groupfor a bad sample or bad task data is caught byController._rollout_loop(logged,rollout/group_failures) and by validation'sgather(return_exceptions=True), as the description says. _build_sampling_paramsbuilds vLLMSamplingParamsdirectly, without generation_config defaults. So acceptingtop_k=-1, min_p=0.0matches what the generator actually samples.GenerationServer.close()is a no-op ifstart()never ran, soclose()after a failedsetup_asyncis safe.- Shutdown order: before,
VerifiersRollouter.closestopped the env server beforeRollouter.closewaited for generate calls. Now episodes stay alive untilstop_rollout_workers().Controller.runcancels groups beforeclose, so this only affects a group whosecancel_groupfailed, and that group waits out the drain timeout in both versions. - Validation tasks are rebuilt with the training taskset's
task_type()andconfig.task, as the env server did before. No change.
Not verified: Verifiers 0.4.1 internals (that env.serving() isn't bound to a task, whether load_environment loads the Harbor dataset in each of the 16 workers, that vf.TaskData always has name), and all Docker/GPU behavior.
| connection_timeout_sec=1800.0, | ||
| ), | ||
| # Each worker runs the agent loops of its groups; 16 processes share that CPU work. | ||
| worker_pool_size=16, |
There was a problem hiding this comment.
With this PR the rollout worker's default executor does the rendering, and num_threads_per_worker (default 4) sets its size (RolloutWorkerActor.__init__). In the Qwen3.5-9B recipe, (3+1) x 12 = 48 active groups x 32 = 1,536 episodes run across 16 workers. That puts ~96 multi-turn, up-to-32K-token rollouts on 4 render threads per process. The env-server pool workers rendered on Python's default executor, which has min(32, os.cpu_count() + 4) threads. If the Docker run shows render wait, set num_threads_per_worker here next to worker_pool_size, with a comment on how you picked it, so users don't have to find it themselves. (Unverified: I'm relying on the description's statement that Verifiers renders on the default executor.)
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| async def run(): | ||
| await worker.setup_async( | ||
| tokenizer_config=None, | ||
| renderer_config=from_renderers(Qwen3RendererConfig(enable_thinking=False)), | ||
| hf_assets_path="tests/assets/tokenizer", | ||
| ) | ||
| try: | ||
| return await worker.run_group( | ||
| generate_fn=generate_fn, | ||
| release_session_fn=AsyncMock(), | ||
| sample=VerifiersTaskSample( | ||
| verifiers_task_data={ | ||
| "idx": 0, | ||
| "prompt": "What is 1 + 1?", | ||
| "ground_truth": "2", | ||
| } | ||
| ), | ||
| group_id=5, | ||
| group_size=2, | ||
| sampling=SamplingConfig( | ||
| temperature=1.0, top_p=1.0, max_tokens=64, seed=100 | ||
| ), | ||
| ) | ||
| finally: | ||
| await worker.close() |
There was a problem hiding this comment.
This test runs setup_async and close in the same task. In production, Monarch runs them in different tasks: the setup_async endpoint, then __cleanup__. The comment at rollouter.py:149-151 says that only works while Verifiers' serving resources aren't bound to a task. No test checks that. If a Verifiers upgrade makes serving() hold an anyio cancel scope or an asyncio.timeout, exiting it from another task raises RuntimeError, and that would surface only at shutdown of a real run.
Run each step in its own task and this test catches it at no extra cost:
async def run():
await asyncio.create_task(worker.setup_async(...))
try:
return await worker.run_group(...)
finally:
# Monarch closes the worker from `__cleanup__`, not the setup task.
await asyncio.create_task(worker.close())There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
94acdb9 to
c7f5077
Compare
46c3079 to
e6a4157
Compare
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 3m 49s —— View job Needs discussion: the code reads correctly, but this draft still waits on its own real-model Terminal-Bench run, the human-written summary is empty, and the container watchdog needs a TODO linking an upstream Verifiers issue. Review |
There was a problem hiding this comment.
Verdict: Needs discussion -- the code reads correctly and is a net deletion, but the PR is still a draft. Its own gate, a Terminal-Bench run with a real model (in-flight rollouts per worker, render wait, host RAM against 26 GB), hasn't run. And the +4.7 GB host RAM and whole-group-per-worker placement are trade-offs a maintainer has to accept.
What this PR does. Verifiers 0.4.1 deleted the ZMQ env server. Each VerifiersRolloutWorker now loads the env in setup_async and holds env.serving() until a new RolloutWorker.close(), which the actor's __cleanup__ calls. It runs each rollout as env.run_slot(slot, ModelContext(...)). Since the last review, each worker also starts a sh watchdog in its own session. When the worker's pipe closes, the watchdog runs docker rm -f on the worker's verifiers.run=$VF_RUN_ID containers. The Terminal-Bench recipe now sets num_threads_per_worker=32.
Example.
TB Qwen3.5-9B: 48 active groups x 32 rollouts over 16 workers (~96 episodes per worker on average)
before: rollout worker --ZMQ--> env server (16 pool procs, rollouts spread one at a time)
after: rollout worker: env.run_slot x32 per group, render on 32 threads, watchdog per worker
worker SIGKILLed mid-episode -> its watchdog removes its containers (description: 12 s)
Must fix
- PR description: "Summary (human-written)" is still empty, and the description lists a real-model Terminal-Bench run as "still open before ready". Please add the summary, and add that run's numbers before moving out of draft.
torchtitan/rl/examples/verifiers/rollouter.py:198-206: the container watchdog works around a Verifiers gap but has no TODO linking an upstream issue (inline).
Still open from the last review
tests/rl/unit_tests/cpu/test_verifiers_example.py: the end-to-end test still callssetup_asyncandclosein the same task, so nothing guards the "serving resources aren't bound to a task" assumption atrollouter.py:150-152across a Verifiers upgrade. To fix it, wrap both calls inasyncio.create_task(...).- Resolved: render threads (the recipe now sets 32 and says why).
Questions
- Does
load_environmentcalltaskset.load()eagerly? If it does, each of the 16 workers reads the whole Harbor/TMax dataset. Then the verifiers README line "so workers never load the dataset" is wrong, and the dataset is part of the 1,635 MB per worker. - Does Monarch's
choosebalance by load, or pick at random? With whole 32-rollout groups per worker, random placement makes some workers run 2x the average number of containers. The real-model run's per-worker in-flight counts would answer this.
Details
- Gate: unchanged since the last review. The two pins must move together, and the rollout worker is the right layer. Copying the 1.3k-line server would be the bigger change.
- Watchdog fd handling: Python pipes are non-inheritable (PEP 446), and
subprocess/ asyncio children useclose_fds=True, so docker CLI or harness subprocesses don't keep the write end open and delay the sweep. Amultiprocessingfork would keep it open. Nothing in this path forks. close()after a failed or skippedsetup_asyncis safe: the exit stack is empty,GenerationServer.close()is a no-op, and the watchdog isNoneor gets swept.test_rollouter_pool.pynow checks thatmesh.stop()reachesclose(), which guards the__cleanup__wiring.- The watchdog also starts for the DAPO (Subprocess runtime) recipe. That's harmless: it exits when
dockeris absent, or else runs one emptydocker ps.
Not verified: Verifiers 0.4.1 internals (when VF_RUN_ID is read, whether vf.TaskData always has name for the overflow warning at rollouter.py:363, eager taskset loading), and all Docker/GPU behavior.
| # Verifiers labels each container it starts `verifiers.run=$VF_RUN_ID`. One id per | ||
| # worker lets this worker's watchdog remove exactly its containers if the worker is | ||
| # killed: a killed worker runs no cleanup (`__cleanup__` runs only on a graceful stop, | ||
| # and actor code runs off the main thread, where Python can't handle SIGTERM). | ||
| # TODO: a kill of the whole process tree at once (e.g. its cgroup) takes the watchdog too. | ||
| # TODO: Compose projects (`vf-<uuid>`) carry no run label, so the watchdog misses them; | ||
| # no Terminal-Bench 2.1 or TMax task uses Compose. | ||
| os.environ["VF_RUN_ID"] = f"torchtitan-{uuid.uuid4().hex}" | ||
| self._container_watchdog = _start_container_watchdog(os.environ["VF_RUN_ID"]) |
There was a problem hiding this comment.
The watchdog works around a Verifiers gap: any process that runs env.serving() and dies without cleanup (Verifiers' own runner included) leaves its labelled containers running. Verifiers already owns the verifiers.run label and the container lifecycle, so the reaper belongs there: for example, serving() could start this watchdog itself, or the Docker runtime could start a per-run reaper. Today torchtitan keeps a shell script that has to match Verifiers' label scheme, and it breaks silently if Verifiers renames the label or the env var. Nothing tests the real label: the unit test uses a fake docker and checks the string this code builds.
The two TODOs here describe the watchdog's own limits, not the upstream gap. Per CLAUDE.md principle 3, please add a TODO with a link to a Verifiers issue (container cleanup when the serving process dies), so the script gets deleted once Verifiers handles it, e.g.:
# TODO(verifiers): remove the watchdog once Verifiers reaps its own containers when the
# serving process dies: <issue link>There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
c7f5077 to
2a4af25
Compare
e6a4157 to
7d72cb7
Compare
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 2m 3s —— View job Needs discussion: the code reads correctly, but the draft still waits on its real-model Terminal-Bench run, and the human-written summary is empty. Both upstream workarounds (the watchdog and |
There was a problem hiding this comment.
Verdict: Needs discussion -- the code still reads correctly, but the PR is a draft waiting on its own real-model Terminal-Bench run. The +4.7 GB host RAM and the whole-group-per-worker placement are trade-offs a maintainer has to accept.
What changed since the last review. VF_RUN_ID now keeps a launcher's id as its prefix. The watchdog has a TODO saying when to drop it. The loopback no_proxy setup moved here from the deleted env_server.py. The end-to-end test now skips when uv's package index is unreachable.
Example.
host env before setup_async: HTTPS_PROXY=http://proxy:3128 NO_PROXY=.corp.internal
after (this PR): no_proxy=NO_PROXY=127.0.0.1,localhost <- .corp.internal is lost
Must fix
- PR description: "Summary (human-written)" is still empty. The description still lists one real-model Terminal-Bench run as "still open before ready" (in-flight rollouts per worker, render wait, host RAM against 26 GB). Please add both before taking the PR out of draft.
torchtitan/rl/examples/verifiers/rollouter.py:1899: partly resolved. The watchdog now has a TODO, but it points at 0.4.0's_arm_teardown, not at an upstream Verifiers issue. The newno_proxyTODO atrollouter.py:178has no link either. Please file one Verifiers issue per gap and link it, so both workarounds get deleted when upstream fixes them.
Should consider
torchtitan/rl/examples/verifiers/rollouter.py:179-182: drops an uppercase-onlyNO_PROXY(inline).tests/rl/unit_tests/cpu/test_verifiers_example.py:686: the end-to-end test leaksVF_RUN_ID,no_proxyandNO_PROXYinto later tests (inline).
Still open from the last review
tests/rl/unit_tests/cpu/test_verifiers_example.py:setup_asyncandclosestill run in the same task. Nothing guards the comment atrollouter.py:1574-1576(serving resources are not bound to a task) across a Verifiers upgrade. Wrap both calls inasyncio.create_task(...).
Questions
torchtitan/rl/examples/verifiers/README.mdsays "workers never load the dataset". Doesload_environmentcalltaskset.load()eagerly? If it does, each of the 16 Terminal-Bench workers reads the Harbor/TMax dataset, and that line is wrong.- Does Monarch's
choosebalance by load? With whole 32-rollout groups on one worker, random placement leaves some workers with twice the average number of containers. The real-model run's per-worker in-flight counts would answer this.
Details
- Gate: unchanged. Verifiers 0.4.1 and renderers 0.2.0 must move together, and the rollout worker is the right layer for the env.
close(): closing the watchdog's stdin endscat. Thenshsweeps once, backgrounds the second sweep and exits, sowait(60)returns after the first sweep. stdout is not piped, so the background subshell can't block it.to_dictcallsreplace(self, environment=None), which re-runs__post_init__. That check never readsenvironment, so it is safe.slot.task.data.name or slot.task.data.idxlogs0for a nameless task with index 0. That is correct.
Not verified: Verifiers 0.4.1 internals (eager taskset loading, and whether TaskData always has a name attribute). No Docker or GPU behavior was checked.
| no_proxy = os.environ.get("no_proxy", "") | ||
| no_proxy = ",".join(filter(None, (no_proxy, "127.0.0.1", "localhost"))) | ||
| os.environ["no_proxy"] = no_proxy | ||
| os.environ["NO_PROXY"] = no_proxy |
There was a problem hiding this comment.
This reads only the lowercase no_proxy, then overwrites both spellings. Say a host sets only NO_PROXY=.corp.internal along with HTTPS_PROXY. After setup_async, both variables are 127.0.0.1,localhost, so the worker and every subprocess it starts (harness installs through uv, the docker CLI) now send internal hosts through the proxy. The code came from env_server.py, so the bug isn't new, but this PR is the one moving it. Merge both spellings:
| no_proxy = os.environ.get("no_proxy", "") | |
| no_proxy = ",".join(filter(None, (no_proxy, "127.0.0.1", "localhost"))) | |
| os.environ["no_proxy"] = no_proxy | |
| os.environ["NO_PROXY"] = no_proxy | |
| no_proxy = ",".join( | |
| filter( | |
| None, | |
| ( | |
| os.environ.get("no_proxy"), | |
| os.environ.get("NO_PROXY"), | |
| "127.0.0.1", | |
| "localhost", | |
| ), | |
| ) | |
| ) | |
| os.environ["no_proxy"] = no_proxy | |
| os.environ["NO_PROXY"] = no_proxy |
The TODO above also works around a Verifiers gap. Like the watchdog's TODO, it needs an upstream issue link (CLAUDE.md principle 3).
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
7d72cb7 to
764c31e
Compare
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 1m 19s —— View job Needs discussion: the new push changes none of the open items. The human-written summary is still empty, the real-model Terminal-Bench run hasn't been done, and the |
There was a problem hiding this comment.
Verdict: Needs discussion -- every item from the 06:19 review is still open at 764c31e. The PR is still a draft waiting on its own real-model Terminal-Bench run, and a maintainer still has to accept the +4.7 GB host RAM and the whole-group-per-worker placement.
What this PR does. Verifiers 0.4.1 deleted the ZMQ env server. Each VerifiersRolloutWorker now loads the env in setup_async, holds env.serving() until close() (called from the actor's __cleanup__), and runs each rollout as env.run_slot(...). A per-worker sh watchdog removes the worker's verifiers.run=$VF_RUN_ID containers if the worker is killed. Verifiers moves to 0.4.1 and renderers to 0.2.0 together.
Example.
before: rollout worker --ZMQ--> env server (16 pool procs) --> agent loop --HTTP--> GenerationServer
after: rollout worker: env.run_slot x group_size --HTTP--> the same worker's GenerationServer
host with only NO_PROXY=.corp.internal -> after setup_async: no_proxy=NO_PROXY=127.0.0.1,localhost
Must fix (still open)
- PR description: "Summary (human-written)" is still empty, and the description still lists the real-model Terminal-Bench run as "still open before ready" (in-flight rollouts per worker, render wait, host RAM against 26 GB). Both are needed before this PR leaves draft.
torchtitan/rl/examples/verifiers/rollouter.py:578and:179-- both upstream workarounds (the container watchdog and the loopbackno_proxyedit) still have no Verifiers issue link. The watchdog TODO points at 0.4.0's_arm_teardown, and theno_proxyTODO links nothing. Please file one Verifiers issue for each gap and link it in its TODO (CLAUDE.md principle 3), so both get deleted once upstream fixes them.
Should consider (still open)
torchtitan/rl/examples/verifiers/rollouter.py:180-183-- reads only lowercaseno_proxyand overwrites both spellings, so a host that sets onlyNO_PROXYloses its entries. The fix is in the earlier inline suggestion.tests/rl/unit_tests/cpu/test_verifiers_example.py(end-to-end test) --setup_asyncandclosestill run in the same task. Nothing guards the assumption atrollouter.py:155-157that serving resources aren't bound to a task. To fix it, wrap each call inasyncio.create_task(...). The test also leavesVF_RUN_ID,no_proxyandNO_PROXYset for later tests; usemonkeypatch.setenv/delenvup front so they get restored.
Questions (still open)
- Does
load_environmentcalltaskset.load()eagerly? If it does, each of the 16 Terminal-Bench workers reads the Harbor/TMax dataset, and the README line "workers never load the dataset" is wrong. - Does Monarch's
choosebalance by load? With whole 32-rollout groups on one worker, random placement leaves some workers with twice the average number of containers.
Details
- At HEAD, the hunks for the items above (
rollouter.pysetup_async/close/watchdog, the end-to-end test, the recipe) match what the 06:19 review saw. The new push changed none of them. - Re-checked:
close()after a failed or skippedsetup_asyncis safe (the exit stack is empty,GenerationServer.close()is a no-op, and the watchdog isNone). The watchdog blocks onreadbefore it checks fordocker, soclose()'s write to its stdin never hits a closed pipe in the normal path. - Gate: unchanged. The two pins must move together, and the rollout worker is the right layer.
Not verified: Verifiers 0.4.1 internals (eager taskset loading, TaskData.name) and all Docker/GPU behavior.
764c31e to
8848afc
Compare
|
Claude finished @felipemello1's task in 47s —— View job Needs discussion: picking up the |
There was a problem hiding this comment.
Verdict: Needs discussion -- at d0de8ae, this PR picks up the MessageEnvRolloutWorker rename from below cleanly and adds no new problems. The same three items still keep it in draft.
What changed since the last review. The PR below renamed the stock RolloutWorker to MessageEnvRolloutWorker with no alias. This PR now uses the new name in torchtitan/rl/README.md, next to BaseRolloutWorker and VerifiersRolloutWorker. There is no bare RolloutWorker left anywhere in the repo at HEAD. VerifiersRolloutWorker still subclasses BaseRolloutWorker, so the rename leaves its code path alone.
Example.
torchtitan/rl/README.md
before: Subclass `RolloutWorker` or `Rollouter` ...
after: Subclass `MessageEnvRolloutWorker` or `Rollouter` ...; a worker whose env isn't a
`MessageEnv` subclasses `BaseRolloutWorker` (e.g. `VerifiersRolloutWorker`)
Must fix (still open)
- PR description: "Summary (human-written)" is still empty. The real-model Terminal-Bench run (rollouts in flight per worker, render wait, host RAM against 26 GB) also hasn't been done; the recipe's
worker_pool_sizeTODO tracks it. The PR can't merge while row 0 is under it either, as the description says. torchtitan/rl/examples/verifiers/rollouter.py: none of the three TODOs that work around Verifiers gaps (no_proxyinsetup_async, theVF_RUN_IDlimiter scope, the container watchdog) links a Verifiers issue yet (CLAUDE.md principle 3). The author says the issues are drafted and waiting for their OK to file.
Details
- I searched the repo at HEAD for
\bRolloutWorker\band got no matches. Every worker-name reference in the diff isBaseRolloutWorker,MessageEnvRolloutWorkerorVerifiersRolloutWorker. - The core hunks match the last review:
BaseRolloutWorker.close(), the actor's__cleanup__, and the removedRollouter.setup_async(worker_config=...). - Gate: unchanged. The two pins have to move together, and the rollout worker is the right layer for the env.
Not verified: Verifiers 0.4.1 internals. I didn't run any tests here, and no Docker or GPU behavior was checked.
|
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 2m 2s —— View job Needs discussion: the reorder and the three passes add no new problems at |
There was a problem hiding this comment.
Verdict: Needs discussion -- at be1e7c3, the reorder and the three passes add no new problems. The same three items still keep this PR in draft.
What changed since the last review. This PR now sits directly on "taskset package ids" (row 4). "One handle per rollout worker" (row 6) and "Spread rollout workers" (row 7) are now above it. So at this head, Rollouter.run_group_rollouts sends each group with Monarch's run_group.choose(...) (torchtitan/rl/rollout/rollouter.py:256), and the description's NOTE now says exactly that. The __cleanup__ check is again its own test, test_stopping_the_rollout_workers_closes_each_worker in test_shutdown.py. The test it was folded into last time belongs to row 6, so at this base test_shutdown.py has no real-process rollout-worker test to extend. A standalone test is the right call here. The VerifiersRollouter docstring now draws where each process runs, the Verifiers README has a call-order table, and the Terminal-Bench README notes that containers run on Docker's bridge network.
Example.
VerifiersRollouter docstring, rl_grpo_qwen35_9b_terminal_bench under SlurmLauncher:
Layout: trainer (8 GPUs) -> mesh "trainer" (1 node); 8 x 1-GPU generators -> "node_0"
host 0: trainer, controller, router, batcher, 16 rollout workers (spawn_cpu_procs), 16 watchdogs
host 1: 8 generators
Must fix (still open)
- PR description: "Summary (human-written)" is still empty. The real-model Terminal-Bench run (rollouts in flight per worker, render wait, host RAM against 26 GB) also hasn't been done; the recipe's
worker_pool_sizeTODO tracks it. The PR can't merge while row 0 is under it either, as the description says. torchtitan/rl/examples/verifiers/rollouter.py: none of the three TODOs that work around Verifiers gaps (no_proxyinsetup_async, theVF_RUN_IDlimiter scope, the container watchdog in_start_container_watchdog) links a Verifiers issue yet (CLAUDE.md principle 3). The author says the issues are drafted and waiting for their OK to file.
Details
- I checked the new docstring diagram against the code.
Layoutpacking (launcher/base.py:179-205) gives the trainer its own node and puts the eight 1-GPU generators on a shared one. The router, batcher and rollout workers come fromspawn_cpu_procson the controller host (actors/monarch/system.py:100,169-182). SlurmLauncher'sbind_tois a listen address, not CPU pinning, so "No TorchTitan process is pinned to cores" holds. - The core hunks match the last review:
BaseRolloutWorker.close(), the actor's__cleanup__, the removedRollouter.setup_async(worker_config=...), and thenum_threads_per_workerdocstring.close()still sends "clean" only afteraclose()returns. - Outside deleted lines, nothing in the repo still mentions
env_server,EnvClient,serve_env,ServeConfig,HarborEnv,connection_timeout_sec, or the 0.4.0/0.1.x pins. - Gate: unchanged. The two pins have to move together, and the rollout worker is the right layer for the env.
Not verified: Verifiers 0.4.1 internals, including the new Terminal-Bench README claim that Docker containers use the bridge network rather than host networking. I didn't run any tests, and no Docker or GPU behavior was checked.
|
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. Below this PR, |
|
Claude finished @felipemello1's task in 1m 38s —— View job Needs discussion: removing the |
There was a problem hiding this comment.
Verdict: Needs discussion -- at bd22d90, the rebase onto main and the removal of worker_kwargs add no new problems. The same three items still keep this PR in draft.
What changed since the last review. In the PR below, env_server_address is now a constructor argument of VerifiersRolloutWorker, passed through Rollouter.setup_async(worker_kwargs=...) -> spawn_rollout_workers(**kwargs) -> RolloutWorkerActor(worker_kwargs=...). This PR deletes that whole path in both ActorSystem signatures, the Monarch actor, and Rollouter.setup_async, along with the TODO that asked for exactly this. worker_config.build() now takes no arguments. The README's "Integration flow" is now a lane diagram: one column per process, with rows for run_group, start, chat, reserve, generate, release_reservation, grade, release_session, and RolloutGroup.
Example.
below this PR: VerifiersRollouter.setup_async -> env_server.start() -> super().setup_async(
worker_kwargs={"env_server_address": addr}) -> RolloutWorkerActor(worker_kwargs=...)
-> VerifiersRolloutWorker(config, env_server_address=addr)
this PR: Rollouter.setup_async -> spawn_rollout_workers(config, num_workers, num_threads)
-> RolloutWorkerActor -> worker_config.build() -> VerifiersRolloutWorker(config)
Must fix (still open)
- PR description: "Summary (human-written)" is still empty. The real-model Terminal-Bench run (rollouts in flight per worker, render wait, host RAM against 26 GB) also hasn't been done; the recipe's
worker_pool_sizeTODO tracks it. torchtitan/rl/examples/verifiers/rollouter.py: three TODOs work around Verifiers gaps (no_proxyinsetup_async, theVF_RUN_IDlimiter scope, the container watchdog in_start_container_watchdog), and none of them links a Verifiers issue yet (CLAUDE.md principle 3). The author says the issues are drafted and waiting for their OK to file.
Should consider (new)
torchtitan/rl/examples/verifiers/README.md:45-47-- the lane diagram leaves out the controller'srelease_groupscall at group end, which is the call that frees the group's KV (inline).
Details
- After the PR, the repo has no references to
worker_kwargs,env_server_address,env_server,EnvClient,serve_env,ServeConfigorHarborEnvoutside the deleted lines. - The
release_reservationrow's "no reply" matches the controller'sgenerate_fn(controller.py:685,.broadcast). - Core hunks match the last review:
BaseRolloutWorker.close(), the actor's__cleanup__, andtest_stopping_the_rollout_workers_closes_each_workerintest_shutdown.py.close()still writes "clean" only afteraclose()returns. - Gate: unchanged. The two pins have to move together, and the rollout worker is the right layer for the env. With look-aside routing merged, the "Must not merge while row 0 is under it" caveat from the last two reviews no longer applies.
Not verified: Verifiers 0.4.1 internals. I didn't run any tests, and no Docker or GPU behavior was checked.
| 11 | |--release_session--------->| | one per trace, after | ||
| | | | | | run_slot returns | ||
| 12 |<-RolloutGroup---| | | | scored |
There was a problem hiding this comment.
The lanes stop at row 12, so they leave out one of the release calls: after the group returns, the controller calls router.release_groups([group_id]) (controller.py:1202), and that call frees the group's held KV. The VerifiersRollouter docstring points here for "Call order, with the release calls", and the new comment at rollouter.py:372 depends on release_groups running. As drawn, a reader would take row 11 (release_session) as the only cleanup. One more row fixes it:
| 11 | |--release_session--------->| | one per trace, after | |
| | | | | | run_slot returns | |
| 12 |<-RolloutGroup---| | | | scored | |
| 11 | |--release_session--------->| | one per trace, after | |
| | | | | | run_slot returns | |
| 12 |<-RolloutGroup---| | | | scored | |
| 13 |--release_groups---------------------------->| | frees the group's KV |
There was a problem hiding this comment.
Reply from claude: Fixed in e933617: row 13 is release_groups, from the controller to the router, with the note "drops its cache salts". It frees held KV only when the engine holds session KV, and no recipe sets session_kv_holder, so "frees the group's KV" would overstate it. Step 4 now says the controller releases the group before TitanRL trains on it (controller.py:1202, then finalize_work).
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
|
Reply from claude: @claude please review. This push adds the |
|
Claude finished @felipemello1's task in 1m 16s —— View job Needs discussion: the new |
There was a problem hiding this comment.
Verdict: Needs discussion -- at e933617, the README fix resolves the last review's item and adds no new problems. The same three items still keep this PR in draft.
What changed since the last review. The Verifiers README's lane diagram now has a row 13: the controller calls release_groups on the router after the group returns. Step 4 now gives the order the controller uses: it releases the group, then TitanRL trains on it.
Example.
controller.py:1202 await generator_router.release_groups.call_one([work.group_id]) <- row 13
controller.py:1203 await group_buffer.finalize_work(group) <- "trains on it"
router.release_groups -> fan-out to each generator -> engine_loop.release_groups:
"drop the pinned cache salts" (held KV too, only with session_kv_holder)
Resolved since the last review
torchtitan/rl/examples/verifiers/README.md:48: therelease_groupsrow is there, and its note ("drops its cache salts") matches what the call does by default.Generator.release_groups(generator/generator.py:432) drops the pinned salts. It frees held KV only whenVLLMEngine.Config.session_kv_holderis set, and no recipe sets it, so narrowing the note from my suggestion was the right call. The arrow ends at the router column, which matchesInterGeneratorRouter.release_groups(routing/inter_generator.py:246) fanning the call out to each generator.
Must fix (still open)
- PR description: the "Summary (human-written)" section is still empty. The real-model Terminal-Bench run (rollouts in flight per worker, render wait, host RAM against 26 GB) also hasn't been done; the recipe's
worker_pool_sizeTODO tracks it. torchtitan/rl/examples/verifiers/rollouter.py: three TODOs work around Verifiers gaps (no_proxyinsetup_async, theVF_RUN_IDlimiter scope, and the container watchdog in_start_container_watchdog). None of them links a Verifiers issue yet (CLAUDE.md principle 3). The author says the issues are drafted and waiting for their OK to file.
Details
- The new row's columns line up with rows 11 and 12: the arrowhead lands on the router column, and the note starts in the same column as the others.
- Gate: unchanged. The two pins have to move together, and the rollout worker is the right layer for the env.
Not verified: Verifiers 0.4.1 internals. I didn't run any tests, and no Docker or GPU behavior was checked.
| ThreadPoolExecutor(max_workers=num_threads) | ||
| ) | ||
| self._worker = worker_config.build(**worker_kwargs) | ||
| self._worker = worker_config.build() |
There was a problem hiding this comment.
this makes sense to me, but why was this in the first place. do you know?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
|
|
||
| def load(self) -> list[VerifiersMathTask]: | ||
| """Build the tasks consumed by both the dataset and environment server.""" | ||
| """Build the tasks the controller samples; rollout workers rebuild each from its data.""" |
There was a problem hiding this comment.
lets not put "controller" her, as this may change in the future. It build tasks for training/eval. Thats it, no?
I dont get the part of "rebuild"
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| async def sync_log_step(self, step: int) -> None: | ||
| sl.set_step(step) | ||
|
|
||
| async def __cleanup__(self, exc: Exception | None) -> None: |
There was a problem hiding this comment.
noob question: should this is cleanup or close? i dont think that we have cleanup in other workers, do we? Its fine to keep as it is, i just want to understand.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # Verifiers' train client always sends these switched off, so vLLM ignores the model's | ||
| # generation_config. TorchTitan's generator samples the full vocabulary, which is the | ||
| # same; it can't honor any other value. | ||
| disabled_values = {"top_k": -1, "min_p": 0.0} |
There was a problem hiding this comment.
why a dict and not a set? Attributing values is confusing. Also, comment can be 2 lines instead of 3, and written better, something like: "TODO: Titan doesn't current support different top_k. Raise early.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| 6 |<-scored group----|<-trace, reward-| | | | | ||
| 7 |--batch, packed by the batcher process-------------------------------------------->| | ||
| | | | | |<-new weights| | ||
| controller rollout worker container generators trainer |
There was a problem hiding this comment.
as i mentioned before, in another PR, this should be in verifiers readme.md. In this PR, it is added there, so we can delete it from here, as its the same thing, and we can have one source of truth and point to that doc instead.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| - Workers busy on CPU: raise the rollouter's `worker_pool_size` (default 4; the Terminal-Bench | ||
| recipe uses 16). |
There was a problem hiding this comment.
dont mention specific examples, specially config values that differ from example to example.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| --config <recipe function name> | ||
| ``` | ||
|
|
||
| ## Scaling |
There was a problem hiding this comment.
i dont like this section too much. I think we can delete it.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # TODO: 16 is untuned. Set it from a Terminal-Bench run with Docker: rollouts in flight | ||
| # per worker, render wait and host RAM. The `VerifiersRollouter` docstring and the | ||
| # Verifiers README's "Scaling" section copy 16: update them with it. | ||
| worker_pool_size=16, |
There was a problem hiding this comment.
i asked about it in a different PR. Can we have a better heuristic, defined in the controller, that the user can override, based on buffer size, number of cpus available, etc
There was a problem hiding this comment.
Also, too many comments//todos. Lets see what we can do about them and be less verbose.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| """Start this worker's generation server, then load and serve the Verifiers env. | ||
| Verifiers renders with its own renderer, so no tokenizer here.""" | ||
| del tokenizer_config | ||
| if vision_processor_config is not None: |
There was a problem hiding this comment.
didnt we merge in titan some PRs for vision models? wouldnt this break them?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| @@ -75,25 +84,33 @@ async def __call__(self, rollout: Rollout, env_input: object) -> float: | |||
|
|
|||
|
|
|||
| class VerifiersRollouter(Rollouter): | |||
There was a problem hiding this comment.
this docstring is poorly written. It should be something like:
"""Class responsible for the logic to create rollouts. It is the TitanRL integration with verifiers. More details can be found in
In this integration,
Titan provides:
- Generator endpoint
- Sandbox
- bla bla bla
Verifiers:
- Outputs a completed rollout, later scored in
make_scored_groupand casts it to TitanRL expected format."""
We could also add some info that this runs multiple workers, one per agent, bla bla bla. Not sure. Wdyt? Like the TLDR of the data flow.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| """How a rollout worker runs a Verifiers group; `__post_init__` fills in | ||
| `worker.environment.taskset`.""" |
There was a problem hiding this comment.
why does this need to happen in post init? it isnt very elegant. Is this also how other libraries integrate with verifiers?
Why not create some method, like worker: update task?
Also, not for this PR, but in the future we may have multiple tasks in the same training job, e.g. both dapo-math and terminal bench.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| environment: VerifiersEnvConfig | ||
| """Verifiers env and agent config, e.g. `vf.SingleAgentEnvConfig(agent=...)`. Leave | ||
| `environment.taskset` unset: `VerifiersRollouter` copies the training taskset in.""" |
There was a problem hiding this comment.
this doesnt sound right. If we will copy it in, it should be a proper method. Its also unclear how we would deal with different environments, like math and terminal bench at the same time. Maybe these are a different Env type and the "env" definition is loaded here? i would need to understand better the data flow
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| def to_dict(self) -> dict[str, Any]: | ||
| # The generic dump can't serialize the pydantic env config. | ||
| return { | ||
| **BaseRolloutWorker.Config.to_dict(replace(self, environment=None)), | ||
| "environment": self.environment.model_dump(mode="json"), | ||
| } |
There was a problem hiding this comment.
why would we need to_dict?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| del tokenizer_config, vision_processor_config | ||
| """Start this worker's generation server, then load and serve the Verifiers env. | ||
| Verifiers renders with its own renderer, so no tokenizer here.""" | ||
| del tokenizer_config |
There was a problem hiding this comment.
whats the idea behing deleting the tokenizer config? where do we tokenize them? and it tokenization distributed?
There was a problem hiding this comment.
is it because the renderes has it? If so, then i dont see wy we need tokenizer_config in the signature in the first place. This should also be true for the MessageEnv worker, no?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
|
Reply from claude: answers to the comments on this PR that have no inline thread.
In "Rollouter: least-loaded placement; the controller sizes the pool from rollouts_per_worker", whole groups stay on one worker, placed on the least-loaded one, at most |
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 5m 14s —— View job Verdict: Needs discussion -- see the review on this PR. |
There was a problem hiding this comment.
Verdict: Needs discussion -- the design is right: 0.4.1 removes serve_env, so each rollout worker runs its own envs, and the PR is -530 LoC net. But a GPU run is still pending, the README partly ignores @felipemello1's earlier comments, and two edits loosen explicit contracts.
What this PR does. It bumps Verifiers to 0.4.1 and renderers to 0.2.0. It deletes the separate env server and the Docker watchdog. Each VerifiersRolloutWorker now loads its envs, one per env config, and runs env.run_slot once per rollout. Model calls go through a loopback GenerationServer in that worker. Failed rollouts get reward None in score_group, which replaces error_reward=0.0 in the recipes. Core changes: Configurable._convert dumps pydantic models, so RenderersConfigAdapter.to_dict is deleted.
Example.
before: controller -> env server actor (serve_env) -> rollout worker -> generator
after: controller -> rollout worker [vf env -> interception -> train client -> GenerationServer] -> generator
group of 8, rollout 3 hits a SandboxError -> status error_infra, reward None,
and the other 7 train
Must fix
- The PR description: "Summary (human-written)" is empty. Its NOTE also says nothing has run on GPUs yet and that one short Terminal-Bench run gates the merge. Add that run's loss/reward and status rates before this merges.
generation_server.py:207-- the allowlist of sampling params is gone, so unknown params are ignored without a word (inline).rollouter.py:264--score_groupgrades rollouts and then throws the grades away. It may raise TypeError on a Nonetrace.reward(unverified). Filter before scoring (inline).README.md:105-172-- @felipemello1's request to drop example-specific values and the scaling section is only partly addressed (inline).- TODOs that work around Verifiers gaps have no upstream issue link (principle 3):
rollouter.py:593(no_proxy on loopback) andverifiers_terminal_bench.py:127(renderer lock on the event loop).
Should consider
rollouter.py:237-- the multi-agent list split can't run; return a singleRollout(inline).rollout_worker.py:73-- the RDMA TODO is unrelated to this bump (inline).rollouter.pyrun_iddefault_factory readsVF_RUN_IDat config build time, and a random uuid ends up in the dumped job config. That's fine if intended, but two configs built in one process get different ids.- With the watchdog gone, a killed worker now leaves Docker containers behind until someone runs
docker rmby label (README). A maintainer should accept this tradeoff explicitly.
Questions
-
@felipemello1's earlier questions, answered from the code:
worker_kwargscarriedenv_server_addressto each worker. It disappears along with the env server.- Vision: the renderer Verifiers builds gets no processor, so
setup_asyncraises for image models. MessageEnv vision recipes are unaffected. - The tokenizer is gone because the train client renders in each worker with its own renderers copy.
Do these match your intent?
Details
Gate: the problem is real. 0.4.1 removes serve_env, and the pins must move together. The layer is right: Verifiers runs inside the rollout worker, and core only gets the generic pydantic dump in configurable.py. The rewrite resolves these earlier comments:
- the watchdog
- the
VF_RUN_IDscope - the
to_dictoverride and its test num_threads_per_worker(now None, with a reason)- the
__post_init__taskset copy - one env per env config
- the top_k/min_p dict
- the
dapo_math/data.py"controller"/"rebuild" docstring
Tests: the generation server, status and lifecycle tests guard real invariants (sessions released, close order, calls in flight drained). The scoring test doesn't cover a None grade.
Not verified: what sampling keys the Verifiers 0.4.1 client sends, whether trace.reward is None on failed traces, and anything on GPU.
| # TODO: TitanRL's generator doesn't support other top_k or min_p yet. Raise early. | ||
| for name, full_vocabulary in (("top_k", -1), ("min_p", 0.0)): | ||
| if sampling_params.get(name, full_vocabulary) != full_vocabulary: | ||
| raise ValueError( | ||
| f"sampling_params.{name}={sampling_params[name]!r} is unsupported" | ||
| ) |
There was a problem hiding this comment.
This drops the old allowlist (unsupported sampling parameters: ...). Now only top_k and min_p get checked, and every other key is ignored without a word. Say a Verifiers env sets repetition_penalty=1.1, presence_penalty, min_tokens, or stop strings: the generator samples without them, and the trace logprobs no longer match what the env asked for. Nothing reports it. That breaks principle 8.
Smallest fix: bring the allowlist back next to the no-op checks. This is about 4 lines:
| # TODO: TitanRL's generator doesn't support other top_k or min_p yet. Raise early. | |
| for name, full_vocabulary in (("top_k", -1), ("min_p", 0.0)): | |
| if sampling_params.get(name, full_vocabulary) != full_vocabulary: | |
| raise ValueError( | |
| f"sampling_params.{name}={sampling_params[name]!r} is unsupported" | |
| ) | |
| # TODO: TitanRL's generator doesn't support other top_k or min_p yet. Raise early. | |
| for name, full_vocabulary in (("top_k", -1), ("min_p", 0.0)): | |
| if sampling_params.get(name, full_vocabulary) != full_vocabulary: | |
| raise ValueError( | |
| f"sampling_params.{name}={sampling_params[name]!r} is unsupported" | |
| ) | |
| honored = {"temperature", "top_p", "max_tokens", "seed", "stop_token_ids", "top_k", "min_p"} | |
| protocol = {"logprobs", "skip_special_tokens", "routed_experts_prompt_start"} | |
| if unsupported := sorted(set(sampling_params) - honored - protocol): | |
| raise ValueError(f"unsupported sampling parameters: {unsupported}") |
Unverified: I haven't checked which other keys the 0.4.1 renderer client always sends. If it sends some with no-op defaults (e.g. repetition_penalty=1.0), add them to the (name, no-op value) loop instead of the allowlist. test_sampling_config_takes_only_what_the_generator_honors could take one more parametrize row for this case.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| rubric_outputs = await super().score_group(rollouts, env_input) | ||
| scored = [] | ||
| for rollout, rubric_output in zip(rollouts, rubric_outputs, strict=True): | ||
| # Validation groups have negative ids (`Controller`'s `_validation_group_ids`). | ||
| is_validation_timeout = ( | ||
| rollout.group_id < 0 and rollout.status is RolloutStatus.ERROR_TIMEOUT | ||
| ) | ||
| keeps_grade = rollout.status in _TRAINED_STATUSES or is_validation_timeout | ||
| scored.append(rubric_output if keeps_grade else RubricOutput(reward=None)) | ||
| return scored |
There was a problem hiding this comment.
This calls the rubric on every rollout, then throws away the grades of ERROR, ERROR_TIMEOUT (training) and TRUNCATED_PROMPT_TOO_LONG rollouts. That has two costs:
- Reward fns run for nothing. That matters with a custom rubric, e.g. an LLM judge.
- Unverified: a failed trace may carry
trace.reward = None. ThenRewardFromVerifiersreturns None, andRubric._score_single_rolloutevaluatesw * None(rubric.py:154). That raises a TypeError, and the whole group fails, which contradicts "a failure stays inside its episode". On the base branch,error_reward=0.0in the recipes short-circuited errored rollouts, but this PR removes it.
Decide keeps_grade first and score only those rollouts. This is simpler and doesn't depend on how the rubric treats failures:
keeps_grade = [
rollout.status in _TRAINED_STATUSES
# Validation groups have negative ids (`Controller`'s `_validation_group_ids`).
or (rollout.group_id < 0 and rollout.status is RolloutStatus.ERROR_TIMEOUT)
for rollout in rollouts
]
graded = iter(await super().score_group(
[r for r, keep in zip(rollouts, keeps_grade) if keep], env_input
))
return [next(graded) if keep else RubricOutput(reward=None) for keep in keeps_grade]The existing scoring test uses rollouts with no turns, so RewardFromVerifiers always returns 0.0 there, and the None-reward path is never exercised.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # `make_scored_group` numbers a raised entry by its position, so each episode's first | ||
| # rollout, or its error, sits at the episode's index. Rollouts of other trainable agents | ||
| # in one episode follow. | ||
| first_rollouts: list[Rollout | BaseException] = [] | ||
| other_agent_rollouts: list[Rollout] = [] | ||
| for episode_output_or_error in episode_outputs_or_errors: | ||
| if isinstance(episode_output_or_error, BaseException): | ||
| first_rollouts.append(episode_output_or_error) | ||
| continue | ||
| rollouts = episode_output_or_error | ||
| first_rollouts.append(rollouts[0]) | ||
| other_agent_rollouts.extend(rollouts[1:]) | ||
| return await self.make_scored_group( | ||
| first_rollouts + other_agent_rollouts, sample, group_id=group_id | ||
| ) |
There was a problem hiding this comment.
This code can never run. _run_episode raises unless there is exactly one trainable trace (line 342), so rollouts[1:] is always empty, other_agent_rollouts never gets an element, and the list return at 347-356 always holds one item. The TODO at line 340 already records the multi-agent case.
Have _run_episode return a single Rollout (-> Rollout, (trace,) = trainable_traces after the check). Then this block becomes:
return await self.make_scored_group(
list(episode_outputs_or_errors), sample, group_id=group_id
)That removes about 12 lines plus the "A list:" docstring and comment. Bring the list back along with the per-agent advantages that need it.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| ## What crosses each hop | ||
|
|
||
| One model call at 128K tokens of context (turn 133 of an agent's rollout), measured on CPU: | ||
|
|
||
| ```text | ||
| hop what crosses bytes | ||
| agent (container) -> egress proxy (worker) the whole chat history, JSON 573 KB | ||
| egress proxy -> interception server the same bytes, relayed 573 KB | ||
| train client -> GenerationServer (loopback) the whole prompt's token ids 586 KB | ||
| generate_fn -> generator (Monarch) the whole prompt's token ids 374 KB | ||
| generate_fn -> router the request and session ids < 1 KB | ||
| each reply, back to the agent the new completion only a few KB | ||
| ``` | ||
|
|
||
| - Each call carries the whole history: the agent speaks OpenAI chat, and the generator gets the | ||
| full prompt. So the bytes a rollout moves grow with turns x context: about 140 MB of encode and | ||
| decode for a 128K rollout of 133 turns, at most about 0.6 MB per call. | ||
| - The cost is worker CPU to encode and decode: about 50 ms per call at 128K, about 4 s per | ||
| rollout. At most 0.6 MB per call is little for the network. | ||
| - Memory grows only with the rollout's own length. The trace keeps each message once, with | ||
| only the tokens it adds; the GenerationServer keeps counters per session; a `Rollout` keeps each | ||
| turn's new prompt tokens and its completion, about 1.4 MB at 128K. | ||
| - Size limits. The GenerationServer reads request bodies up to 1 GiB; replies have no limit. | ||
| The largest Monarch message here is a worker's scored group, G x one `Rollout`: about 44 MB for | ||
| 32 rollouts at 128K. With router replay or top-k logprobs on, the batcher's packed step becomes | ||
| the largest message. A recipe that turns either on also sets | ||
| `async_loop.batcher.rdma_min_tensor_bytes`, so those tensors go by RDMA: Monarch caps a message | ||
| at 10 GiB and fails the whole actor mesh above it. | ||
|
|
||
| ## Concurrency | ||
|
|
||
| One cap: the controller keeps at most K groups of G rollouts in flight, with | ||
| K = `(target_offpolicy_steps + 1) x num_prompts_per_train_step` and G = `num_samples_per_prompt`. | ||
| A group is in flight from when a worker starts it until it returns to the controller. The rest | ||
| follows from K x G. Example column: K = 48 groups of G = 32 (1,536 rollouts in flight), V = 89 | ||
| validation tasks. | ||
|
|
||
| | what | how many | example | set by | | ||
| |---|---|---|---| | ||
| | rollout workers, processes on the controller host | ceil(K x G / rollouts_per_worker) | 24 | `Rollouter.Config.rollouts_per_worker` (64) | | ||
| | rollouts per worker | a sizing target: whole groups are placed, so a worker can hold up to one group more (groups of 24 at 64: 72); a group larger than it raises | 64 | the same | | ||
| | sandboxes | one per running rollout: at most K x G + V | 1,625 | the agent's runtime | | ||
| | interception servers per worker | one per 32 rollouts in flight; never shrink | 2 | Verifiers: the env's `interception.multiplex` | | ||
| | renderers per worker, about 175 MB each | one per 256 model calls in flight; never shrink | 1 | Verifiers: `vf.TrainClientConfig.multiplex` | | ||
| | threads per worker | Python's default, min(32, CPUs + 4) | 32 | `Rollouter.Config.num_threads_per_worker` (the Verifiers recipes set None; default 4) | | ||
| | controller host CPUs | one per worker, plus local sandboxes | 24 + sandboxes | the host | | ||
|
|
||
| - Placement: the Rollouter counts rollouts in flight per worker and sends each group to the | ||
| worker with the lowest count. It is a list of numbers in the controller, so it works wherever | ||
| the workers run. A group's count drops when the whole group returns. | ||
| - A whole group runs on one worker, so a group larger than `rollouts_per_worker` raises when the | ||
| config is built. Example: groups of 128 at the default 64 raise; set `rollouts_per_worker=128` | ||
| and 16 groups run on 16 workers, one group each. | ||
| - Each rollout starts its own sandbox and removes it when it ends. Validation | ||
| sends its V tasks at once, beside training (`ValidationConfig.steps`), hence the + V. Usually far | ||
| fewer run: a group stays in flight until its slowest rollout ends. | ||
| - Verifiers' pools, measured in one worker: 1, 1, 2, 4 and 10 interception servers at 1, 32, 33, | ||
| 100 and 300 rollouts. A second renderer loads only above 256 model calls in flight, and loading | ||
| it stops the worker's event loop for 0.4-1.2 s. At 64 rollouts per worker and groups of at most | ||
| 64, a worker holds under 128 rollouts, so it keeps one renderer. A local runtime (Docker too) | ||
| opens no tunnel; a remote provider without its own tunnel opens one per interception server. | ||
| TitanRL adds no knob for these pools: set them in the Verifiers config. | ||
| - Threads run renders and blocking runtime calls. With 4, renders waiting for the renderer lock | ||
| held every thread, and other thread work (e.g. sandbox cleanup) waited up to 346 ms in a | ||
| 100-rollout test, vs 12 ms with 32. More threads are not faster: renders hold Python's GIL. | ||
| - CPUs: a local Docker sandbox shares the controller host's CPUs with the workers. `--cpus` | ||
| limits a container but reserves nothing, so 24 workers and 200 running 1-CPU sandboxes want | ||
| about 224 CPUs. A remote provider runs sandboxes on its own machines. |
There was a problem hiding this comment.
@felipemello1 asked earlier not to mention specific example config values ("dont mention specific examples, specially config values that differ from example to example"), and to delete the scaling section. "Scaling" is gone, but "What crosses each hop" and "Concurrency" bring the same kind of content back:
- an example column (K=48, G=32, 24 workers, 1,625 sandboxes)
- measured byte counts at 128K
- pool counts at 1/32/33/100/300 rollouts
- 346 ms vs 12 ms thread waits
These numbers go stale with every Verifiers or recipe change. They also make the README about 2.4k words, up from about 700.
Suggestion: keep the one-cap rule (K x G in flight, rollouts_per_worker, a group larger than it raises). Keep the size limits (1 GiB request body, the 10 GiB Monarch cap and rdma_min_tensor_bytes). Keep the CPU note for local Docker. Drop the example column and the measurements, or move them into the PR description, where they describe this PR's testing.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # TODO: once a group's per-token arrays (router replay rows, top-k logprobs) pass about | ||
| # 3 GiB, send RDMA handles in this reply, registered once per rollout and released after | ||
| # the batcher reads them: Monarch caps a message at 10 GiB. |
There was a problem hiding this comment.
This is a core TitanRL TODO, and it isn't related to the Verifiers 0.4.1 / renderers 0.2.0 bump: any rollout worker with router replay or top-k logprobs hits the same limit. Following one concern per PR, move it to its own PR, or to the PR that adds router replay.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
|
Reply from claude: answers to the points in the review that have no inline thread.
Agreed, the run gates the merge of this PR and the next three in the stack. A 50-step Terminal-Bench run of this stack waits for free hosts; it hasn't started. When it ends, its loss, reward and status rates go into the description.
The two Verifiers issues aren't filed yet, so these TODOs have no link. Each names its gap: skip the proxy for a loopback base_url, and wait for the renderer lock on the event loop.
Intended. The config is built once per run and pickled to every worker, so all the workers share one id. Having it in the saved job config helps: the cleanup command that "Verifiers README: terms, concurrency and sandboxes" adds to the README filters containers by it. A launcher that wants a fixed id sets
The author accepted it in the design review, after the earlier review round. A maintainer's sign-off is still open. The watchdog covered only Docker, and only a killed worker. A graceful stop cancels each rollout, and its
They match the plan this PR follows, and each has its own thread: |
| # Verifiers' client in this worker calls its generation server on loopback. With | ||
| # http_proxy set, httpx sends even loopback requests to the proxy unless no_proxy | ||
| # names the host. | ||
| # TODO: drop once Verifiers' train client ignores env proxies for a loopback base_url. | ||
| # Keep the host's own entries from either spelling, e.g. NO_PROXY=.corp.internal. |
There was a problem hiding this comment.
this docstring is not helpful as it is. I am also skeptical of the TODO. Perhaps we are not using it correctly?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| del tokenizer_config, vision_processor_config | ||
| """Start this worker's generation server, then load and serve the Verifiers env. | ||
| Verifiers renders with its own renderer, so no tokenizer here.""" | ||
| del tokenizer_config |
There was a problem hiding this comment.
is it because the renderes has it? If so, then i dont see wy we need tokenizer_config in the signature in the first place. This should also be true for the MessageEnv worker, no?
| # One VF_RUN_ID per worker: "torchtitan-<uuid>", or "<launcher's VF_RUN_ID>-<uuid>". | ||
| # 1. Verifiers labels each container it starts `verifiers.run=$VF_RUN_ID`. | ||
| # 2. So the watchdog removes exactly this worker's containers when the worker dies. | ||
| # 3. Side effect: Verifiers' run-wide creation-rate limits (e.g. `PrimeConfig.creates_per_min`) | ||
| # apply per worker. | ||
| # TODO: drop the side effect once Verifiers keeps the container label and the limiter scope apart. | ||
| run_id_prefix = os.environ.get("VF_RUN_ID", "torchtitan") | ||
| os.environ["VF_RUN_ID"] = f"{run_id_prefix}-{uuid.uuid4().hex}" | ||
| self._container_watchdog = _start_container_watchdog(os.environ["VF_RUN_ID"]) |
There was a problem hiding this comment.
i think i am missing here some diagram showing exactly all components and their connections betwen envserver, generation server, rollout worker, shutdown process, etc. Like, some documentation i can read once, non verbose, diagram, enumerated, how did locally on discussion 190.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # Each group replaces this one slot. That is safe because every group's generate_fn routes the | ||
| # same way; keep per-group state out of it. | ||
| self._generation_server.set_generate_fn(generate_fn) |
There was a problem hiding this comment.
is this worker serving only one group at a time? My intuition is that each worker serves multiple groups, otherwise if we wanted to have 500 concurrent groups, we would need 500 cpus, for most of the part idle, waiting for tool call/generation.
In other words: is this state preserved for this one group?
But if this is serving multiple groups, then the generate_fn could be different across groups? I dont know if this is a real pattern though, i.e. we would have multiple generate_fn. Please check in other libraries. If it isnt, we could try to simplify this and NOT set it per group call, but something we set at the start?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # same way; keep per-group state out of it. | ||
| self._generation_server.set_generate_fn(generate_fn) | ||
| # Rebuild the controller's task from its data, as the taskset's `load` builds it. | ||
| task_type = self._verifiers_env.taskset.task_type() |
There was a problem hiding this comment.
i dont really get this. The sample should define the task type, no? sounds like bad design on our end.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| return turns | ||
|
|
||
|
|
||
| def _start_container_watchdog(run_id: str) -> subprocess.Popen: |
There was a problem hiding this comment.
Too verbose and too many todos. It doesn't sound elegant. Please double check.
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| because Verifiers runs the env and its agent loop, and a | ||
| `VerifiersRollouter` that copies the training taskset into the worker's env config. |
There was a problem hiding this comment.
| because Verifiers runs the env and its agent loop, and a | |
| `VerifiersRollouter` that copies the training taskset into the worker's env config. | |
| because Verifiers runs the env and its agent loop. |
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| verifiers_env_server=VerifiersEnvServer.Config( | ||
| environment=HarborEnvConfig( | ||
| worker=VerifiersRolloutWorker.Config( | ||
| environment=vf.SingleAgentEnvConfig( |
There was a problem hiding this comment.
i dont understand this: are we not using harbor anymore?
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
| # TODO: 16 is untuned. Set it from a Terminal-Bench run with Docker: rollouts in flight | ||
| # per worker, render wait and host RAM. The `VerifiersRollouter` docstring and the | ||
| # Verifiers README's "Scaling" section copy 16: update them with it. | ||
| worker_pool_size=16, |
There was a problem hiding this comment.
Also, too many comments//todos. Lets see what we can do about them and be less verbose.
There was a problem hiding this comment.
this was in an earlier pr. It seems that this wasnt properly rebased?
There was a problem hiding this comment.
Reply from claude: Right. "Run Verifiers groups in rollout workers" merged with two edits made in the web editor. GitHub's stack then rebased the next four PRs and stopped at this one, which rewrites the same lines. Fixed at 15:40 PST: this PR and the nine above it are rebuilt on the new base, with both edits carried up. This PR is one commit again (+843/-983).
There was a problem hiding this comment.
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one.
|
Reply from claude: This PR is replaced by the fresh draft "[rl] Verifiers: each rollout worker runs its Verifiers env; the env server is gone". It keeps the dataset config and taskset ids from main; the dataset redesign and the installed-package ids from this PR are on hold. The comments here were read when planning it. Closing this one. |
Summary (human-written)
Agent details
TLDR: Each rollout worker now runs its Verifiers envs itself, on Verifiers 0.4.0. The env server process and its pool are gone, and the env is configured once, in the dataset config. One picture of the whole path is in
torchtitan/rl/examples/verifiers/README.md.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".
Problem
serve_env), so the integration has to move before the pin can.VerifiersRolloutercopies the training taskset into the env server's config.Env.serving,Env.slotsandEnv.run_slot(..., on_trace=).Solution
close, and runs each rollout in its own task withenv.slots(task)andenv.run_slot.VerifiersTaskDataset.Config(env, select). Each sample carries it as JSON. The dataset parses it as the worker will, so an env a worker can't load fails when the dataset is built.on_trace).closecancels the running rollouts (eachrun_slotstops its own sandbox), then stops serving the envs, then the generation server.VerifiersRollouterand theworker_kwargspath in 4 core files.Rollouter.Config.num_threads_per_workertakes None (Python's default thread pool), which the two Verifiers recipes use. Also gone:VerifiersRolloutWorker.Config.renderer_multiplex(no recipe set it; Verifiers' default of 256 stays) andconnection_timeout_sec(the wait for the env server).Configurable.to_dictwrites pydantic fields (the dataset's env config) withmodel_dump(mode="json"), soRenderersConfigAdapter.to_dictgoes.You may ask:
trace: Any? PR 7 (sessions), PR 8 (the converter'svf.Trace) and PR 9 (the failure rule) replace them. This PR only moves the env.NOTE: not run on GPUs, on Verifiers 0.4.0. Merge this PR together with PRs 7-9, after one short Terminal-Bench run at PR 9's head: the GPU runs so far used the 0.4.1 shape.
TODOs in this PR: wait for a session's model calls in flight before its release (PR 7 does it); lazily deserialized task data; skip tasks whose first prompt never fits; mix two envs in one stream; several agents per episode; the vision processor; the proxy bypass (upstream Verifiers); Verifiers' renderer lock (upstream Verifiers).
Test plan
pip install -e torchtitan/rl/examples/verifiers/dapo_math -e torchtitan/rl/examples/verifiers/terminal_bench pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config # Verifiers 0.4.0: 973 passed, 1 skippedtest_a_group_runs_end_to_end_in_a_rollout_workerruns a real Verifiers env through the renderer client and the generation server, with a fake generator. Also new:test_close_cancels_the_running_rollouts_before_it_stops_the_envs,test_a_second_close_returns_while_the_first_still_stops_an_env,test_worker_serves_one_env_per_env_config_until_close,test_rollout_releases_every_session_verifiers_minted(a retried attempt's trace too),test_verifiers_task_dataset_rejects_an_env_the_worker_cannot_load.