Skip to content

[rl] Run Verifiers groups in rollout workers - #5511

Merged
felipemello1 merged 4 commits into
mainfrom
felipemello1/http/6-verifiers-groups-in-workers
Nov 15, 2026
Merged

felipemello1 merged 4 commits into
mainfrom
felipemello1/http/6-verifiers-groups-in-workers

Conversation

@felipemello1

@felipemello1 felipemello1 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

TLDR: Verifiers groups now run in rollout worker processes, like native groups. Each worker runs its own GenerationServer, so the controller no longer serves every Verifiers model call or decodes every trace: it receives finished groups only. The rollouts are the same: on CPU, every training field of 16 rollouts matches the in-controller path below this PR (Results). Its base, the BaseRolloutWorker split, is on main.

The per-rollout work of a Verifiers group (send the task, serve model calls, get the trace, score) moves from the controller into one rollout worker.

Before: the controller runs every Verifiers group.

sequenceDiagram
    participant C as controller process<br/>VerifiersRollouter, GenerationServer, trace decode
    participant E as env server<br/>runs the agent loop
    participant R as router
    participant G as generators
    C->>E: 1. task, once per rollout (msgpack, ZMQ)
    Note over E: chat to token ids
    E->>C: 2. each model call: token ids (JSON, HTTP)
    C->>R: 3. reserve a generator (Monarch)
    C->>G: 4. token ids (pickle, Monarch)
    G-->>C: reply
    C-->>E: completion
    E->>C: 5. trace + reward (msgpack, ZMQ)
    Note over C: trace to turns, advantages
Loading

After: rollout workers run them, like native groups. W = worker_pool_size.

sequenceDiagram
    participant C as controller process<br/>VerifiersRollouter: sends groups only
    participant W as rollout worker x W<br/>VerifiersRolloutWorker + its own GenerationServer
    participant E as env server<br/>runs the agent loop
    participant R as router
    participant G as generators
    C->>W: 1. group (pickle, Monarch)
    W->>E: 2. task, once per rollout (msgpack, ZMQ)
    Note over E: chat to token ids
    E->>W: 3. each model call: token ids (JSON, HTTP on loopback)
    W->>R: 4. reserve a generator (Monarch)
    W->>G: 5. token ids (pickle, Monarch)
    G-->>W: reply
    W-->>E: completion
    E->>W: 6. trace + reward (msgpack, ZMQ)
    Note over W: trace to turns, advantages
    W->>C: 7. finished group (pickle, Monarch)
Loading

Stack (15 PRs, bottom first; merging a PR also merges every PR below it; this PR in bold)

# PR What
1 Run Verifiers groups in rollout workers Verifiers groups run in rollout workers; the env server stays
2 Rollouts that fail outside the policy are recorded, not trained a failed rollout no longer drops its group
3 Rollouter: least-loaded placement; the controller sizes the pool from rollouts_per_worker least-loaded placement; the pool size follows the rollouts in flight
4 Rollout workers get generate_fn and release_session_fn once, at setup; the rollouter closes each worker before it stops them generator functions at setup; workers close before they stop
5 Verifiers: each example is an installed package; its name is the taskset id taskset ids are package names
6 Verifiers: each rollout worker runs its Verifiers envs; the env server is gone the env runs in the worker (Verifiers 0.4.0)
7 Verifiers: the generation server keeps one session per trace sessions; 1 GiB requests; the renderer refuses overlong prompts
8 Verifiers 0.4.1 and renderers 0.2.0 both pins move
9 Verifiers: only a rollout that Verifiers finished cleanly trains the failure rule
10 Verifiers README: terms, concurrency and sandboxes README only: terms, concurrency, sandboxes
11 Verifiers: time each rollout's sandbox start, setup, agent, model, finalize and scoring per-phase time metrics
12 Terminal-Bench: terminal_bench_env_config takes the package that exports the taskset a package argument for launchers outside the repo
13 Spread rollout workers over the job's hosts opt-in: rollout workers on the other hosts
14 Terminal-Bench: run each task in its image's WORKDIR and grade with task.toml timeouts Terminal-Bench task fixes
15 Rollout workers, the router and the controller report their CPU and memory each step per-role CPU and memory metrics

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".

Since the approval (second commit; the first is the approved change, rebased on main)

  • One diagram of one group in the Verifiers README, one column per process, a blank row between steps; the Terminal-Bench README links to it and keeps its agent and grading.
  • How many processes: 4 workers and a pool of 8 add 4 + 1 + 8 to the controller, not 4 x 8.
  • GenerationServer: a call diagram, one line per error status, an example request and reply, and labels for its 4 blocks.
  • The rollouter's docstrings say what TitanRL and Verifiers each provide, and point to the README.
  • "Add an experiment": the files a task needs and the recipe module to run (--module torchtitan_recipes.rl.verifiers_my_task).
  • A TODO at VerifiersTaskSample for lazily deserialized task data, a reviewer's follow-up.

Problem

  1. Native groups run in workers. The controller sends each native group to one of worker_pool_size rollout worker processes, which runs it and returns a scored group.
  2. Verifiers groups run in the controller. VerifiersRollouter.run_group_rollouts runs the env client, the trace decode and the conversion to rollout turns in the controller process.
  3. The controller also serves every model call. Verifiers' agents call one GenerationServer (aiohttp) in the controller, which parses each request and sends it to a generator that the router picks.
  4. Cost. All of that shares the controller's event loop with training and weight sync. Not measured at this head. An older measurement on main (Verifiers 0.3.1, before the generation server's faster request path, Verifiers DAPO-Math at ~62 model calls/s on 8 x H100): the controller used 22.6 CPU-seconds per training step (38.6% of one core).

