Skip to content

[rl] Verifiers: a trace's status says who failed, and 400 means only a prompt too long (3/4) - #6183

Merged
felipemello1 merged 1 commit into
mainfrom
felipemello1/infra-errors/3-verifiers-status
Nov 23, 2026
Merged

felipemello1 merged 1 commit into
mainfrom
felipemello1/infra-errors/3-verifiers-status

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

TLDR: VerifiersRolloutWorker maps each trace to who failed, by error type and status code, never by message text. It uses the native worker's mechanism: _run_single_rollout always returns a Rollout and logs a failure once, and make_scored_group scores only trainable rollouts.

In a 20-step Terminal-Bench run of 17,504 rollouts, 100 SandboxError and 16 setup-timeout rollouts used to train as ERROR or drop their group and are now ERROR_INFRA and not trained, while 398 later prompts that were too long now train with their own reward and 167 HarnessError rollouts still train as ERROR.

Verifiers trace, checked in this order                   status                      trained
first model call got a 400 (prompt >= max_rollout_tokens) FIRST_PROMPT_TOO_LONG      no
no turn (e.g. the sandbox didn't start)                   ERROR_INFRA                no
a deadline passed (agent, finalize, scoring)              ERROR_TIMEOUT              yes, with error_reward
ok, but its episode failed (e.g. a judge's trace)         ERROR_INFRA                no
ended on a 400 on a later model call                      TRUNCATED_PROMPT_TOO_LONG  yes
failed, last error HarnessError or TaskError              ERROR                      yes, with error_reward
failed, any other error                                   ERROR_INFRA                no  (e.g. SandboxError, a 502)
ok                                                        COMPLETED                  yes
hit max_turns                                             TRUNCATED_MAX_TURNS        yes
a completion hit max_tokens, or a Verifiers token budget  TRUNCATED_LENGTH           yes
  (max_input_tokens, max_output_tokens, max_total_tokens)
truncated for another reason (e.g. compaction_failed)     ERROR_UNKNOWN              no
then: any trainable status above, but no trainable token  ERROR_INFRA                no

Problem

  1. The Verifiers worker marks any failed trace ERROR, and a trace with no turn ERROR.
  2. ERROR trains. Many of these failures aren't the policy's: a SandboxError, a 502, a sandbox that never started.
  3. It finds an overlong first prompt by matching "maximum context length" in an error message. And the generation server answers 400 to a missing header or a malformed body too, so a 400 can't mean "prompt too long".
  4. In a 20-step Terminal-Bench run, 116 of 17,504 rollouts (0.66%) failed outside the policy. Main marked each one ERROR (Results below).

Solution

  1. rollout_status follows the table. A new error type defaults to "not trained". Verifiers' token budgets stay TRUNCATED_LENGTH, like a completion that hit max_tokens. Any other truncation, e.g. compaction_failed, is now ERROR_UNKNOWN and doesn't train.
  2. A trace with model calls but no trainable token has no turn. It becomes ERROR_INFRA, unless its status is already untrainable, with a no_trainable_token entry in Rollout.logs["errors"]. So it never trains, and its 0.0 never enters the group mean.
  3. _run_single_rollout catches into ERROR_INFRA and calls the generic log_failed_rollout. Verifiers' own log helper is deleted. run_group uses an asyncio.TaskGroup and make_scored_group.
  4. The generation server answers 400 only for a prompt with no room for an output token. A missing header or a malformed body gets 422, so a config mistake can't look like a prompt that's too long.
  5. The BaseRolloutWorker.score_group and run_group docstrings no longer say where rewards and advantages are set.
  6. A rollout with no turn no longer drops its group: [rl] Rollouts that fail outside the policy are recorded, not trained (1/4) #6116 makes the builder skip untrainable rollouts before its group drop, and this PR makes the rollout untrainable.

Results

20-step Terminal-Bench run, Qwen3.5-27B, 17,504 rollouts, stop reasons from its logs:
  ERROR_INFRA:     100 SandboxError + 16 setup_timeout = 116 (0.66%)
  still train:     398 prompt too long (after a turn: TRUNCATED_PROMPT_TOO_LONG), 167 HarnessError (ERROR)

the 600 error rollouts the recorder kept, by turns:
  no turn:         17 SandboxError, 16 setup_timeout     (on main each was scored ERROR and its whole group was dropped)
  with turns:      368 prompt too long, 137 HarnessError, 62 SandboxError

Among the recorded error rollouts, no HarnessError or prompt-too-long one had zero turns, so the no-turn rule changed none of them.

You may ask: why do HarnessError and TaskError train? In an earlier 50-step Terminal-Bench run, 73 of 106 harness errors were the agent's own pkill -f killing its harness. A TaskError can mean the agent broke the box its grader runs in.
You may ask: why list the policy's errors, not the infra ones? A new Verifiers error type then defaults to "not trained".

NOTE: ERROR and ERROR_TIMEOUT still train at error_reward (0.0 in both Verifiers recipes). To leave them out of training, add them to the tuple in RolloutStatus.is_trainable. A TODO above RolloutStatus marks making this configurable.

New W&B keys: rollout/status_rate/error_unknown, rollout/errors/no_trainable_token.

Follow up

  • Tell policy-caused failures from infra ones inside HarnessError, TaskError and the deadlines. Blocked: Verifiers' error types say where a rollout broke, not who caused it.
  • Allow more than one trainable trace per episode, which happens in e.g. Verifiers' best_of_n env (n attempts per episode).

Test plan: both suites (Verifiers 0.4.0: 1045 passed, 1 skipped; without Verifiers: 961 passed, 7 skipped). New: test_rollout_status_says_who_failed (one case per table row; 23 cases), test_a_rollout_with_no_turn_never_trains_and_each_failure_is_logged (5 cases; no_trainable_token checks Solution 2 and its log entry), test_a_rollout_whose_verifiers_call_raises_is_error_infra_and_logged, test_a_rollout_that_raises_fails_its_group_after_its_siblings_stop, test_generation_server_answers_422_to_a_bad_request; test_generation_server_requires_group_id now expects 422.

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

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

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the items below before merging (two small checks, plus the empty human-written summary): review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve -- please address the items below before merging. The status mapping now uses error types and status codes instead of message text, and the worker now follows the native worker's contract. What's left is two small checks and the missing human summary. A maintainer still needs to review, because rollout/types.py and rollout/rollouter.py are core RL files.

What this PR does. VerifiersRolloutWorker.rollout_status now maps each trace to a status by error type, HTTP status code, and stop condition. Statuses for failures outside the policy no longer train. _run_single_rollout catches exceptions as ERROR_INFRA and logs them through the shared log_failed_rollout. run_group now uses a TaskGroup and make_scored_group, the same as MessageEnvRolloutWorker. The generation server returns 400 only for a prompt that leaves no room for an output token. Bad requests now get 422.

Example.

trace: one turn, then SandboxError        before: ERROR (trains at error_reward)  after: ERROR_INFRA (not trained)
trace: zero turns, sandbox never started  before: ERROR, group dropped            after: ERROR_INFRA (group still dropped until PR 4/4)
trace: later prompt refused with 400      before: ERROR                           after: TRUNCATED_PROMPT_TOO_LONG (trains, reward = trace.reward)
trace: stop_condition=compaction_failed   before: TRUNCATED_LENGTH                after: ERROR_UNKNOWN (not trained)
request missing X-Session-ID              before: 400                             after: 422

Must fix

  1. The PR description's "Summary (human-written)" is empty. The author needs to fill it in; agents don't.
  2. torchtitan/rl/examples/verifiers/rollouter.py:380 -- a failed trace (ok=False) that died on a 400 now becomes trainable TRUNCATED_PROMPT_TOO_LONG and stores trace.reward. If that reward can be None, float(None) fails the whole group (unverified). Confirm the type, or don't store a None. Details inline.

Should consider

  • torchtitan/rl/examples/verifiers/rollouter.py:265 -- the TaskGroup cancels only the local client. A sibling still running in the env server may keep generating after the group is released, which is the case the deleted comment guarded against. Confirm that cancellation reaches the server, or document the limit.

Questions

  • torchtitan/rl/examples/verifiers/rollouter.py:434 -- is a scoring-stage TaskError recorded on the trace or on the episode? If it's on the episode, this branch makes it ERROR_INFRA, which doesn't train. That contradicts the rationale for training TaskError.
Details
  • Gate: the problem is real on the base branch. ERROR trains, so a SandboxError or a no-turn trace trained at error_reward, and the first-prompt check matched on message text. Owning the mapping in the Verifiers worker is the right layer. Core changes are limited to the ERROR_UNKNOWN status and two docstrings.
  • The generation server's 400 vs 422 split is consistent. json.JSONDecodeError is a ValueError, so a malformed body returns 422. The prompt-length check runs only after the body validates.
  • log_failed_rollout reads error['type'] and error['message']. controller/metrics.py already relies on Verifiers' model_dump having type, so dropping the Verifiers-specific logger is safe.
  • The no-turn rule (not turns and status.is_trainable() -> ERROR_INFRA) keeps a 0.0 reward from rollouts with nothing to train out of the group mean, and it leaves FIRST_PROMPT_TOO_LONG unchanged.

Not verified: the Verifiers Trace and Error field semantics (reward on failed traces, num_turns, where scoring errors land, and whether run propagates cancellation), because the package source wasn't inspectable here.

# Rewards by the env, if any, are added to the last turn.
# The rollout will be scored later.
# TODO: provide better support to carry rewards per trace
turns[-1].env_rewards[VERIFIERS_REWARD_KEY] = trace.reward

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This path is new for a failed trace. Before this PR, any not trace.ok was ERROR, so it never got an env reward. Now rollout_status returns TRUNCATED_PROMPT_TOO_LONG for a trace with ok=False whose harness died on the 400 (line 438), so this line stores trace.reward for it. If Verifiers leaves reward as None on a trace that failed before scoring, RewardFromVerifiers calls float(None). That raises in score_group inside make_scored_group and fails the whole group, siblings included.

Unverified: I couldn't inspect the Verifiers Trace type here. Please confirm that trace.reward is always a float on a failed trace. If it isn't, decide explicitly what a refused-then-died trace scores. One option is to let it fall through to the 0.0 default by not storing a None. The later_prompt_too_long test case uses a SimpleNamespace trace with no reward, so this path isn't exercised end to end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reply from claude: It can't be None. In Verifiers 0.4.0, Trace.reward is a property, sum(r.value for r in self.rewards.values() if r is not None) (verifiers/v1/trace.py:473-474), so a trace whose scoring never ran has reward 0.0. That rollout trains at 0.0, like the other truncations. float(None) can't happen here.

Comment on lines +265 to +267
# Run the group's rollouts in the env server, all at once. Each catches its own failures, so
# a raise is a bug: the TaskGroup then cancels the siblings before raising.
async with asyncio.TaskGroup() as task_group:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The deleted code waited for every sibling before raising. Its comment explained why: "a sibling still generating would pin the group again, with nothing left to release it". For Verifiers, a sibling's generation runs in the env-server process. Cancelling the local VerifiersEnvClient.run await only stops the client coroutine. Unless the cancel reaches the server, the harness keeps calling the generation server with this group_id after the controller has released the group.

The new test (test_a_rollout_that_raises_fails_its_group_after_its_siblings_stop) replaces _run_single_rollout with a local coroutine, so it only checks the local side.

The impact is small now that _run_single_rollout catches Exception, since only a bug reaches this path. Still, please either:

  • confirm that VerifiersEnvClient.run cancels the remote rollout (unverified here), or
  • say in the comment that cancellation stops only the client, and that a raise can leave a remote sibling generating.

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: This only happens on the bug path. _run_single_rollout catches every Exception, so a raise past it is a bug, and the group fails anyway. In #6118 (later in this stack), each episode runs in the worker's own event loop, so there the cancel reaches the episode. Leaving it as is.

return RolloutStatus.ERROR_TIMEOUT
if not verifiers_episode.ok or not trace.ok:
return RolloutStatus.ERROR
if trace.ok and not verifiers_episode.ok:

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.

Question: does Verifiers record a scoring-stage TaskError on the trace or on the episode?

The description says TaskError trains because "the agent broke the box its grader runs in". If that error lands only in verifiers_episode.errors while trace.ok stays True, this branch makes it ERROR_INFRA, which doesn't train. That contradicts the stated rationale. If scoring errors are always on the trace, a one-line comment saying so would make the ordering easier to trust.

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: On the trace. Scoring runs inside boundary(TaskError, "scoring") (verifiers 0.4.0 v1/rollout.py:610), and Rollout.fail records the error "captured onto the trace" (v1/rollout.py:192-195). So trace.last_error.type == "TaskError", and rollout_status returns ERROR.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 840d23a to 4fb042d Compare November 18, 2026 17:07
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the items below before merging (the empty human-written summary, plus one question on where a 400 comes from): review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: Approve -- please address the items below before merging. The status mapping uses error types and status codes, and the worker follows the native worker's contract. The replies to the last review settle its points: Trace.reward is a sum, so it's never None; a scoring TaskError is recorded on the trace; and the cancel limit only matters on the bug path. What's left is the human-written summary and one question about where a 400 comes from. A maintainer still needs to review, because rollout/types.py and rollout/rollouter.py are core RL files.

What this PR does. VerifiersRolloutWorker.rollout_status maps each trace to a status by num_turns, deadline flags, the last call's HTTP status, the last error type, and the stop condition. Failures outside the policy (ERROR_INFRA) and truncations it can't map (new ERROR_UNKNOWN) don't train. _run_single_rollout returns a Rollout even when it fails: an exception ends it as ERROR_INFRA, and it is logged once through the shared log_failed_rollout. run_group uses a TaskGroup and make_scored_group. The generation server answers 400 only for a prompt with no room for an output token, and 422 for any other bad request.

Example.

trace                                             before                     after
one turn, then SandboxError                       ERROR (trains)             ERROR_INFRA (not trained)
zero turns, setup_timeout                         ERROR_TIMEOUT              ERROR_INFRA
later call refused with 400, harness dies         ERROR (error_reward)       TRUNCATED_PROMPT_TOO_LONG (trace.reward)
policy's trace ok, judge's trace failed           ERROR                      ERROR_INFRA
stop_condition=compaction_failed                  TRUNCATED_LENGTH           ERROR_UNKNOWN (not trained)
env server unreachable                            group raises               ERROR_INFRA, siblings still train
request missing X-Session-ID                      400                        422

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author fills it in; agents don't.

Questions

  • torchtitan/rl/examples/verifiers/rollouter.py:426 -- is the generation server's 400 the only way an overlong prompt reaches a trace, or can the Verifiers renderer refuse it client-side with no status code? If it can, an overlong later prompt becomes ERROR_INFRA and doesn't train, which isn't what this PR intends. Details inline.
Details
  • Gate: the problem is real on the base branch. ERROR trains, so a SandboxError, a 502, or a judge failure trained at error_reward, and the first-prompt check matched message text. The mapping belongs in the Verifiers worker. Core changes are one enum value (ERROR_UNKNOWN, also in _ERROR and _NOT_TRAINABLE) and two docstrings. controller/metrics.py:284-292 loops over RolloutStatus, so status_rate/error_unknown needs no other edit. No other in-repo producer of statuses needs updating (token_env.py and rollouter.py use only existing values).
  • Ordering in rollout_status: FIRST_PROMPT_TOO_LONG before the zero-turn check, then deadlines, then episode-only failure, then the later 400, then error type. A refused later call that ends in a HarnessError without status 400 falls through to ERROR, which is a reasonable default. A failed trace whose last_error is None raises AttributeError, which _run_single_rollout catches as ERROR_INFRA, so it fails safe.
  • The no-turn override (not turns and status.is_trainable()) only fires when num_turns > 0, since num_turns == 0 already returns an untrainable status. It keeps a 0.0 reward out of the group mean.
  • except Exception doesn't catch CancelledError, so the TaskGroup cancellation still works. Sessions aren't released when run itself raises, because their trace ids are unknown. That's the same as on the base branch, and the existing TODO covers it.
  • The generation server's 422 path covers json.JSONDecodeError (a ValueError). The length check runs only after the body validates, so a malformed body can't return 400.

Not verified: the Verifiers semantics of Trace.num_turns (assistant turns vs. model calls, including failed ones), and whether its renderer can fail an overlong prompt before sending it. The package source isn't in this checkout.

# TODO: an error type or a deadline says where a rollout broke, not who broke it, so some
# infra failures train, e.g. Harbor wraps a sandbox error in a TaskError.
last_call_error = trace.calls[-1].error if trace.calls else None
refused = last_call_error is not None and last_call_error.status_code == 400

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.

Question (unverified): is the generation server's 400 the only way a prompt that is too long reaches a trace?

The deleted comment said "vLLM, the renderer and the generation server all word it 'maximum context length'". The server also advertises max_model_len = max_rollout_tokens (generation_server.py:167). If the Verifiers renderer client checks the length itself and fails the call without sending it, call.error.status_code is presumably None, so:

  • an overlong first prompt becomes ERROR_INFRA instead of FIRST_PROMPT_TOO_LONG. It trains the same way, but status_rate/first_prompt_too_long misses it.
  • an overlong later prompt becomes ERROR_INFRA and doesn't train, where this PR means it to be TRUNCATED_PROMPT_TOO_LONG and train.

The test fixtures use the message "Prompt length (9) exceeds maximum context length (8).", which isn't the server's wording, but they set status_code=400 by hand. Please confirm that the 398 prompt-too-long rollouts in Results had status_code == 400 on the call. If the renderer can refuse client-side, map its error type here too.

@felipemello1 felipemello1 Nov 18, 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: Yes, the renderer client can refuse a prompt itself, but the call still records status 400, so rollout_status sees it the same way.

  1. For a prompt without images, renderers checks its length against max_model_len from GET /v1/models (this server sends max_rollout_tokens) and raises OverlongPromptError before sending (renderers 0.1.12 renderers/client.py:302-308; 0.2.0 :569-575). A prompt with images skips this check and gets this server's 400.
  2. Verifiers' train client re-raises it as ProviderError(str(e), status_code=400) (Verifiers 0.4.0 verifiers/v1/clients/train.py:458-461; 0.4.1 :480-483).
  3. The interception server records the call's error with status_code=getattr(error, "status_code", None), so 400 (0.4.0 verifiers/v1/interception/server.py:565; 0.4.1 :710).

So both refusals, the client's and this server's, reach rollout_status as status_code == 400. The test fixture's message, "Prompt length (9) exceeds maximum context length (8).", is the client's wording, so the tests cover that path.

On the 398: Results counts them from the run's logs, by the "maximum context length" message. Those logs don't keep status_code, so I can't show it per rollout. By the path above, both sources record 400. No code change.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch 2 times, most recently from b967e50 to c9e93f5 Compare November 18, 2026 20:05
@felipemello1
felipemello1 marked this pull request as ready for review November 18, 2026 20:05
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 18, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 18, 2026 20:06
@felipemello1
felipemello1 removed this pull request from stack #6185 November 18, 2026 20:42
@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from c9e93f5 to b88ec5a Compare November 18, 2026 20:43
@felipemello1
felipemello1 added this pull request to stack #6190 November 18, 2026 20:43
@felipemello1 felipemello1 changed the title [rl] Verifiers: a trace's status says who failed, and 400 means only a prompt too long (3/4) [rl] Verifiers: a trace's status says who failed, and 400 means only a prompt too long (3/3) Nov 18, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from e8ba39a to 9a2dbfe Compare November 19, 2026 02:00
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item below before merging (only the empty human-written summary is left; the squashed commit matches the approved state): 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 branch was squashed into one commit (9a2dbfe) after the last review, and its diff matches the approved state at e8ba39a. There is no new logic and no new problem. A maintainer still needs to review, because rollout/types.py and rollout/rollouter.py are core RL files.

What changed since the last review. Only the squash. I checked the parts the earlier reviews raised, and they are still as approved:

  • The no-turn comment at rollouter.py:866-867 uses the suggested wording.
  • The retried-attempt TODO at rollouter.py:806-808 wraps at the file's width.
  • rollout_status at rollouter.py:917-986 has the same branch order, and its finish_reason read matches ModelCall.finish_reason.
  • generation_server.py answers 422 for bad requests and 400 only for a prompt with no room for an output token.
  • The TODO above RolloutStatus (types.py:203) is there, as the description says.

Example.

trace                                       base                 this PR
one turn, then SandboxError                 ERROR (trains)       ERROR_INFRA (not trained)
later call refused with 400, harness dies   ERROR                TRUNCATED_PROMPT_TOO_LONG (trace.reward)
stop_condition=compaction_failed            TRUNCATED_LENGTH     ERROR_UNKNOWN (not trained)
env server unreachable                      group raises         ERROR_INFRA, siblings still train
request missing X-Session-ID                400                  422

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author has to fill it in; agents don't.

Not verified: that verifiers_episode.errors includes the errors of retried attempts, as the comment at rollouter.py:600 says. The Verifiers source isn't in this checkout.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 9a2dbfe to 8d84545 Compare November 19, 2026 02:10
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item below before merging (only the empty human-written summary is left; 8d84545 has no new problems): 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. I re-read the full diff at 8d84545 and found nothing new. The logic matches the state approved in the earlier reviews. The only open item is the empty human-written summary. A maintainer still needs to review, because rollout/types.py and rollout/rollouter.py are core RL files.

What this PR does. VerifiersRolloutWorker.rollout_status maps each trace to a status using num_turns, the deadline flags, the last call's HTTP status, the last error type, and the stop condition. Failures outside the policy (ERROR_INFRA) don't train. Neither do truncations it can't map (the new ERROR_UNKNOWN). _run_single_rollout always returns a Rollout, ends an exception as ERROR_INFRA, and logs each failure once through the shared log_failed_rollout. run_group uses a TaskGroup and make_scored_group. The generation server now answers 400 only for a prompt that leaves no room for an output token, and 422 for any other bad request.

Example.

trace                                       base                 this PR
one turn, then SandboxError                 ERROR (trains)       ERROR_INFRA (not trained)
later call refused with 400, harness dies   ERROR                TRUNCATED_PROMPT_TOO_LONG (trace.reward)
stop_condition=compaction_failed            TRUNCATED_LENGTH     ERROR_UNKNOWN (not trained)
env server unreachable                      group raises         ERROR_INFRA, siblings still train
request missing X-Session-ID                400                  422

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author has to fill it in; agents don't.
Details
  • Checked again at HEAD: log_failed_rollout(rollout) (rollout/rollouter.py:287) returns early for statuses that aren't errors, so the unconditional call at the end of _run_single_rollout logs each failure exactly once. make_scored_group (rollout/rollouter.py:388) scores only is_trainable() rollouts, so ERROR_INFRA and ERROR_UNKNOWN never enter the group mean.
  • ERROR_UNKNOWN is in both is_error() and the is_trainable() exclusion list.
  • The TODO about configurable statuses (types.py:203) already exists on the base branch, as the description says.
  • In the generation server, the length check runs only after the body validates, so a malformed body can't return 400.

Not verified: that verifiers_episode.errors includes the errors of retried attempts, as the comment at examples/verifiers/rollouter.py:600 says. The Verifiers source isn't in this checkout.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 8d84545 to 117edf1 Compare November 19, 2026 23:24
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item below before merging (only the empty human-written summary is left; the rebased 117edf1 has no new problems): 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. I re-read the full diff at 117edf1, which was rebased since 8d84545. I found no new problems, and the logic is unchanged from the approved state. The one open item is still the empty human-written summary. A maintainer still needs to review, because rollout/types.py and rollout/rollouter.py are core RL files.

What changed since the last review.

  • The rebase: the commit now sits on beda0a5. The PR diff and the local commit diff are the same size, 1102 lines each.
  • The run_group comment no longer says that a raise is a bug that cancels the siblings. The code is the same TaskGroup + make_scored_group flow as MessageEnvRolloutWorker.run_group (rollout/rollouter.py:522-546).
  • The description has a new claim: a no-turn rollout no longer drops its group. That is true at HEAD. training_sample_builder.py:158-166 filters to is_trainable() before the no-completion group drop, so an ERROR_INFRA rollout with no turns is skipped instead of dropping its siblings.

Example.

trace                                       base                       this PR
zero turns, SandboxError                    ERROR, whole group dropped ERROR_INFRA, skipped; siblings train
one turn, then SandboxError                 ERROR (trains)             ERROR_INFRA (not trained)
later call refused with 400, harness dies   ERROR                      TRUNCATED_PROMPT_TOO_LONG (trace.reward)
stop_condition=compaction_failed            TRUNCATED_LENGTH           ERROR_UNKNOWN (not trained)
request missing X-Session-ID                400                        422

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author has to fill it in; agents don't.
Details
  • I checked callsites. The Verifiers-local log_failed_rollout is deleted, and nothing else imports it. The only callers left are the Verifiers worker and the native worker, and both call the shared rollout/rollouter.py:287 version. The recipes (verifiers_terminal_bench.py, verifiers_dapo_math.py) don't import it.
  • log_failed_rollout returns early for statuses that aren't errors. So the unconditional call at the end of _run_single_rollout logs each failure exactly once.
  • make_scored_group scores only is_trainable() rollouts. So ERROR_INFRA and ERROR_UNKNOWN never enter the group mean.
  • A bug-path raise now surfaces as an ExceptionGroup from the TaskGroup. The native worker behaves the same way, and the updated test expects it.

Not verified: that verifiers_episode.errors includes retried attempts' errors, as the comment at examples/verifiers/rollouter.py:600 says. The Verifiers source isn't in this checkout.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 117edf1 to 2784265 Compare November 22, 2026 09:03
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve -- please address the item below before merging (only the empty human-written summary is left; the rebased 2784265 has no new problems): 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. 2784265 is a rebase of 117edf1 onto the new base 3cca432. The source diff has the same logic as the approved state, and I found no new problems. tianyu-l has approved as maintainer. The only open item is still the empty human-written summary.

What changed since the last review. Only the rebase. The PR diff is still 1102 lines across the same 5 files (+620/-212). I re-checked the parts that depend on the base:

  • The shared log_failed_rollout(rollout) (rollout/rollouter.py:301) and make_scored_group (rollout/rollouter.py:402) still have the signatures this PR calls. make_scored_group scores only is_trainable() rollouts.
  • training_sample_builder.py:156 still filters to is_trainable() before the no-completion group drop. So a no-turn ERROR_INFRA rollout is skipped and no longer drops its siblings.
  • Nothing else in torchtitan/ imports the deleted Verifiers-local log_failed_rollout, or depends on the generation server's old 400 for a bad request.

Example.

trace                                       base                       this PR
zero turns, SandboxError                    ERROR, whole group dropped ERROR_INFRA, skipped; siblings train
one turn, then SandboxError                 ERROR (trains)             ERROR_INFRA (not trained)
later call refused with 400, harness dies   ERROR                      TRUNCATED_PROMPT_TOO_LONG (trace.reward)
stop_condition=compaction_failed            TRUNCATED_LENGTH           ERROR_UNKNOWN (not trained)
request missing X-Session-ID                400                        422

Must fix

  1. The PR description's "Summary (human-written)" is still empty. The author has to fill it in; agents don't.

Not verified: I didn't run the test suite here. I also couldn't confirm that verifiers_episode.errors includes the errors of retried attempts, as the comment at examples/verifiers/rollouter.py:598 says, because the Verifiers source isn't in this checkout.

@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 2784265 to 2496ad6 Compare November 23, 2026 19:28
felipemello1 added a commit that referenced this pull request Nov 23, 2026
…(1/4) (#6116)

<!--
Reviewers need to be convinced, not just informed. Delete sections you
don't need.
Agents: follow .claude/skills/pr-description/SKILL.md. Never fill in the
Summary.
-->

## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
     this approach, and what you checked yourself. -->

## Agent details

**TLDR:** A rollout's status now says who failed, and only the policy's
failures train. In the native worker, a rollout that fails outside the
policy (`ERROR_INFRA`: an exception, or a completion the generator cut
short or returned empty) stays in its group, counted by metrics, with
its errors in `Rollout.logs`. It is never scored or trained. The rest of
the group trains, centered on its own mean. Such a rollout with no
completion token no longer drops its group. First of 4: TokenEnv's first
prompt, the Verifiers worker and the builder's per-rollout drops follow.

![In the unit test's group of 3 with rewards 1, 2 and 3, a rollout whose
generate call raises used to drop the whole group, and an aborted one
trained at reward 1, while in this PR it is ERROR_INFRA with no reward
or advantage and its siblings train at -0.5 and
+0.5.](https://raw.githubusercontent.com/felipemello1/pr_images/5d230b49cf231c68e4f4f821bd85b13ae9dfff3a/torchtitan/6116/rows.png)
<!-- pr-image drawn at 191455d -->

```python
# before: a raise in a rollout is ERROR (it trains), or it fails the whole group
# after: _run_single_rollout always returns a Rollout
try:
    ...  # run the rollout; the env (TokenEnv or Verifiers' trace) gives the status
except Exception as error:
    rollout = Rollout(..., status=RolloutStatus.ERROR_INFRA, logs={"errors": [error_entry(error)]})
log_failed_rollout(rollout)  # the one failure log
```

**Problem**
1. `MessageEnvRolloutWorker._run_single_rollout` marks any exception
`ERROR`. `TokenEnv` marks an aborted completion `ERROR_ABORT`.
2. `ERROR` reads as the policy's fault: the rubric scores it (or gives
it `error_reward`, if set), and it enters the group mean.
3. Many of those failures aren't the policy's: an unreachable generator,
a crashed env, a completion the generator aborted.
4. So the policy trains on infra failures. The Terminal-Bench numbers
are in the Verifiers PR (3/4).
5. `build_from_group` drops the whole group if any rollout has no
completion token. In a 20-step Terminal-Bench run, 33 of the 600 error
rollouts the recorder kept had no turn (17 `SandboxError`, 16 setup
timeouts). Each one dropped its whole group.

**Solution**
1. A status says who failed. `RolloutStatus.is_trainable()` is False for
`ERROR_INFRA`.
2. `_run_single_rollout` always returns a `Rollout`. An exception
becomes `ERROR_INFRA`, with its type, message and traceback in
`Rollout.logs["errors"]`. A failed rollout is logged once, by
`log_failed_rollout`.
3. `make_scored_group` only scores and centers the trainable rollouts.
`run_group` runs the rollouts in an `asyncio.TaskGroup`: a raise past
`_run_single_rollout` is a bug, and it cancels the siblings before the
group fails.
4. `TrainingSampleBuilder.build_from_group` skips a rollout whose status
doesn't train, then runs main's checks on the rest. A group of 2 or more
with fewer than 2 scored rollouts counts as zero-std, e.g. 3 of 4 are
`ERROR_INFRA` and the one left has advantage 0.
5. `TokenEnv`: a completion cut short (finish reason `abort` or `error`)
or with no tokens is `ERROR_INFRA`. Its failures go to
`TokenEnvOutput.errors`. Only the step deadline is `ERROR_TIMEOUT`.
`ERROR_ABORT` is deleted.
6. New metrics: `rollout/status_rate/<status>` for every terminal
status, and `rollout/errors/<type>` and `validation/errors/<type>` per
error in `Rollout.logs["errors"]`.
7. The builder's group drop (a sibling with no completion token) now
looks only at the trainable rollouts. The native worker marks a rollout
with no completion token `ERROR_INFRA` (item 5), so the builder skips
it, and its siblings train.
8. Builder metric names, `drop_zero_std_reward_groups` and the loss are
as on main. `rollout_reward/group_zero_std_frac` and the zero-std drop
read the rewards of the trainable rollouts. The per-rollout drops and
their metrics are in the builder PR (4/4).
9. Unchanged: in the native worker, a group where no rollout raises and
no completion is cut short trains as on main. The Verifiers worker never
returns `ERROR_INFRA` before the Verifiers PR (3/4), so the builder sees
all its rollouts, as on main: a rollout with no turn still drops its
group. It only gains the metrics of item 6.

You may ask: why set the status in `_run_single_rollout`, not in
`make_scored_group`? One place sets a rollout's status and logs its
failure. Scoring only reads statuses.
You may ask: can users add a status? Not yet: a `StrEnum` with members
can't be subclassed. A TODO sits above `RolloutStatus`.
You may ask: why not reweight a group that lost rollouts? The loss is a
token mean, so a prompt already weighs its share of the batch's trained
tokens, which changes every step with completion length. A group that
trains 10 of its 16 rollouts weighs like a group with shorter
completions.

NOTE: validation now leaves untrainable rollouts out of
`validation_reward`.
NOTE: a tool call in the history can make `TokenEnv`'s full re-render
raise. That rollout is `ERROR_INFRA`, though the policy caused it. It's
a renderer bug on main; a TODO marks it.
NOTE: a reward function that raises (e.g. a judge that is down) still
fails its whole group. A TODO in `make_scored_group` marks it.
NOTE: until the Verifiers PR (3/4), the Verifiers worker keeps its own
`log_failed_rollout` and its main behavior.
NOTE: Lands with #6182 and #6183: until #6183, a Verifiers rollout with
no turn still drops its group, as on main. Until #6182, a native rollout
whose first prompt doesn't fit is still scored as
`TRUNCATED_PROMPT_TOO_LONG`.
NOTE: `ERROR` and `ERROR_TIMEOUT` still train: the rubric scores them,
or gives them `error_reward` if set (0.0 in every recipe that sets it).
To leave them out of training, add them to the tuple in
`RolloutStatus.is_trainable`. A TODO above `RolloutStatus` marks making
this configurable.

**Follow up** (each one is a TODO in the code)
- [ ] Let users add a status without editing `rollout/types.py`.
- [ ] Make the set of trainable statuses a config field, e.g. to leave
`ERROR` and `ERROR_TIMEOUT` out of training.
- [ ] Catch a raising reward function per rollout, so its siblings still
train.
- [ ] Run an ordered list of group postprocessors in
`make_scored_group`, e.g. a length penalty; the advantage estimator and
the group filters become some of them.
- [ ] Make `Rollout.reward` per token, e.g. to give each turn of a
multi-turn rollout its own reward.
- [ ] Convert `parsed.tool_calls` to the dicts `Message.tool_calls`
holds, so the full re-render doesn't raise.
- [ ] Typed errors (`RolloutError`) in their own `errors` field on
`Rollout` and `TokenEnvOutput`, next to a free-form `logs`.

**Test plan**
```bash
pytest -rs tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config
# Verifiers 0.4.0: 1016 passed, 1 skipped (test_train_loop.py, skipped on the base too).
# Without Verifiers: 959 passed, 7 skipped (the Verifiers test files and recipes).
```
`pre-commit` passes. `pyrefly` skips `torchtitan/rl` and `tests`
(`project-excludes` in `pyproject.toml`), so it checks none of this PR's
files.
New tests, each failing without its change:
-
`test_a_failed_rollout_is_kept_logged_once_and_left_out_of_the_advantage`
(generate call raises, aborted generation)
-
`test_a_response_that_fails_to_parse_is_error_parse_unless_the_generator_cut_it_short`
- `test_only_the_step_deadline_is_error_timeout`
-
`test_build_from_group_skips_an_unscored_rollout_but_trains_its_siblings`
(`ERROR_INFRA` with no turn, and after a turn)
- `test_build_from_group_drops_a_group_left_with_one_scored_rollout`
(`num_groups_dropped_zero_std`)
- `test_compute_rollout_metrics_records_a_rate_per_status`
- `test_compute_rollout_metrics_counts_each_error_type`

Co-authored-by: Felipe Mello <[email protected]>
@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 2496ad6 to 661a22b Compare November 23, 2026 19:34
Base automatically changed from felipemello1/infra-errors/2-first-prompt-too-long to main November 23, 2026 19:35
@felipemello1
felipemello1 force-pushed the felipemello1/infra-errors/3-verifiers-status branch from 661a22b to 738444e Compare November 23, 2026 19:35
@felipemello1
felipemello1 merged commit 56a07ca into main Nov 23, 2026
27 of 28 checks passed
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.

2 participants