Repository navigation
[rl] Verifiers: only a rollout that Verifiers finished cleanly trains - #5986
felipemello1 wants to merge 1 commit into
Conversation
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 3m 17s —— View job Verdict: Approve -- please address the items before merging (review). |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. Classifying failures from Verifiers' typed Error fields and the rollout's phase replaces matching on message text and is the right layer. What's left is local: the summary, the order of two status checks, and the description. A maintainer still needs to review, since rollout/types.py is core.
What this PR does. VerifiersRolloutWorker.rollout_status now sets a failed rollout's status from Verifiers' error records:
- If the last model call was a
ProviderErrorwith status 400, the prompt was past the context. - A generator, interception or tunnel error is
ERROR_INFRAat any turn. - Any failure before the first turn is
ERROR_INFRA. - After the first turn, sandbox, tool and task failures stay
ERROR(the policy's).
The generation server keeps 400 for context overflow only and returns 422 for every other bad request. A trace that Verifiers dropped gets reward None.
Example.
before after
sandbox never booted (0 turns) ERROR, no tokens -> group ERROR_INFRA, siblings train
dropped
generator 503 at turn 3 ERROR, trained with reward 0 ERROR_INFRA, not trained
SandboxError at turn 3 ERROR, trained ERROR (unchanged)
harness dies on an overlong prompt ERROR, reward 0 TRUNCATED_PROMPT_TOO_LONG,
at turn 5 reward = trace.reward
judge gives a drop verdict trained with trace.reward reward None, not trained
Must fix
- The PR description has no "Summary (human-written)". The section is empty; the author needs to fill it in.
rollouter.py:420-427-- the generator and no-turn checks run beforeis_timeout. If a call cut off at a deadline is recorded as aProviderError, a timed-out rollout becomesERROR_INFRAand escapes the timeout penalty. Please confirm which error type Verifiers 0.4.1 records there, then either reorder the checks or add a test row that pins the intended status (see inline comment).
Should consider
rollouter.py:277-294-- classify a dropped trace asERROR_INFRAinrollout_status. Training comes out the same, and it removes both thescore_groupoverride that readsRollout.logsand the core docstring change attypes.py:321.rollouter.py:372-376-- say in the description that overflow after a turn now trains differently. It used to beERRORwith reward 0; it now trains withtrace.rewardortruncation_reward. That is a numerics change, and the description says truncation is "unchanged".rollouter.py:338-- therelease_groupscomment rewrite is unrelated to this PR's concern.
Details
- The problem is real on the base branch. Every failed trace became
ERROR, andERRORwith no tokens drops the whole group inTrainingSampleBuilder. Overflow was found by searching for "maximum context length" in the error message. - Training outcome of each status.
make_scored_groupleavesERROR_INFRArollouts out of scoring and centering. A reward of None fromscore_groupalso keeps a rollout out of centering. So whether a dropped trace isERROR_INFRAor has reward None, its siblings train the same way. logs["dropped"]can't raiseKeyError.score_grouponly sees rollouts built by_run_verifiers_rollout; the syntheticERROR_INFRArollouts for siblings that raised are filtered out before it.- The metric meaning moves, but the keys don't.
rollout_rewardandvalidation_rewardalready average only scored rollouts (controller/metrics.py:279). This PR doesn't change that code; it just leaves more Verifiers rollouts unscored. - New tests. They are cheap CPU tests. The real-
WireTracetest guards that the Verifiers schema still has thenum_turns,last_erroranddroppedfields this code reads.
Not verified: what Verifiers 0.4.1 records for a deadline-cancelled call, and whether its train client maps the generation server's HTTP 400 to ProviderError(status_code=400). I couldn't inspect the installed package or run the tests in this environment.
| async def score_group( | ||
| self, rollouts: list[Rollout], env_input: object | ||
| ) -> list[RubricOutput]: | ||
| """Score with the rubric; a trace that Verifiers dropped (e.g. a judge gave a drop | ||
| verdict) gets reward None, so it isn't trained. | ||
|
|
||
| Args: | ||
| rollouts: Sibling rollouts in one prompt group, already stepped. | ||
| env_input: the env initial input shared by the group. | ||
|
|
||
| Returns: | ||
| One `RubricOutput` per rollout, in input order. | ||
| """ | ||
| outputs = await super().score_group(rollouts, env_input) | ||
| return [ | ||
| RubricOutput(reward=None) if rollout.logs["dropped"] is not None else output | ||
| for rollout, output in zip(rollouts, outputs, strict=True) | ||
| ] |
There was a problem hiding this comment.
This override makes Rollout.logs, which is a debug record, carry a control signal, and it changes the core Rollout.logs docstring (types.py:321) just to allow that. A drop verdict is already known in _run_verifiers_rollout, and it isn't the policy's doing, which is exactly what ERROR_INFRA means. If rollout_status returned ERROR_INFRA for trace.dropped is not None, training would come out the same: make_scored_group already keeps it out of scoring and centering. That lets you delete this override (~18 lines), turn test_a_trace_that_verifiers_dropped_gets_no_reward into one more row of the rollout_status parametrize, and revert the types.py docstring change. The cost is that a dropped trace shows up under status_rate/error_infra instead of completed, and log_failed_rollout logs it, with logs["dropped"] still giving the reason.
There was a problem hiding this comment.
Reply from claude: I kept the override. A drop verdict isn't a failure: Verifiers' judge says the trace can't be graded (e.g. the task is unanswerable), and Verifiers leaves it out of reward means and training (Trace.drop). As ERROR_INFRA, each drop would count in status_rate/error_infra and be logged by log_failed_rollout, which we read as an infra alarm. With the default rubric, training is the same either way (a rubric that compares siblings would still see the dropped one). The RolloutStatus docstring already names reward None as the way to keep a scored rollout out of training, and the Rollout.logs docstring now names this use.
| logs = verifiers_rollout_logs(verifiers_episode, trace) | ||
| if status.is_error(): | ||
| log_failed_rollout(logs, group_id=group_id, rollout_id=rollout_id) | ||
| else: | ||
| elif turns: | ||
| turns[-1].env_rewards[VERIFIERS_REWARD_KEY] = trace.reward |
There was a problem hiding this comment.
Rollouts that overflow the context after a turn now train differently, and the description doesn't list it. Before, the harness dying on an overlong later prompt was ERROR: env_rewards stayed unset, so the reward was 0.0, or error_reward if set. Now it is TRUNCATED_PROMPT_TOO_LONG, so turns[-1].env_rewards gets trace.reward (or truncation_reward). On a task graded from container state, such as Terminal-Bench, that rollout can now train with reward 1. That may well be what you want, but it changes numerics, so please state it in the description; right now it says truncation is "unchanged".
There was a problem hiding this comment.
Reply from claude: Solution item 4 now says it, but the "before" in your example isn't quite right, so here it is case by case. A harness that ends cleanly after the 400 was already COMPLETED and trained on its grade. Now it is TRUNCATED_PROMPT_TOO_LONG with the same grade. A harness that dies on the 400 was ERROR (error_reward=0.0). Now it is TRUNCATED_PROMPT_TOO_LONG with Verifiers' grade, 0.0, since Verifiers doesn't grade a failed run. So the in-repo recipes change the status, not the reward. A recipe that sets truncation_reward gets that reward in both cases. Item 9 no longer lists completion, or a prompt past the context, as unchanged.
| # Not fatal: `release_groups` frees the group's KV when the group ends, and | ||
| # `max_sessions` evicts the routing pin. |
There was a problem hiding this comment.
This comment rewrite about release_groups has nothing to do with error classification. Please move it to the PR that introduced release_groups, or drop it here (one concern per PR).
There was a problem hiding this comment.
Reply from claude: Moved both comment edits (the retried-attempt TODO and the release_groups note) down to the PR that owns this code (row 6 of the stack). This PR's diff no longer touches them.
3261329 to
6ced3e2
Compare
cad691f to
6e39e21
Compare
6ced3e2 to
2db56d0
Compare
6e39e21 to
38c4768
Compare
|
Reply from claude: @claude please review |
|
Claude finished @felipemello1's task in 3m 43s —— View job Verdict: Approve -- please address the items before merging (review). |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. At 38c4768, failures are still classified from Verifiers' typed Error fields and the rollout's phase, which is the right layer. A test row now pins the no-turn timeout case. What's left is the description and a few still-open suggestions. A maintainer still needs to review, since rollout/types.py is core.
What this PR does. VerifiersRolloutWorker.rollout_status checks these in order, and the first match wins:
- The last model call was a
ProviderError400:TRUNCATED_PROMPT_TOO_LONG. - A generator, interception or tunnel error:
ERROR_INFRA. - No turn:
ERROR_INFRA. - Otherwise the timeout, error and truncation rules apply as before.
The generation server now sends 400 only for context overflow and 422 for any other bad request. A failed rollout with turns keeps trace.reward under the reward key. A dropped trace gets reward None.
Example (in-repo recipes: error_reward=0.0, no truncation_reward)
before after
sandbox boot past timeout.setup ERROR, no tokens -> group ERROR_INFRA, siblings train
dropped
generator 503 at turn 3 ERROR, reward 0.0, trained ERROR_INFRA, not trained
SandboxError at turn 3 ERROR, reward 0.0 ERROR, reward 0.0
400 at turn 5, harness ends clean ERROR, reward 0.0 TRUNCATED_PROMPT_TOO_LONG,
reward = trace.reward
judge drop verdict trained with trace.reward reward None, not trained
Must fix
- The "Summary (human-written)" section is still empty. The author needs to fill it in.
Should consider
Each of these is still open from the last review:
rollouter.py:287-304-- returnERROR_INFRAfortrace.dropped is not Noneinrollout_status. That deletes thisscore_groupoverride, which readsRollout.logsas a control signal. It also lets you revert the core docstring change attypes.py:321-322. Training comes out the same, becausemake_scored_groupalready keepsERROR_INFRAout of scoring and centering.rollouter.py:371,386-389-- say in the description that overflow after a turn now trains ontrace.reward. For the in-repo recipes it used to train on 0.0. On Terminal-Bench, a harness that ends cleanly after the 400 can now train on reward 1. Solution item 8 says truncation is "unchanged". The NOTE describes the grading, but not the change from main.rollouter.py:336-339, 349-350-- these comment rewrites about generation metadata andrelease_groupsaren't about error classification. Move them to the PR that owns that code (one concern per PR).
Questions
rollouter.py:439-446-- at a Verifiers deadline, what is the cut-off model call recorded as? If it is aProviderError, the rollout becomesERROR_INFRAand avoids the timeout penalty. A row withis_timeout=Trueplus aProviderErrorafter a turn would pin whichever answer you intend.
Details
- What happens downstream.
TrainingSampleBuilder(training_sample_builder.py:136-160) drops reward-None rollouts before its no-tokens group drop. So a dropped trace or anERROR_INFRArollout with no turns leaves its siblings trainable. A first prompt past the context (TRUNCATED_PROMPT_TOO_LONG, no tokens) still drops its group, the same asERRORwith no tokens did on the base branch. - Failed rollouts with turns now carry
trace.reward. Both in-repo Verifiers recipes seterror_reward=0.0(verifiers_terminal_bench.py:134,verifiers_dapo_math.py:93), so theirERRORandERROR_TIMEOUTrewards don't change. - Generation server. A malformed JSON body raises
JSONDecodeError, which is aValueError, so it gets a 422 and can't be read as an overflow. A generatorfinish_reason="abort"returns 502, which becomesERROR_INFRAhere, while the native path makes itERROR_ABORT(token_env.py:209). I found no in-repo code that issues aborts, so I'm not listing this as a finding. - The 422 and the
episode error:text in theValueErroratrollouter.py:358are both in scope: they serve the classification.
Not verified: whether Verifiers 0.4.1 leaves trace.reward at 0.0 or None when it skips scoring. RewardFromVerifiers calls float() on it, which would fail on None when error_reward is unset. Also not verified: what a deadline-cancelled call is recorded as. I couldn't inspect the installed package or run the tests here.
2db56d0 to
dc51fce
Compare
38c4768 to
70549c4
Compare
dc51fce to
2e3717b
Compare
70549c4 to
c7acdad
Compare
2e3717b to
375a845
Compare
c7acdad to
1b8647b
Compare
375a845 to
33282f5
Compare
1b8647b to
5308f46
Compare
33282f5 to
ed49af9
Compare
5308f46 to
2ddc8b2
Compare
ed49af9 to
0326557
Compare
2ddc8b2 to
2788cca
Compare
|
Reply from claude: On the question about a Verifiers deadline. Verifiers 0.4.1 records the cut-off model call as a @claude please review |
|
Claude finished @felipemello1's task in 1m 53s —— View job Verdict: Approve -- please address the items before merging (review). |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. At 2788cca the earlier review items are resolved: the deadline question is answered and pinned by a test row, and the comment rewrites are gone from the diff. The new phase rule matches the native path, where any env exception is ERROR_INFRA. The only item left is the empty human-written summary. A maintainer still needs to review, since rollout/types.py is core.
What changed since the last review. After the first turn, only a trace whose last error is exactly HarnessError is ERROR now. SandboxError, TaskError, ToolsetError, an unknown type, and a failure with no recorded error all become ERROR_INFRA (the previous revision kept them ERROR). The README has a new "Which failed rollouts train" table.
Example (in-repo recipes: error_reward=0.0)
base branch this PR
SandboxError at turn 3 ERROR, reward 0.0 ERROR_INFRA, not trained
agent pkills itself at turn 3 ERROR, reward 0.0 ERROR (HarnessError), reward 0.0
deadline at turn 3, cancelled ERROR_TIMEOUT ERROR_TIMEOUT (trace.ok stays True)
model call
ProviderError 503 + is_timeout ERROR_TIMEOUT ERROR_INFRA (new test row)
no turn, past timeout.setup ERROR, group dropped ERROR_INFRA, siblings train
Earlier items
- Deadline vs. generator order: resolved. The reply explains that 0.4.1 records the cut-off call as
CancelledErrorand leavestrace.okTrue, and the(False, True, False, 1, ProviderError 503)row intest_rollout_status_maps_timeouts_to_error_timeoutpins the order. - Dropped trace as reward None via
score_group: resolved by the author's reply.RolloutStatus's TODO (types.py:139) already names ascore_groupoverride that returns None as the way to stop training a rollout, and keeping drops out ofstatus_rate/error_infrakeeps that metric usable as an infra alarm. - Overflow after a turn: resolved. Solution items 4 and 9 now describe the change, case by case.
- Unrelated comment rewrites: resolved. They moved to PR 6.
Must fix
- The "Summary (human-written)" section is still empty. The author needs to fill it in.
Should consider
rollouter.py:471-- the status table is written twice, in therollout_statusdocstring and inREADME.md:160, with a "keep both in sync" note. If you keep the full table in one place and point to it from the other, the note can go and the two copies can't drift.
Details
- Downstream training of each status.
make_scored_groupscores onlyis_trainable()rollouts (rollouter.py:530), so anERROR_INFRArollout with turns ignores thetrace.rewardthat is now written to itsenv_rewards.ERRORandERROR_TIMEOUTtakeerror_rewardbefore the reward fns (rubric.py:139), so the in-repo recipes (verifiers_terminal_bench.py:134,verifiers_dapo_math.py:93) still train failed rollouts on 0.0. - Episode-level errors.
erroris read only from a failed trace (None if trace.ok), so an episodeEnvErroron a graded trace falls through toERROR_INFRA. The env-retry andfinalizerows in the parametrize cover this. - Metrics.
{prefix}/unscored_rateexists (controller/metrics.py:282). The averaging code is unchanged; the reward means move only because more Verifiers rollouts are now unscored, as the description says. - Numerics change. For Terminal-Bench, sandbox, tool and task failures after a turn used to train at 0.0 and now leave the group's centering. The description states this and gives its cost (31 of 46,106 rollouts in one run).
Not verified: whether trace.reward can be None when Verifiers skips scoring (with error_reward unset, RewardFromVerifiers would then fail on float(None)), and the Verifiers 0.4.1 behavior described in the replies. I couldn't inspect the installed package or run the tests here.
0326557 to
8ac20af
Compare
|
Reply from claude: @claude please review. The stack is reordered: Verifiers groups in workers, then Verifiers 0.4.1, then worker placement come first (the stack table shows the new rows). It is also rebuilt with three reviewed passes: a code-style pass over every changed file, the rewritten placement docs (the |
|
Claude finished @felipemello1's task in 1m 12s —— View job Verdict: Approve -- please address the item before merging (review). |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. At 5365586, after the stack reorder and the style pass, rollout_status, the score_group override, the generation server's 400/422 split and the tests have the same logic as at 021610a. A maintainer still needs to review, since rollout/types.py is core.
What changed since the last review. This PR's 5 files have the same hunks as before. The style pass only touched wording. For example, the rollout_status docstring now gives the two costs as separate sentences ("A policy that breaks its sandbox before grading, or hangs the task's tests, isn't penalized. An agent the host kills ... trains as ERROR."). The placement docs, the deleted SVG and the reorder are in other rows of the stack, not in this diff.
Example. I checked that the moved base doesn't change anything this PR depends on:
what this PR relies on at the base branch now
BaseRolloutWorker.score_group(rollouts, unchanged (rollout/rollouter.py:361)
env_input)
make_scored_group scores is_trainable() only unchanged (rollout/rollouter.py:447)
MessageEnvRolloutWorker (named in 3 comments) class at rollout/rollouter.py:469
Rubric error_reward / truncation_reward unchanged (rollout/rubric.py:134-142)
short-circuit
So an ERROR_INFRA rollout or a dropped trace still stays out of centering, and the in-repo recipes (error_reward=0.0) still train ERROR and ERROR_TIMEOUT on 0.0.
Must fix
- The "Summary (human-written)" section is still empty. The author needs to fill it in.
Details
- Earlier items all stay resolved at HEAD: the order of the deadline and generator checks, the dropped-trace
score_groupoverride, the overflow numerics in the description, the unrelated comment rewrites,record_timeoutoverwriting the stop condition, the status table written twice, and theMessageEnvRolloutWorkerrename. - Line length. The two longest new comment lines (
rollouter.py:696,test_verifiers.py:1371) are under the 120-column limit in.flake8.
Not verified: I didn't run the tests in this environment.
5365586 to
58d0ba2
Compare
8ca9c0e to
eea50dd
Compare
58d0ba2 to
37eedda
Compare
|
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. |
|
Claude finished @felipemello1's task in 57s —— View job Verdict: Approve -- please address the item before merging (review). |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. At 37eedda (rebased onto main after the look-aside router PR merged), this PR's 5 files have the same hunks as at 5365586. rollout_status, the score_group override, the generation server's 400/422 split and the tests are unchanged. A maintainer still needs to review, since rollout/types.py is core.
What changed since the last review. Only the base moved. The diff is the same 465/67 lines across the same 5 files. Because the stack below is now on main, the code this PR depends on comes from main, not from the draft row 0.
Example. I checked the new base for the things this PR relies on:
what this PR relies on at the base branch now
BaseRolloutWorker.score_group(rollouts, unchanged (rollout/rollouter.py:361)
env_input)
make_scored_group scores is_trainable() only unchanged (rollout/rollouter.py:447)
MessageEnvRolloutWorker (named in 3 comments) class at rollout/rollouter.py:469
Rubric error_reward / truncation_reward unchanged (rollout/rubric.py:134-142)
short-circuit
generation server: the only 400 is the yes; not ready 503, generator
context-length check exceptions 500, bad responses 502
in-repo recipes set error_reward=0.0 verifiers_terminal_bench.py:134,
verifiers_dapo_math.py:93
So an ERROR_INFRA rollout or a dropped trace still stays out of centering. A 400 still means only a prompt past the context. The in-repo recipes still train ERROR and ERROR_TIMEOUT on 0.0.
Must fix
- The "Summary (human-written)" section is still empty. The author needs to fill it in.
Details
- Earlier items all stay resolved at HEAD: the order of the deadline and generator checks, the dropped-trace
score_groupoverride, the overflow numerics in the description, the unrelated comment rewrites,record_timeoutoverwriting the stop condition, the status table written twice, and theMessageEnvRolloutWorkerrename. - The PR description no longer mentions row 0. That matches the rebase onto main.
Not verified: I didn't run the tests in this environment.
eea50dd to
d8aaf70
Compare
66e32e8 to
7308386
Compare
0c47cbd to
ec7c8b6
Compare
|
Reply from claude: Closing. "Verifiers 0.4.1 and renderers 0.2.0: each rollout worker runs Verifiers envs" now trains only a rollout that Verifiers finished cleanly; every other rollout gets no reward, and its status says who failed. So this PR has nothing left to add. The dropped-trace case the bot raised is that PR's first row. |
7308386 to
1df122d
Compare
ec7c8b6 to
6f48047
Compare
Summary (human-written)
Agent details
TLDR: Only a rollout that Verifiers finished cleanly trains, with Verifiers' grade as its reward. Every other rollout gets reward None, and its status says what went wrong. Validation still grades a timed-out rollout, so a timeout counts as a failure there.
Stack (15 PRs, bottom first; merging a PR also merges every PR below it; this PR in bold)
Alone on main, not in this stack: "Validation reads each prompt at most once; ValidationConfig.steps defaults to -1" and "Terminal-Bench 35B-A3B recipe: Dist-MoE in both roles, FULL CUDA graph generators, DAPO loss".
Problem
ERRORorERROR_TIMEOUT, and both train at the rubric'serror_reward(0.0 in the recipes).Solution
rollout_statusreads Verifiers' fields (trace.dropped,is_timeout,ok, the last call's error,stop_condition,num_turns): the table above.VerifiersRolloutWorker.score_groupsends only the "yes" rows to the rubric, plusERROR_TIMEOUTin validation groups (negative ids). The rest get reward None, so they don't train; the rest of their group does.RewardFromVerifiers, so no recipe sets one.Rollout.logs.rollout/status_rate/<status>,rollout/unscored_rate,validation_reward_all.You may ask:
status_rate/error_timeoutis mostly the policy (the log line'sstopnames the stage), a climbingstatus_rate/error_infrais the sandbox, the harness launch or the generator.NOTE: a validation timeout before the policy's first reply has no turn to keep its grade on, so
RewardFromVerifiersreads 0.0 for it. A TODO intrace_to_rolloutkeeps it for later.TODOs in this PR: keep the grade of a rollout with no turns.
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.1: 976 passed, 1 skippedtest_rollout_status_takes_the_first_matching_rowcovers each row;test_only_a_rollout_that_trains_or_a_validation_timeout_keeps_its_gradecoversscore_group, including a group that never calls the rubric;test_a_rollout_that_does_not_train_logs_its_task_and_last_errorchecks the log line.