Solution

  1. VerifiersRolloutWorker(BaseRolloutWorker) (the base class on main) runs one group per run_group call: the env client, a GenerationServer on loopback for its agents, the trace decode, scoring and advantages. The env server and the workers both run on the controller host. Each server binds a free port. GenerationServer.Config.port is gone: a fixed port would collide across workers.
  2. The Verifiers worker settings move to the worker's config, as for native rollouts: worker=VerifiersRolloutWorker.Config(rubric=..., generation_server=..., connection_timeout_sec=...). The two recipes change only that. The Verifiers README draws one group, one column per process ("Integration flow"), and the docstrings point to it. The architecture SVG is deleted.
  3. VerifiersRollouter starts the env server, then spawns the workers and passes its address to each worker's constructor: VerifiersRolloutWorker(config, *, env_server_address), through Rollouter.setup_async(worker_kwargs=...). close stops the workers first, then the env server. Why: Rollouter.close waits for each running group, and a group waits for its runs' results from the env server (untimed in Verifiers 0.4.0). A stopped env server never sends them, so each group would wait out the 30 s drain.
  4. Groups go through the stock Rollouter.run_group_rollouts, like native groups: VerifiersRollouter no longer overrides it.
  5. A Verifiers rollout that raises (e.g. "Verifiers expects one trainable trace") still fails its whole group, as on main (rollout/group_failures). The worker raises only after every sibling finished, as main's rollouter did. The next PR turns it into an ERROR_INFRA rollout, so its siblings train.
  6. Unchanged: the env server, the generation server's protocol and metadata, and the trace conversion.

Results

CPU, at the approved head f42b3130e (the same change, rebased on main since; not re-run): Verifiers DAPO-Math recipe (Verifiers 0.4.0), real env server, 4 groups x 4 rollouts
(6 of 16 answers right, one group all wrong). Only the generator is fake: its answer depends on the group
and the rollout's seed. Reference: VerifiersRollouter below this PR, which runs the groups in the controller.
                                        rollouts  turns  training fields equal to the reference
below this PR (groups in the controller)  16       16    (reference)
this PR, 2 workers in one process         16       16    all
this PR, 2 worker processes (Monarch)     16       16    all (each process ran at least one group)
Training fields: status, reward, advantage, token ids, logprobs, policy versions, messages, env rewards,
metrics. Only Rollout.logs differs: the Verifiers trace id and the wall-clock timings.

The GPU run ran at an older head of this PR (44c5edb, 11-10), with "Cancel a rollout group on its worker"
below it and the env server stopped first. Not re-run at this head.

GPU, rl_dapo_qwen3_4b_verifiers_8k cut to 10 steps on 4 GB300 GPUs (trainer TP 2, 2 generators), Qwen3-4B-Base
  10 of 10 steps; 0 rollout errors (99.6% completed, 0.4% truncated at the length cap)
  step-0 validation scored all 30 prompts, 0 group failures

You may ask:

  • Why one GenerationServer per worker, not one shared server? A shared server would stay in the controller, which this PR empties. Each worker keeps the policy versions and metrics of the calls it served, so they reach the controller inside the finished group.
  • Why a constructor arg, not a config field? The env server's address exists only after it starts, so no user sets it. build(**kwargs) is how a runtime value reaches a constructor. The worker is built in its own process, so the value goes down the spawn path (Rollouter.setup_async(worker_kwargs=...) -> spawn_rollout_workers(**kwargs) -> RolloutWorkerActor -> build(**kwargs)), as the trainer's and batcher's constructor args do. It is temporary: PR 6 runs the env in the rollout worker (still on Verifiers 0.4.0) and removes worker_kwargs, env_server_address and connection_timeout_sec.
  • Why loopback? The env server and the workers both run on the controller host. A worker on another host would need a routable address.
  • Does the env server now build W times the renderers? No. Verifiers shares renderers per process, keyed by the renderer model and config, not by base_url.

