Skip to content

[rl] Verifiers: the generation server keeps one session per trace - #6106

Draft
felipemello1 wants to merge 1 commit into
felipemello1/verifiers-v2/2-verifiers-0.4.1from
felipemello1/verifiers-v2/2b-generation-sessions
Draft

felipemello1 wants to merge 1 commit into
felipemello1/verifiers-v2/2-verifiers-0.4.1from
felipemello1/verifiers-v2/2b-generation-sessions

Conversation

@felipemello1

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

TLDR: The Verifiers generation server keeps one session per trace: opened when Verifiers starts the trace, closed only after the trace's model calls return. It accepts prompts up to 1 GiB of JSON, and Verifiers' renderer, not the server, refuses a prompt with no room for an output token.

before:  each request carries its group id in sampling_params; the worker pops what the server kept, then releases
after:   open_session(trace id, group id) -> model calls -> close_session waits for calls in flight -> release

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

Problem

  1. The worker tags each request with its group id through an extra sampling param, and pops what the server recorded for a trace after the rollout.
  2. An agent past its deadline hangs up, but aiohttp doesn't cancel the handler. Its generate_fn call still runs, and the worker could release its routing session first (the TODO the previous PR left).
  3. aiohttp's 1 MiB default refuses a prompt past about 150K tokens (7 bytes of JSON per 6-digit token id).
  4. The server parses each request itself and answers an overlong prompt with vLLM's wording, so the worker matches an error string.

Solution

  1. GenerationServer.open_session(trace_id, group_id=...) runs for each trace Verifiers starts. close_session refuses further calls, waits for the calls in flight, and returns the trace's policy-version range and generator metrics.
  2. Request bodies up to 1 GiB, Verifiers' own limit for its interception server.
  3. /v1/models advertises max_model_len = max_rollout_tokens - 1. Verifiers' renderer refuses a longer prompt before sending it, as a ProviderError with status 400.
  4. _sampling_config refuses a param the generator can't apply, e.g. an env's repetition_penalty, another top_k or min_p, or top-k logprobs. Any failure answers 500.
  5. VerifiersRolloutWorker.Config.max_rollout_tokens replaces generation_server=GenerationServer.Config(...).
  6. The README gets "What crosses each hop": what each call carries, what grows with a rollout, and the size limits.
  7. Unchanged: the reply format (logprobs.content, what renderers 0.1.12 reads), the trace converter, the statuses.

NOTE: not run on GPUs, on Verifiers 0.4.0. Merge it with PRs 6, 8 and 9, after the Terminal-Bench run at PR 9's head.

NOTE: the RDMA TODO in RolloutWorkerActor.run_group comes with this PR's size limits: once a group's per-token arrays pass about 3 GiB, the group reply should carry RDMA handles.

TODOs in this PR: per-token policy versions; generators serve this endpoint; a faster JSON parser; only new tokens to the generator; score centering's top-k; usage; other top_k, min_p or top-k logprobs (raise early); check an env's agent sampling keys when the env loads; router replay rows, with rdma_min_tensor_bytes in its recipes; rollout-side RDMA handles.

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: 969 passed, 1 skipped

New: test_generation_server_serves_generate_fn_per_session (two calls, one prompt over 1 MiB; the reply read as renderers 0.1.12 reads it), test_generation_server_answers_500_without_a_usable_completion, test_closing_a_session_waits_for_its_call_in_flight, test_renderer_refuses_a_prompt_with_no_room_for_an_output_token, test_sampling_config_takes_only_what_the_generator_honors.

@felipemello1
felipemello1 added this pull request to stack #6109 November 15, 2026 21:44
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 15, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-v2/2-verifiers-0.4.1 branch from fe14957 to f242c05 Compare November 15, 2026 23:40
@felipemello1
felipemello1 force-pushed the felipemello1/verifiers-v2/2b-generation-sessions branch from da8849e to 58d7f7c Compare November 15, 2026 23:40
@felipemello1
felipemello1 removed this pull request from stack #6109 November 16, 2026 06:52

This branch has not been deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant