Repository navigation
[rl] Verifiers: a trace's status says who failed, and 400 means only a prompt too long (3/4) - #6183
Conversation
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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
- The PR description's "Summary (human-written)" is empty. The author needs to fill it in; agents don't.
torchtitan/rl/examples/verifiers/rollouter.py:380-- a failed trace (ok=False) that died on a 400 now becomes trainableTRUNCATED_PROMPT_TOO_LONGand storestrace.reward. If that reward can beNone,float(None)fails the whole group (unverified). Confirm the type, or don't store aNone. Details inline.
Should consider
torchtitan/rl/examples/verifiers/rollouter.py:265-- theTaskGroupcancels 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-stageTaskErrorrecorded on the trace or on the episode? If it's on the episode, this branch makes itERROR_INFRA, which doesn't train. That contradicts the rationale for trainingTaskError.
Details
- Gate: the problem is real on the base branch.
ERRORtrains, so aSandboxErroror a no-turn trace trained aterror_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 theERROR_UNKNOWNstatus and two docstrings. - The generation server's 400 vs 422 split is consistent.
json.JSONDecodeErroris aValueError, so a malformed body returns 422. The prompt-length check runs only after the body validates. log_failed_rolloutreadserror['type']anderror['message'].controller/metrics.pyalready relies on Verifiers'model_dumphavingtype, 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 leavesFIRST_PROMPT_TOO_LONGunchanged.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| # 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: |
There was a problem hiding this comment.
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.runcancels 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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
840d23a to
4fb042d
Compare
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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
- 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 becomesERROR_INFRAand doesn't train, which isn't what this PR intends. Details inline.
Details
- Gate: the problem is real on the base branch.
ERRORtrains, so aSandboxError, a 502, or a judge failure trained aterror_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_ERRORand_NOT_TRAINABLE) and two docstrings.controller/metrics.py:284-292loops overRolloutStatus, sostatus_rate/error_unknownneeds no other edit. No other in-repo producer of statuses needs updating (token_env.pyandrollouter.pyuse only existing values). - Ordering in
rollout_status:FIRST_PROMPT_TOO_LONGbefore the zero-turn check, then deadlines, then episode-only failure, then the later 400, then error type. A refused later call that ends in aHarnessErrorwithout status 400 falls through toERROR, which is a reasonable default. A failed trace whoselast_errorisNoneraisesAttributeError, which_run_single_rolloutcatches asERROR_INFRA, so it fails safe. - The no-turn override (
not turns and status.is_trainable()) only fires whennum_turns > 0, sincenum_turns == 0already returns an untrainable status. It keeps a 0.0 reward out of the group mean. except Exceptiondoesn't catchCancelledError, so theTaskGroupcancellation still works. Sessions aren't released whenrunitself 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(aValueError). 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 |
There was a problem hiding this comment.
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_INFRAinstead ofFIRST_PROMPT_TOO_LONG. It trains the same way, butstatus_rate/first_prompt_too_longmisses it. - an overlong later prompt becomes
ERROR_INFRAand doesn't train, where this PR means it to beTRUNCATED_PROMPT_TOO_LONGand 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.
There was a problem hiding this comment.
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.
- For a prompt without images, renderers checks its length against
max_model_lenfromGET /v1/models(this server sendsmax_rollout_tokens) and raisesOverlongPromptErrorbefore sending (renderers 0.1.12renderers/client.py:302-308; 0.2.0:569-575). A prompt with images skips this check and gets this server's 400. - Verifiers' train client re-raises it as
ProviderError(str(e), status_code=400)(Verifiers 0.4.0verifiers/v1/clients/train.py:458-461; 0.4.1:480-483). - The interception server records the call's error with
status_code=getattr(error, "status_code", None), so 400 (0.4.0verifiers/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.
b967e50 to
c9e93f5
Compare
c9e93f5 to
b88ec5a
Compare
e8ba39a to
9a2dbfe
Compare
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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-867uses the suggested wording. - The retried-attempt TODO at
rollouter.py:806-808wraps at the file's width. rollout_statusatrollouter.py:917-986has the same branch order, and itsfinish_reasonread matchesModelCall.finish_reason.generation_server.pyanswers 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
- 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.
9a2dbfe to
8d84545
Compare
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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
- 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_rolloutlogs each failure exactly once.make_scored_group(rollout/rollouter.py:388) scores onlyis_trainable()rollouts, soERROR_INFRAandERROR_UNKNOWNnever enter the group mean. ERROR_UNKNOWNis in bothis_error()and theis_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.
8d84545 to
117edf1
Compare
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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_groupcomment no longer says that a raise is a bug that cancels the siblings. The code is the sameTaskGroup+make_scored_groupflow asMessageEnvRolloutWorker.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-166filters tois_trainable()before the no-completion group drop, so anERROR_INFRArollout 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
- 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_rolloutis deleted, and nothing else imports it. The only callers left are the Verifiers worker and the native worker, and both call the sharedrollout/rollouter.py:287version. The recipes (verifiers_terminal_bench.py,verifiers_dapo_math.py) don't import it. log_failed_rolloutreturns early for statuses that aren't errors. So the unconditional call at the end of_run_single_rolloutlogs each failure exactly once.make_scored_groupscores onlyis_trainable()rollouts. SoERROR_INFRAandERROR_UNKNOWNnever enter the group mean.- A bug-path raise now surfaces as an
ExceptionGroupfrom theTaskGroup. 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.
117edf1 to
2784265
Compare
|
Reply from claude: @claude please review |
|
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 |
There was a problem hiding this comment.
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) andmake_scored_group(rollout/rollouter.py:402) still have the signatures this PR calls.make_scored_groupscores onlyis_trainable()rollouts. training_sample_builder.py:156still filters tois_trainable()before the no-completion group drop. So a no-turnERROR_INFRArollout is skipped and no longer drops its siblings.- Nothing else in
torchtitan/imports the deleted Verifiers-locallog_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
- 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.
2784265 to
2496ad6
Compare
…(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.  <!-- 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]>
2496ad6 to
661a22b
Compare
…a prompt too long
661a22b to
738444e
Compare
Summary (human-written)
Agent details
TLDR:
VerifiersRolloutWorkermaps each trace to who failed, by error type and status code, never by message text. It uses the native worker's mechanism:_run_single_rolloutalways returns aRolloutand logs a failure once, andmake_scored_groupscores only trainable rollouts.Problem
ERROR, and a trace with no turnERROR.ERRORtrains. Many of these failures aren't the policy's: aSandboxError, a 502, a sandbox that never started.ERROR(Results below).Solution
rollout_statusfollows the table. A new error type defaults to "not trained". Verifiers' token budgets stayTRUNCATED_LENGTH, like a completion that hitmax_tokens. Any other truncation, e.g.compaction_failed, is nowERROR_UNKNOWNand doesn't train.ERROR_INFRA, unless its status is already untrainable, with ano_trainable_tokenentry inRollout.logs["errors"]. So it never trains, and its 0.0 never enters the group mean._run_single_rolloutcatches intoERROR_INFRAand calls the genericlog_failed_rollout. Verifiers' own log helper is deleted.run_groupuses anasyncio.TaskGroupandmake_scored_group.BaseRolloutWorker.score_groupandrun_groupdocstrings no longer say where rewards and advantages are set.Results
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
HarnessErrorandTaskErrortrain? In an earlier 50-step Terminal-Bench run, 73 of 106 harness errors were the agent's ownpkill -fkilling its harness. ATaskErrorcan 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:
ERRORandERROR_TIMEOUTstill train aterror_reward(0.0 in both Verifiers recipes). To leave them out of training, add them to the tuple inRolloutStatus.is_trainable. A TODO aboveRolloutStatusmarks making this configurable.New W&B keys:
rollout/status_rate/error_unknown,rollout/errors/no_trainable_token.Follow up
HarnessError,TaskErrorand the deadlines. Blocked: Verifiers' error types say where a rollout broke, not who caused it.best_of_nenv (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_tokenchecks 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_idnow expects 422.pre-commitpasses.pyreflyskipstorchtitan/rlandtests(project-excludesinpyproject.toml), so it checks none of this PR's files.