NOTE:

  • The generator path is the native one, over Monarch: the worker reserves a generator from the router, then calls that generator. The Verifiers README's diagram draws that path.
  • At the end of training, a running Verifiers group now ends like a native one: the controller's cancel doesn't reach its worker. With validate_after_training, the group overlaps that validation. Its model calls fail once Controller.close closes the generators. A rollout that is grading, or in a long tool call, needs no generator, so its group can outlast the 30 s drain. Rollouter.close then logs "the job may exit 130": a false alarm there, since no generator owes that group an answer. On main the cancel stopped the group in the controller.
  • A model call that Verifiers gives up on (e.g. at the Terminal-Bench recipe's 7200 s rollout timeout) is still answered later, at the latest when the generators close. run_group returns without waiting for that answer, and cancelling the worker's GenerationServer handler wouldn't stop it. If the answer reaches a worker that already stopped, Monarch fails the generator and the job exits 130 (TODO(monarch) in generation_server.py, Monarch issue 5301). Before this PR this path ran in the controller process, which outlives the generators. The handler isn't cancelled, so the call keeps its router reservation until the generator answers.
  • worker_pool_size defaults to 4 for Verifiers too (it was a no-op before). At high rollout rates, raise it next to the env server's pool.

Open for the maintainer:

  • The worker_kwargs path, the env_server_address constructor arg and connection_timeout_sec are temporary: PR 6 removes them. This PR can land first; they stay until PR 6 lands.
  • This PR changes 4 core files only for the temporary worker_kwargs path: rollout/rollouter.py, actors/system.py, actors/monarch/system.py, actors/monarch/rollout_worker.py. The BaseRolloutWorker split is on main.
  • A reviewer suggested lazy deserialization: bundle the passthrough fields that ride with each group into an object that is deserialized only when read. It is a follow-up, not in this stack.

Test plan

pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config
# Verifiers 0.4.0, on main: 954 passed, 1 skipped
  • test_setup_spawns_workers_with_the_env_server_address_and_close_stops_the_workers_first.
  • test_a_failing_rollout_fails_its_group_only_after_every_sibling_finished: main's test, now on VerifiersRolloutWorker.
  • test_verifiers_worker_sends_muse_glimmer_renderer_config: the agents' base_url is the worker's own server.
  • The rollout, status and trace tests now run on VerifiersRolloutWorker (_run_single_rollout).
  • The CPU check in Results ran from a local script, in one process and with 2 Monarch worker processes (not in CI).

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 18, 2026
@felipemello1
felipemello1 added this pull request to stack #5513 October 18, 2026 23:32
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from ee23f54 to 740beed Compare October 19, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from 740beed to c81435b Compare October 19, 2026 01:16
@felipemello1 felipemello1 changed the title [rl] Run Verifiers groups in rollout workers [rl] Run Verifiers groups in rollout workers (12/14) Oct 19, 2026
@pzhan9

pzhan9 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

A general comment:

A theme in this stack is on how to manage the the serialization cost. We should look into the lazy deserialization pattern, so we can bundle passthrough fields into a lazy object, and only deserialize them when we have to.

Monarch already has zero-copy optimization on pickling bytes, and potentially could do more. So this is a area we could make it quite optimal.

@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from c81435b to bb79416 Compare October 23, 2026 07:34
@felipemello1

Copy link
Copy Markdown
Contributor Author

reply from claude: agreed, worth a follow-up. The token payload is already cheap here: the torchtitan response format sends raw int32 ids and float64 logprobs, with no per-token JSON objects. So the next win is the rollout fields the controller only forwards to the batcher. I'm leaving it out of this stack to keep it reviewable.

@felipemello1
felipemello1 removed this pull request from stack #5513 October 27, 2026 14:27
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from bb79416 to 67abd3e Compare October 27, 2026 14:32
@felipemello1 felipemello1 changed the title [rl] Run Verifiers groups in rollout workers (12/14) [rl] Run Verifiers groups in rollout workers (13/14) Oct 27, 2026
@felipemello1
felipemello1 added this pull request to stack #5639 October 27, 2026 14:33
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from 67abd3e to e77d87d Compare November 5, 2026 00:38
@felipemello1
felipemello1 removed this pull request from stack #5639 November 5, 2026 07:53
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from 5669e3b to 4bfb9e3 Compare November 5, 2026 07:53
@felipemello1
felipemello1 changed the base branch from felipemello1/http/4-cancel-group to felipemello1/http/7-native-rollout-timeout November 5, 2026 07:54
@felipemello1
felipemello1 added this pull request to stack #5857 November 5, 2026 07:54
@felipemello1 felipemello1 changed the title [rl] Run Verifiers groups in rollout workers (13/14) [rl] Run Verifiers groups in rollout workers (10/10) Nov 5, 2026
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude review. This PR was rewritten: Verifiers groups now run in rollout workers without the HTTP generation PRs, so the code and the body changed.

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the items before merging (empty human-written summary; a fixed generation_server.port collides across workers): 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. Verifiers groups now go through the stock worker pool, which removes the controller-side generation server, the env client and the special cases in Rollouter. The two remaining items are small, local edits. A maintainer still needs to review, because the PR touches torchtitan/rl/rollout/rollouter.py.

What this PR does. It splits VerifiersRollouter in two. VerifiersRolloutWorker(RolloutWorker) runs in each pool process and owns:

  • the env client
  • a loopback GenerationServer
  • the trace decode, scoring and advantages

VerifiersRollouter now only starts the env server, spawns the workers with the env server's address, and stops the env server before the workers drain. Groups go through Rollouter.run_group_rollouts, so cancel_group and the shutdown drain apply to them. In the recipes, rubric, generation_server and connection_timeout_sec move under worker=VerifiersRolloutWorker.Config(...).

Example.

before: controller: VerifiersRollouter.run_group_rollouts
          -> env client -> env server -> HTTP -> controller GenerationServer -> router
after:  controller: Rollouter.run_group_rollouts -> run_group.choose(...) on worker k
          worker k: env client -> env server -> HTTP 127.0.0.1:<port_k> -> worker k GenerationServer
          -> tracked generate_fn -> router; worker k returns a scored RolloutGroup
close:  env server stopped -> Rollouter.close drains run_group and generate calls -> workers stopped

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.
  2. torchtitan/rl/examples/verifiers/rollouter.py:494: every worker binds its own GenerationServer from one config. A non-zero generation_server.port with worker_pool_size > 1 (now 4 by default) fails at setup with EADDRINUSE. Either delete the unused port field, or raise in __post_init__ (see the inline comment).

Should consider

  • torchtitan/rl/rollout/rollouter.py:170: the new worker_config parameter on the shared setup_async has a single consumer. The subclass can build the replaced config before it calls super(), which keeps the core diff at zero (see the inline comment).
  • assets/images/rl_verifiers_integration_architecture.svg: the box is renamed to VerifiersRolloutWorker, but its "start" arrow to the EnvServer stays. The controller-side VerifiersRollouter starts the env server now, and the diagram has no controller box for it.

Questions

  • The description says cancel_group "stops Verifiers groups too". Cancelling VerifiersEnvClient.run stops the worker-side task. Does it also stop the episode in the env server? If not, a cancelled episode keeps making model calls to that worker's GenerationServer. Those calls go through whatever generate_fn was set last (the TODO at L196 covers the metrics prefix). They also leave entries in generation_metadata that nothing pops. The base branch behaves the same way, but the claim should say which of these happens.
  • With W workers, the env server now receives W TrainClientConfigs that differ only in base_url. Does Verifiers key its renderer pool by client config? If so, the env server builds W times as many renderers, each with its own tokenizer, as before.

Not verified: the questions above, because I couldn't inspect the Verifiers package source here. I also couldn't confirm that the env server's renderer and process pool behave the same under four clients as under one.


def __post_init__(self) -> None:
Rollouter.Config.__post_init__(self)
if self.worker.env_server_address is not None:

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.

Every rollout worker now builds its own GenerationServer from the same worker.generation_server config. So a non-zero GenerationServer.Config.port with worker_pool_size > 1 (now 4 by default) makes the second worker fail TCPSite bind with EADDRINUSE during setup_async, after the env server and the worker processes are already up. Before this PR, a fixed port worked because the controller ran a single server.

No in-repo caller sets port. The smallest fix is to delete port from GenerationServer.Config and always bind port 0, since each worker needs its own ephemeral port anyway. If you'd rather keep the field, reject the combination here:

            if self.worker.generation_server.port != 0 and self.worker_pool_size > 1:
                raise ValueError(
                    "worker.generation_server.port must be 0 when worker_pool_size > 1: "
                    "each rollout worker binds its own generation server"
                )

Comment thread torchtitan/rl/rollout/rollouter.py Outdated
tokenizer_config: HuggingFaceTokenizer.Config,
renderer_config: RendererConfig,
hf_assets_path: str,
worker_config: RolloutWorker.Config | None = None,

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.

(should consider) This adds a parameter to the shared Rollouter.setup_async that only VerifiersRollouter passes. Principle 4 asks us not to add hooks to shared code for one consumer, and the class docstring's "Customization" section doesn't mention the new parameter. The subclass can do the same thing without any core change, by building the replaced config before it calls super():

# VerifiersRollouter.setup_async
env_server_address = await self._verifiers_env_server.start()
self._config = replace(
    self._config,
    worker=replace(self._config.worker, env_server_address=env_server_address),
)
await super().setup_async(actor_system=..., tokenizer_config=..., renderer_config=..., hf_assets_path=...)

This builds a new config and doesn't mutate the original. It does rebind a base attribute, which is the trade-off the PR description mentions. Since the core diff then drops to zero, a maintainer should decide which version they prefer.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude:

  • Port: GenerationServer.Config.port is gone. Every server binds port 0 (b7e9ed6). No caller set it.
  • setup_async(worker_config=...): kept. Rebinding self._config patches a built config at runtime, and self._verifiers_config would still hold the old one. The Customization docstring now names the keyword.
  • SVG: the "start" label is on the EnvServer -> agent arrow inside the EnvServer box. The worker's arrow to the EnvServer is the ZMQ "run episode" link, which is right. The controller isn't drawn, so the README now says VerifiersRollouter starts the env server from the controller, before it spawns the workers.
  • Cancel: yes, best effort. Verifiers 0.4.0's client sends a cancel for each cancelled run. The pool routes it to the worker that holds the run, and that worker cancels it, also while it is queued. A model call already in flight finishes, and its metadata stays in the worker's GenerationServer until the worker stops. Both are in the body now.
  • Renderers: no. Verifiers shares renderers per process, keyed by (renderer model, renderer config, chat_template_kwargs). base_url is not in the key.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: An update on "against main": the refactor PR and this one now sit on a draft copy of your look-aside router PR, rebased onto main ("[DO NOT REVIEW] Look-aside generator routing"), so the whole stack runs on look-aside. They depend on nothing else in the stack. When your PR lands, the stack rebases onto main and the copy closes; nothing in this stack should merge before that.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push puts the stack on a draft copy of the look-aside router PR, rebased onto main (row 0, DO NOT REVIEW; it closes when the original lands). The generate answer now comes from the generator, so the docs and bodies say so; each body says not to merge while row 0 is under the stack.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item before merging (the human-written summary is still empty; the docs and SVG match the look-aside path at d9bb1eb): 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 item below before merging. The docs, the SVG and the class docstring now draw the look-aside path that is in the base: the worker reserves a generator from the router, then calls that generator. I found no new code problems at d9bb1eb. A maintainer still needs to review, because the PR touches torchtitan/rl/rollout/rollouter.py. Per the body, nothing in the stack should merge while the row-0 copy is under it.

What this PR does. VerifiersRolloutWorker(BaseRolloutWorker) runs one Verifiers group per run_group call inside a rollout worker process. Each worker has its own env client, its own loopback GenerationServer on port 0, and does the trace decode and scoring itself. VerifiersRollouter starts the env server, spawns the workers with Rollouter.setup_async(worker_config=replace(worker, env_server_address=addr)), and on close stops the workers first and the env server last.

Example. One model call at this head, checked against the code:

agent -> env server -> HTTP 127.0.0.1:<port_k> -> worker k GenerationServer._handle_generate_request
  -> generate_fn (Controller._make_generate_fn, shipped to worker k)
       generator = router.reserve(request_id, routing_session_id)   # Monarch, worker k -> router
       generator.generate(prompt, ...)                              # Monarch, worker k -> generator
       router.release_reservation(request_id)
  -> Completion back to the agent
SVG: router box "InterGeneratorRouter.reserve", label "reserve / generator handle";
     the blue request/Completion path now runs from GenerateFn to the Generator actors.

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.

Should consider

  • torchtitan/rl/examples/verifiers/rollouter.py:217 -- the look-aside TODO says "when look-aside routing lands, re-check", but generate_fn already calls the reserved generator directly at this head (inline comment).

Still open from earlier reviews

  • rollout/rollouter.py:173-175: setup_async(worker_config=...) is a temporary core parameter with one consumer. Its TODO says PR 7 removes it. A maintainer should confirm they accept it.
Details
  • generation_server.py:209-212 TODO(monarch): this is consistent with look-aside. The generator's answer now returns to the calling worker actor, not to the router. So a worker that has stopped is the one the late answer fails on.
  • The controller's TODO at controller/controller.py:676-678 ("nothing cancels a generate call") still holds with this PR. When Verifiers gives up on a call, the handler isn't cancelled, so the reservation stays until the generator answers. The PR body says the same.
  • VerifiersRolloutWorker's docstring diagram (generate_fn --> a generator (the router picks it)), the Terminal-Bench README step 4, and the Verifiers README step 4 all match _make_generate_fn.

Not verified: the GPU path at this head. The body's GPU run is from an older head.

Comment on lines +217 to +221
# TODO: when look-aside routing lands (https://github.com/pytorch/torchtitan/pull/5990),
# re-check this bridge: `generate_fn` then calls the reserved generator directly, so the
# bridge is one loopback hop. Dropping it needs an HTTP endpoint on each generator, a
# reserve per model call from Verifiers' client, and another home for the policy versions
# recorded here.

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.

(should consider) This TODO is conditional on something that is already true at this head. The stack now sits on look-aside routing, and Controller._make_generate_fn (controller/controller.py:679-689) already reserves a generator and calls it directly. So the "re-check" can happen now, and once PR 5990 lands on main and the stack rebases, nothing will prompt anyone to come back to "when ... lands". You could state the current state and keep only the open part:

Suggested change
# TODO: when look-aside routing lands (https://github.com/pytorch/torchtitan/pull/5990),
# re-check this bridge: `generate_fn` then calls the reserved generator directly, so the
# bridge is one loopback hop. Dropping it needs an HTTP endpoint on each generator, a
# reserve per model call from Verifiers' client, and another home for the policy versions
# recorded here.
# TODO: drop this loopback bridge. `generate_fn` already calls the reserved generator
# directly (look-aside routing); dropping the bridge needs an HTTP endpoint on each
# generator, a reserve per model call from Verifiers' client, and another home for the
# policy versions recorded here.

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 029993d.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push applies your TODO wording at examples/verifiers/rollouter.py (inline reply); nothing else in this PR changed.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 43s —— View job


Approve -- please address the item before merging (the human-written summary is still empty; the look-aside TODO at 029993d is now accurate): 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 item below before merging. At 029993d, the look-aside TODO now describes how the code works today, and this push changes nothing else. A maintainer still needs to review, because the PR touches torchtitan/rl/rollout/rollouter.py. The body says nothing in the stack should merge while the row-0 copy sits under it.

What this PR does. Each Verifiers group now runs inside a rollout worker process, in VerifiersRolloutWorker(BaseRolloutWorker). Each worker has its own env client and its own loopback GenerationServer on port 0, and it decodes and scores its traces itself. VerifiersRollouter starts the env server, then spawns the workers with the server's address through Rollouter.setup_async(worker_config=...). On close it stops the workers first and the env server last.

Example. The TODO at examples/verifiers/rollouter.py:217-220, before and after this push:

before: "when look-aside routing lands (#5990), re-check this bridge: generate_fn then calls the
         reserved generator directly ..."   -> conditional on something already true at this head
after:  "drop this loopback bridge. generate_fn already calls the reserved generator directly
         (look-aside routing); dropping the bridge needs an HTTP endpoint on each generator, a
         reserve per model call from Verifiers' client, and another home for the policy versions"

This matches the earlier suggestion word for word. It also matches Controller._make_generate_fn, which does reserve, then generator.generate, then release.

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.

Still open from earlier reviews

  • rollout/rollouter.py:173-175: setup_async(worker_config=...) is a temporary core parameter with one consumer. Its TODO says PR 7 removes it. A maintainer should confirm they accept it.

Not verified: the GPU path at this head. The GPU run in the body is from an older head.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. The bottom PR renamed the stock RolloutWorker to MessageEnvRolloutWorker (no alias) and cut three docstrings. This PR only takes the new name; nothing else changed.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 40s —— View job


Approve -- please address the item before merging (the human-written summary is still empty; the MessageEnvRolloutWorker rename is complete at ddd4639): 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 item below before merging. At ddd4639 this PR picks up the bottom PR's rename of RolloutWorker to MessageEnvRolloutWorker, and I found no new problems. A maintainer still needs to review, because the PR touches torchtitan/rl/rollout/rollouter.py.

What this PR does. Each Verifiers group runs in a rollout worker process, in VerifiersRolloutWorker(BaseRolloutWorker). Each worker has its own env client and its own loopback GenerationServer on port 0, and it decodes and scores its own traces. VerifiersRollouter starts the env server, then spawns the workers through Rollouter.setup_async(worker_config=replace(worker, env_server_address=addr)). On close, it stops the workers first and the env server last.

Example. How the rename lands at this head:

base (6a): class MessageEnvRolloutWorker(BaseRolloutWorker)   # stock worker, no alias
this PR:   examples/verifiers/rollouter.py imports BaseRolloutWorker, Rollouter
             (was MessageEnvRolloutWorker, used only by the deleted `worker: ... | None = None` field)
           torchtitan/rl/README.md: "Subclass `MessageEnvRolloutWorker` or `Rollouter` ...;
             a worker whose env isn't a `MessageEnv` subclasses `BaseRolloutWorker`"
repo-wide: no bare `RolloutWorker` identifier is left in any .py, .md or .svg
           (the remaining matches are VerifiersRolloutWorker, BaseRolloutWorker, RolloutWorkerActor)

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.

Still open from earlier reviews

  • rollout/rollouter.py:173-175: setup_async(worker_config=...) is a temporary core parameter with one consumer. Its TODO says PR 7 removes it. A maintainer should confirm they accept it.

Not verified: the GPU path at this head. The GPU run in the body is from an older head.

@felipemello1

Copy link
Copy Markdown
Contributor Author

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 VerifiersRollouter docstring and the two Verifiers READMEs; the old SVG is deleted), and the 3 newest main commits. No behavior change from the passes.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item before merging (the human-written summary is still empty; the reordered stack and the doc rewrite at 26c5466 match the code): 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 item below before merging. At 26c5466, after the reorder and the three passes, the code matches the last reviewed behavior, the rewritten docs match the code, and I found no new problems. A maintainer still needs to review, because the PR touches torchtitan/rl/rollout/rollouter.py. The body says nothing in the stack merges while the row-0 look-aside copy is under it.

