Repository navigation
feat(capture): let a rollout skip token capture - #5711
Conversation
c6356e0 to
8bb0e7a
Compare
|
/ok to test 8bb0e7a |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found two preparation-path defects: task-data validation rejects the new framework key, and taskset collation drops it before dispatch. The inline findings describe separate corrections.
RISK — Required real-rollout evidence is missing
The PR description says end-to-end validation hasn't run. The protected AGENTS.md quality bar requires representative real-model smoke rollouts for behavior-changing agent or environment work. The mocked tests don't establish that a real harness and model server honor the new activation behavior together.
Could you run captured and skipped rows through a real harness/model pairing, covering /run and a typed Environment Server activation, and record the configuration, commands, rollout IDs, and inspected outcomes? No implementation patch is established by this evidence gap.
Proposed acceptance checks: the ordinary row retains the training tag and produces captured records; the skipped row retains its attempt-qualified rollout prefix, produces no training-token records, bypasses rebuilding without a capture-induced mask, and completes verification and cleanup. Preserve false/absent-key capture behavior, ensure a row cannot enable disabled capture, and retain evaluation-style output for skipped Claude Code runs. In a multi-participant pairing, the user simulator or judge must remain untagged.
I completed static inspection across all 24 changed files and their directly affected paths, including consolidation of all three review topics. I didn't execute tests or model rollouts.
Inline comments (escaped v1):
-
nemo_gym/data/task_data.pyline 70: RISK — Reserve the new control in task-data validationThe new
_ng_skip_token_capturecontract isn't reflected inRESERVED_ROW_KEYS. A flat example row such as{"responses_create_params":{"input":"task"},"_ng_skip_token_capture":true}is reported as containing an unknown task field against the empty example schema. Normalization leaves the key in the schema input; unknown extras make the report dirty, and strict collation raises. This affects flat rows and rows awaiting taskset materialization. A framework control should not require a task-schema field.Add only this key to the reserved set; don't suppress every
_ng_*field or weaken task validation. Suggested replacement at this anchor, not executed; please verify before adopting:"_ng_rollout_index", "_ng_skip_token_capture",Proposed acceptance checks: validate the row above against the empty example schema and assert a clean report with no unknown keys; repeat with
falseand without the key. Add an unrelatedtypoand assert that it still produces a dirty report. Retain the existing misplacement regression: top-levelunit_testsmust still raise for both flat and taskset declarations. These are source-derived checks, not test results. -
nemo_gym/data/dataset_preparation.pyline 1314: RISK — Preserve the skip flag during taskset collationWith a flat source row containing
_ng_skip_token_capture: trueand a dataset declaration containingtaskset: tasks, this branch saves only the four identity fields. materialize_task() removes every_ng_*field, so the prepared row loses the skip. With validation off/warn—or after correcting the separate reserved-key issue—the episode converter receives no flag. Configured capture then runs and the collector rebuilds a rollout that requested neither. Already-materialized rows retain the flag, so the two supported preparation paths disagree.Keep the control at the prepared row's top level, beside
task_idandtask_input. The smallest correction is to importSKIP_TOKEN_CAPTURE_KEY_NAMEand include it in this preserved-field tuple. Don't retain all collector metadata insidetask_input.Suggested patch, not executed; please verify before adopting:
@@ from nemo_gym.config.global_config import ( ROLLOUT_INDEX_KEY_NAME, + SKIP_TOKEN_CAPTURE_KEY_NAME, TASK_INDEX_KEY_NAME, @@ ATTEMPT_INDEX_KEY_NAME, + SKIP_TOKEN_CAPTURE_KEY_NAME,Proposed acceptance checks: extend test_collation_preserves_shard_and_retry_identity with the flag. Assert that
truesurvives at the prepared row's top level, stays out oftask_input, and yieldsskip_token_capture: truein the episode request. Preserve the existing shard-ID and attempt assertions, repeated copies, and source-file bytes. Withfalseor no key, the episode must still omit the serialized flag. A retained non-boolean value must still be rejected by the collector's strict skip parser.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
8bb0e7a to
43294bb
Compare
|
/ok to test 43294bb |
pthombre
left a comment
There was a problem hiding this comment.
Thanks for this. The skip path looks correct across the agents, the five Environment Servers and rollout collection, and rows without the key behave exactly as on main. Both earlier bot findings are fixed at this head. Two small questions inline: how a null skip value should be treated, and a docs note for the new untagged-activation behavior.
Generated by Claude Code
43294bb to
1e7c1fd
Compare
|
/ok to test 1e7c1fd |
A training framework that also runs rollouts it does not train on, such as validation rollouts, can set `_ng_skip_token_capture: true` on the row. None of that rollout's model calls then carries the `/training-token-capture` segment, so the model server admits none of them for capture, and a framework that stages tokens from its generation worker stores none. - Agents: `/run` reads the row's setting, and an activation on a rollout path without the training tag captures nothing, whatever the agent's own `token_id_capture` setting. Both set a per-request context that `_token_id_capture_enabled()` reads, so harnesses that build their own model URL from it (Claude Code, Codex, OpenCode, ...) follow the rollout. `url_path_for_run` and `base_url_for_run` also read the row, for agents whose `/run` route does not set the context. - Rollout collection passes the setting to Environment Servers as `skip_token_capture: true` in the episode request (omitted when false). single_agent_turn, harbor, swe_together and nemo_user_sim activate their agents without the tag; the flat-row relay reads it from the row. - Rollout collection does not rebuild the response of a row that skips capture. A row can turn capture off, never on: `false` or no key leaves capture to the run's `token_id_capture` block. Refs: NVIDIA-NeMo#5340 Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follow-up to the team review of the per-rollout skip: - Rollout correlation now follows the run's configuration (`_token_id_capture_configured()`), so a `/run` that skips capture keeps its `/ng-rollout/<id>` prefix and drops only the training tag, as an Environment Server activation already did. The tag and capture-dependent output still follow the request (`_token_id_capture_enabled()`). - Tests: Claude Code through the real `/run` route, Claude Code's evaluation output under the skip, every untagged rollout activation route, and the collector's episode request parsed by BaseEpisodeRequest. - Docs: the section moves next to "Provide unique rollout ids", describes flat and typed rows correctly, and says what frameworks that rebuild responses and custom harnesses must do. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A dataset row may set `_ng_skip_token_capture: true`. Task-data validation now treats the key as framework-owned (`RESERVED_ROW_KEYS`) instead of an unknown task field, and taskset collation keeps it at the prepared row's top level beside the collector identity, so the episode request still skips capture. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
… activations - `_ng_skip_token_capture: null` now counts as unset, as `_ng_rollout_id: null` does: a table that sets the column on some rows writes null on the others, and one such row stopped the whole collection. Other non-boolean values are still refused, and the error names the row by its task and rollout index. The agent `/run` request accepts null too. - The harness page says that an activation without `/training-token-capture` captures none of its calls, even if the agent sets `token_id_capture`. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenCode now builds its model URL while handling the activation, so the activation's path decides capture. An Environment Server activates a captured rollout on `/ng-rollout/<id>/training-token-capture/v1/responses`; the test used the untagged path, which no longer captures. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A rollout's sampling values travel in an `/ng-sampling/<values>` segment after the training tag. Pin that an untagged activation drops only the tag and keeps the sampling segment, and that a tagged one keeps both. Signed-off-by: Zeyu Zhou <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1e7c1fd to
1ebb215
Compare
|
/ok to test 1ebb215 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43310972604 |
What changed and why
Token capture is set once per run (
token_id_capture), so a training framework that validates through capturing agents gets its validation rollouts captured like its training rollouts. NeMo RL would then stage their token ids and logprobs in TransferQueue, which is wasted for rollouts it never trains on. RL does not hit this yet: only its single-controller runner captures, and it has no validation loop.A row can now set
_ng_skip_token_capture: true. None of that rollout's model calls carries/training-token-capture, so nothing is captured for it.falseor no key keeps today's behavior: a row can turn capture off, never on. A skipped rollout keeps its/ng-rollout/<id>prefix and any/ng-sampling/<values>segment; only the training tag is dropped./run_ng_skip_token_capturefrom the row.skip_token_capture: truein the episode request, and does not rebuild a skipped row's response.single_agent_turn,harbor,swe_togetherandnemo_user_simcall their agents without/training-token-capture.single_agent_turn_legacyreads the setting from the flat row./training-token-capturetoken_id_capturesetting. Harnesses that build their own model URL (Claude Code, Codex, OpenCode, ...) used to add the segment back from their config. An unprefixed/v1/responsescall keeps the agent's own setting.The last row also affects two roles that Environment Servers already call without the segment: nemo_user_sim's user simulator and swe_together's judge stop being captured when they run on such a harness. Neither is trained on. An Environment Server outside Gym that activates a harness without the segment, and relied on the harness's own
token_id_capture, stops capturing too.A skipped rollout otherwise runs like an uncaptured evaluation rollout, including in agents whose output depends on capture: Claude Code folds its thinking into the message text and names its response with a generated id, and osworld_agent builds its response without the served calls.
Relation to other work
token_id_capture.training_agent_instances. The two settings combine: a call carries the tag only if its agent instance is selected and its rollout does not skip capture. Whichever PR lands second combines the checks where the other changed the same code:training_tag_for, each Environment Server's tag rule, feat(core): let callers name an agent instance on model calls #5252's explicittoken_captureargument (which must keep the row's skip), and feat(agent): bind agent sessions to an agent instance at seed time #5253's agent-instance route, which needs the same wrapper as the unnamed untagged route. A test in this PR fails if an untagged activation route is left unwrapped.Issue
Closes #5340.
Validation
/run), rollout collection, each Environment Server's activation path, and Claude Code's output under the skip. Removing any line they guard fails them.Rollouts
Validated end to end in NVIDIA-NeMo/RL#5098 at 8bb0e7a: in a single-controller GRPO step with token capture on, skipped rollouts through
single_agent_turn,single_agent_turn_legacyandlegacy_agentwere not captured and kept their rollout prefix, while training rollouts were captured as before.🤖 Generated with Claude Code