What this PR does. Each Verifiers group runs in a rollout worker process, in VerifiersRolloutWorker(BaseRolloutWorker). Each worker has:

  • its own env client
  • its own loopback GenerationServer on port 0
  • the trace decode, scoring and advantages

VerifiersRollouter starts the env server, then spawns the workers through Rollouter.setup_async(worker_config=replace(worker, env_server_address=addr)). On close, it stops the workers first and the env server last. A rollout that raises still fails its whole group, as on the base branch.

Example. The recipe change, and one model call at this head:

recipe: VerifiersRollouter.Config(..., rubric=R, generation_server=G, connection_timeout_sec=T)
     -> VerifiersRollouter.Config(..., worker=VerifiersRolloutWorker.Config(rubric=R, generation_server=G,
                                                                         connection_timeout_sec=T))
call:   agent -> env server -> HTTP 127.0.0.1:<port_k> -> worker k GenerationServer
        -> generate_fn (Controller._make_generate_fn): router.reserve -> generator.generate -> release
close:  Rollouter.close (wait up to _RUN_GROUP_DRAIN_TIMEOUT_S, stop_rollout_workers) -> finally env server closed

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.

Still open from earlier reviews

  • rollout/rollouter.py:170-172: setup_async(worker_config=...) is a temporary core parameter with one consumer. Its TODO says it goes once the Verifiers env runs in the worker, which is PR 5 in the new order. A maintainer should confirm they accept it.
Details
  • The docs rewrite checks out against the code. The VerifiersRollouter docstring diagram, Verifiers README steps 1-4 and Terminal-Bench README steps 1, 4 and 6 all say the worker sends tasks, serves model calls through router.reserve and then generate, and returns finished groups. _ENV_SERVER_WORKERS = 16 (verifiers_terminal_bench.py:84) matches "16 for TB" and "The Terminal-Bench recipe runs 16". The pool knob the README names, verifiers_env_server.serve.pool, is what both recipes set.
  • The SVG is deleted, and nothing in the repo still references rl_verifiers_integration_architecture. No other file builds VerifiersRollouter.Config with the old top-level rubric/generation_server/connection_timeout_sec fields. The two recipes and three test files are the only callers, and all of them are updated.
  • Added lines are ASCII only.
  • test_setup_spawns_workers_with_the_env_server_address_and_close_stops_the_workers_first guards the start -> spawn -> stop workers -> close env server order. Nothing else checks that order.

Not verified: the GPU path at this head. The body's GPU run is from an older head.

or `DockerConfig`. With a pool, its pool workers run them. The Terminal-Bench recipe runs 16.
The server and each of its pool workers first run [`worker_setup.py`](./worker_setup.py). Every
worker imports that module, so it must not import torch.
3. `rollouter.py` runs each group in a rollout worker process (`VerifiersRolloutWorker`), like

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.

nit: missing a link on rollouter.py
It's just not consistent -- removing all the links is fine, too

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 in 4907466: linked it.

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: The new README links every file it names.

Comment on lines +23 to +41
| |
| 4. generate | 7. batch
+-------|-------- controller process (torchtitan.rl.train) ---|----------+
| GenerationServer dataset -> VerifiersRollouter -> batcher |
| (localhost HTTP) | ^ |
+-------^---------------------------------|------|-----------------------+
| 4. token ids 1. task | | 6. trace, reward
+-------|---------------------------------v------|-----------------------+
| +-- controller process (torchtitan.rl.train) ---|----------+
| | dataset -> VerifiersRollouter -> batcher |
| +---------------|-----------------^------------------------+
| | |
| group v | finished group
+-------|------- rollout worker processes (VerifiersRolloutWorker) ------+
| GenerationServer send tasks, convert traces, score the group |
| (localhost HTTP) | ^ |
+-------^-------------------------------|------|-------------------------+
| | |
| 4. token ids 1. task | | 6. trace, reward
+-------|-------------------------------v------|-------------------------+
| Verifiers env server (spawned process) |
| per rollout: interception server (chat messages <-> token ids) |
| and a Docker runtime |
+-------^---------------------------------|------------------------------+
| |

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.

It's a bit hard to read. I wonder if we could do either of

  • use more width
  • switch to real picture

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 in 4907466: redrew it as a sequence diagram, your "use more width" option. Each column is one kind of process, or the containers, and each row is one of the numbered steps below it (96 columns). PR 5 redraws it the same way for the env in the rollout worker. If you'd still rather have a rendered picture, I can make it a mermaid sequenceDiagram.

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: Redrawn once more, in the Verifiers README: one column per process, numbered steps, a blank row between steps. It's the only diagram now.


def __init__(self, config: Config) -> None:
super().__init__(config)
self._verifiers_config = config

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.

VerifiersRollouter's config is called _verifiers_config

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 in 4907466: deleted. With the address as a constructor arg, nothing reads it.

@felipemello1 felipemello1 Nov 15, 2026 •

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: Still self._config in this PR.

Edited after the restack: the first version described a later PR's code.


def __init__(self, config: Config) -> None:
super().__init__(config)
self._verifiers_config = config

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.

and VerifiersRolloutWorker's config is again called _verifiers_config

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 in 4907466: renamed to self._config. BaseRolloutWorker stores no config, so it shadows nothing.

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: Still self._config.

Comment on lines +168 to +170
worker_config=replace(
self._verifiers_config.worker, env_server_address=env_server_address
),

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.

nah this is not right -- I think you want to make env_server_address an arg to the constructor of verifiers rollout worker, rather than a field in the config

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 in 4907466: VerifiersRolloutWorker(config, *, env_server_address). The worker is built in its own process, so the address goes down the spawn path (Rollouter.setup_async(worker_kwargs=...) -> spawn_rollout_workers(**kwargs) -> RolloutWorkerActor -> build(**kwargs)), as the trainer's and batcher's constructor args do. It replaces setup_async(worker_config=...) and touches 4 core files (+22/-4). PR 5 (Verifiers 0.4.1, bd22d90) deletes all of it with the env server.

@felipemello1 felipemello1 Nov 15, 2026 •

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: It stays a constructor argument here, as you asked: VerifiersRolloutWorker(config, *, env_server_address), passed through Rollouter.setup_async(worker_kwargs=...). A TODO in rollout/rollouter.py names its removal. "Verifiers: each rollout worker runs its Verifiers envs; the env server is gone" deletes the env server, this argument and worker_kwargs from the 4 core files.

Edited after the restack: the first version described a later PR's code.

@felipemello1

Copy link
Copy Markdown
Contributor Author

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. This push also answers the 5 review threads: env_server_address is now a constructor arg of VerifiersRolloutWorker, both configs are self._config, rollouter.py is linked, and the Terminal-Bench diagram is redrawn as lanes.

@claude

claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item before merging (the human-written summary is still empty; all 5 of @tianyu-l's threads are addressed at 4907466, and he still needs to re-review): 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 item below before merging. At 4907466, all 5 of @tianyu-l's threads are addressed in code, and the new worker_kwargs path through core is correct. I found no new problems. @tianyu-l's review still says changes requested, so he needs to re-review, and a maintainer has to sign off on the 4 core files anyway.

What this PR does. Each Verifiers group now runs in a rollout worker process, in VerifiersRolloutWorker(BaseRolloutWorker). Each worker has its own env client and its own loopback GenerationServer on port 0, and it decodes and scores its own traces. VerifiersRollouter starts the env server, then spawns the workers, giving each one the server's address as a constructor argument. On close it stops the workers first and the env server last.

Example. How the env server address reaches each worker at this head:

VerifiersRollouter.setup_async
  addr = await env_server.start()
  Rollouter.setup_async(..., worker_kwargs={"env_server_address": addr})
    -> actor_system.spawn_rollout_workers(worker_config, num_workers=W, num_threads=T, env_server_address=addr)
    -> MonarchActorSystem: RolloutWorkerActor(worker_config=..., worker_kwargs={"env_server_address": addr}, ...)
    -> worker_config.build(env_server_address=addr)  # Configurable.build checks for overlap with config fields
    -> VerifiersRolloutWorker(config, *, env_server_address=addr)
native recipes: worker_kwargs=None -> {} -> build() -> MessageEnvRolloutWorker(config)   (unchanged)

Must fix

  1. The "Summary (human-written)" section is empty. The author needs to fill it in; agents leave the placeholder.

Maintainer threads, at HEAD

  • examples/verifiers/README.md: the missing rollouter.py link is added.
  • terminal_bench/README.md: the diagram is redrawn as lanes, 96 columns wide (the "more width" option). @tianyu-l should confirm it reads better now.
  • VerifiersRollouter._verifiers_config: deleted. __init__ reads config directly, and the base self._config covers the rest.
  • VerifiersRolloutWorker._verifiers_config: renamed to self._config. BaseRolloutWorker stores no config, so this shadows nothing.
  • env_server_address as a constructor arg: done. The config field and its "leave unset" docstring are gone, and rg env_server_address finds no stale references.

Should consider

  • rollout/rollouter.py:87-96: the Customization docstring doesn't mention worker_kwargs. The comment on the parameter (L170-172) is its only documentation. That is fine for a temporary path; this is a nit.
Details
  • Core diff (+22/-4): Rollouter.setup_async(worker_kwargs=...), ActorSystem.spawn_rollout_workers(**kwargs), MonarchActorSystem and RolloutWorkerActor(worker_kwargs=...). The Monarch system is the only ActorSystem implementation, so no other subclass needs the new **kwargs. spawn_rollout_workers(**kwargs) matches the existing spawn_batcher(config, **kwargs) pattern. The TODO at rollouter.py:171-172 names every piece to delete once the env runs in the worker.
  • Configurable.Config.build(**kwargs) (config/configurable.py:144-169) raises when a kwarg overlaps a config field. That guards the field -> arg move.
  • test_setup_spawns_workers_with_the_env_server_address_and_close_stops_the_workers_first now asserts the address arrives as a spawn kwarg. It still guards the start -> spawn -> stop workers -> close env server order. The test_rollouter_pool.py edits only add worker_kwargs={}.
  • The Terminal-Bench lanes match the code. Row 4 draws the worker calling the generators directly (look-aside), and row 6 draws the scored group going from the worker to the controller.

Not verified: I couldn't run the unit tests here, and the GPU path wasn't re-run at this head (the body's GPU run is from an older head).

@felipemello1 felipemello1 left a comment •

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.

Can you please add better comments, docstrings, but non verbose to verifiers/rollouter.py. Follow the coding style skill.

Comment on lines +22 to +33
controller rollout worker env server container generators trainer
(CPU) (CPU, xN) (Verifiers) (per rollout) (GPU) (GPU)
| | | | | |
1 |--group---------->|--task--------->| | | |
2 | | |--start-------->| | |
3 | | |<-chat request--| | |
4 | |<-token ids-----| | | |
| |--generate--------------------------------------->| |
5 | | |--run test.sh-->| | |
6 |<-scored group----|<-trace, reward-| | | |
7 |--batch, packed by the batcher process-------------------------------------------->|
| | | | |<-new weights|

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.

it seems that this is explaining the integration with verifiers, and would be true for most of verifiers integration. It should probably be in the verifiers readme, and here we should point there. Other than that, it looks good.

@felipemello1 felipemello1 Nov 15, 2026 •

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: Moved. The integration is explained once, in the Verifiers README ("Integration flow"). The Terminal-Bench README keeps its agent and its grading and links there.

Edited after the restack: the first version described a later PR's code.

Comment on lines +39 to +42
2. **Agent.** One of the env server's pool workers (`verifiers_env_server.serve.pool`)
starts a container from the task's `docker_image` and runs Terminus-2 in it
([`harness.py`](./harness.py)). The agent types commands into a tmux shell and reads
the screen back.

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.

can we make it clear that the docker part is just a place holder for people to use their sandbox provider of choice, and maybe point to the doc in verifiers readme on how to replace it? (we have some internal example with sandoq. We might have some documentation on daytona as well). I am ok with these readme changes go in a new PR, or are adressed in future prs, e.g. on the pr updating distributed rolloutworkers or the verifiers 4.1. I would rather review this only once. It could be at the end of the stack as well.

@felipemello1 felipemello1 Nov 15, 2026 •

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 once, near the end of the stack: "Verifiers README: terms, concurrency and sandboxes" adds the "Sandboxes" section. It says Docker is a placeholder, and that a remote sandbox provider plugs in as a Verifiers custom runtime (new in Verifiers 0.4.1). It also covers the model path back, retries, run-wide limits and cleanup. No later PR edits that section.

Edited after the restack: the first version described a later PR's code.

rollout worker.
2. [`env_server.py`](./env_server.py) runs the Verifiers env server as a local process on the
controller host. The server runs the agents in the configured runtime, e.g. `SubprocessConfig`
or `DockerConfig`. With a pool, its pool workers run them. The Terminal-Bench recipe runs 16.

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.

we shouldn't mention terminal bench here. This is about verifiers, not other examples. Let terminal bench worry about terminal bench. Also, this is config specific. You cannot just say that it runs 16.

@felipemello1 felipemello1 Nov 15, 2026 •

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: the Verifiers README names no config value that differs between the examples. It still links the two examples as places to start: in its intro and at the end of "Add an experiment", which also copies the DAPO recipe. "Verifiers README: terms, concurrency and sandboxes" adds an env table and the "Concurrency" rules later, with formulas and Verifiers' defaults.

Edited after the restack: the first version described a later PR's code.

controller host. The server runs the agents in the configured runtime, e.g. `SubprocessConfig`
or `DockerConfig`. With a pool, its pool workers run them. The Terminal-Bench recipe runs 16.
The server and each of its pool workers first run [`worker_setup.py`](./worker_setup.py). Every
worker imports that module, so it must not import torch.

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.

" so it must not import torch." you should clarify what you mean by that, i.e. importing torch takes a lot of memory. You cannot expect people to just understand why. Make the reason explicit.

@felipemello1 felipemello1 Nov 15, 2026 •

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: The README now says why: "importing torch costs each process about 0.5 GB of memory (peak RSS after import torch)". Measured: 522 MB on torch 2.16 nightly. The rule applies to the env server and its pool workers. "Verifiers: each example is an installed package; its name is the taskset id" deletes worker_setup.py, and the rule goes with it.

Edited after the restack: the first version described a later PR's code.

Comment on lines +34 to +35
HTTP, from the env server). For each call it gets a generator from `router.reserve`, then calls
`generate` on it. Each rollout worker runs its own, on localhost. The server also records what

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.

"then calls generate on it" in your diagram in terminal bench, you say that the rollout worker calls generate. Is it the worker or generation server? is there a contradiction?

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: There was a contradiction. Now there is one diagram: the worker's GenerationServer calls generate_fn (step 6), and nothing else does.

4. `rollouter.py` sends samples to Verifiers and converts the
returned trace graph into TitanRL `RolloutTurn` objects. TitanRL then applies
its rubric and advantage estimator normally.
A diagram of one group: the `VerifiersRollouter` docstring in [`rollouter.py`](./rollouter.py).

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.

i dont like that we point there. I think i would rather have it here, and have the .py point to the readme. I also think that the terminal bench is better than the rollouter.py one. Lets try to make a single one that is the best of both worlds. Its fine if we need 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. The diagram is in the Verifiers README, and rollouter.py points to it.

Comment on lines +86 to +88
rollout worker k (CPU process, controller host): VerifiersRolloutWorker.run_group
| env client: 8 x run(task), ZMQ --> Verifiers env server (controller host:
| 1 process, plus a worker pool if any: 16 for TB)

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.

this is confusing. So we have K rollout workers. But for each, we also have 16 worker pool for verifiers env server? So its K * 16?

@felipemello1 felipemello1 Nov 15, 2026 •

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: No: the rollout workers share one env server. 4 workers and a pool of 8 add 4 + 1 + 8 processes to the controller, not 4 x 8, as the README says under the diagram. "Verifiers: each rollout worker runs its Verifiers envs; the env server is gone" removes the env server and its pool: then each worker runs its envs itself.

Edited after the restack: the first version described a later PR's code.

connection_timeout_sec: float = 120.0
"""Maximum time to wait for the Verifiers server to become healthy."""

def __post_init__(self) -> None:

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.

please, for this .py file, follow the skill coding style, and add small comments on major blocks of code. e.g.

for

if configured_taskset not in (
                VerifiersTasksetConfig(),
                self.training_dataloader.dataset.verifiers_taskset,
            ):

we could add a small 1 liner above it saying "check if taskset is registered in verifiers", or something like this (not verbatim).

@felipemello1 felipemello1 Nov 15, 2026 •

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 with the code-style skill: block labels in run_group and __post_init__, and the docstrings rewritten. Blocks that aren't obvious have a one-line comment.

Edited after the restack: the first version described a later PR's code.

Comment on lines +191 to +196
renderer_multiplex: int = 256
"""Maximum concurrent rollouts sharing one Verifiers renderer instance.

TODO: evaluate sharing this renderer pool with TitanRL's native rollout
path instead of keeping it specific to the Verifiers client.
"""

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.

can we open a new PR addressing this. Locally we also have another discussion regarding cpu threads. You can search the outcome of that research. Maybe we can have some heuristic in the controller, allow the user to override, but pick decent numbers for this based on buffer size, number of cpus available, etc?

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: That PR is "Rollouter: least-loaded placement; the controller sizes the pool from rollouts_per_worker". The controller computes the worker count from training rollouts in flight and rollouts_per_worker, once, before any process starts.

Comment on lines +242 to +246
await self._generation_server.start()
self._verifiers_env_client = VerifiersEnvClient(self._env_server_address)
await self._verifiers_env_client.wait_for_server_startup(
timeout=self._config.connection_timeout_sec
)

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.

lets open a PR adding some structured logger to functions here in the rollouter, so we can have a good understanding about timing, etc. We can avoid small functions that are called disproportionally many times compared to others, so it doesnt clog the logs.

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 "Verifiers: time each rollout's sandbox start, setup, agent, model, finalize and scoring". It reports where each rollout's time went, from Verifiers' trace timing: verifiers/{boot,setup,agent,model,finalize,scoring}_time_s, mean and max per step, for every rollout, including those that failed before their first turn. Metrics, not a span per rollout: Verifiers already times each phase on the trace, so a span would repeat those numbers. A trace span times each env start.

@felipemello1

felipemello1 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Reply from claude: answers to the comments on this PR that have no inline thread.

felipemello1 (comment): Can you please add better comments, docstrings, but non verbose to verifiers/rollouter.py. Follow the coding style skill.

Done; see the reply on the rollouter.py line 114 thread.

pzhan9 (comment): We should look into the lazy deserialization pattern, so we can bundle passthrough fields into a lazy object, and only deserialize them when we have to.

Agreed, as a follow-up outside this stack. A TODO now marks it at VerifiersTaskSample: "send the task's fields as one lazily deserialized object, e.g. JSON bytes, decoded only where the task runs." The controller and a checkpoint of pending samples would then copy bytes, not a nested dict. Not done yet: no one has measured that cost, and it changes how every sample crosses to the worker.

pzhan9 (comment): Can we split this PR into 2 commits ... In addition, this PR should be created against the main branch.

Done: the split is on main.

the review bot (comment): setup_async(worker_config=...) is a temporary core parameter with one consumer ... A maintainer should confirm they accept it.

Still here, as worker_kwargs, with a TODO in rollout/rollouter.py. "Verifiers: each rollout worker runs its Verifiers envs; the env server is gone" removes it with the env server.

Edited after the restack: the first version described a later PR's code.

@felipemello1

felipemello1 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Reply from claude: Reopened as the bottom of the Verifiers stack. Its first commit is the change tianyu-l approved, rebased on main; the second addresses the review comments. "Verifiers: each rollout worker runs its Verifiers envs; the env server is gone" later moves the env into the worker and deletes the env server.

Edited after the restack: this comment first said the PR closes.

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

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests 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.

3 participants