Repository navigation
refactor(capture): name capture keys capture_key on the ledger control surface - #5248
Conversation
|
/ok to test c8ade95 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — LGTM — no concerns found.
Reviewed all 23 changed files and their directly affected contracts and consumers. The capture-key rename is consistent across control routes, ledger implementations, capture contexts, snapshots, vLLM integration, and checkpoint restoration. The legacy HTTP body alias, persisted TokenEntry.rollout_id, and public staging-acknowledgement keyword remain intact.
Static review only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
cmunley1
left a comment
There was a problem hiding this comment.
LGTM, one comment, CaptureContext.rollout_id and the rollout_id= keywords on manifest/retire/delete/record_failure/mark_incomplete are renamed with no deprecated alias. #5317 kept read-only aliases with a one-time FutureWarning for the record fields. Doing the same here would spare outside callers a hard break. Nothing in Gym or NeMo RL uses the old names today, so fine either way.
|
/ok to test 1f7f429 |
…l surface Finish the capture-key rename on the training-token-capture control surface: - The manifest route parameter is `capture_key`; the URL is unchanged. - The retire and delete body field is `capture_keys`. The routes still accept `rollout_ids` for one release; RolloutControlClient sends the new name. - CaptureLedger.record_failure/manifest/retire/delete and TokenSink.mark_incomplete name their parameter `capture_key(s)`, as do the InMemoryLineageStore, FileLineageStore and TokenCaptureStore methods and RolloutControlClient.manifest/retire/delete. - CaptureContext.rollout_id and TokenCaptureSnapshot.rollout_id are `capture_key`. TokenEntry.rollout_id is an on-disk field and is not renamed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…re key Review follow-up. TokenEntry.rollout_id holds the capture key (one attempt of one rollout), so rename it to capture_key and bump the token record schema to version 2. Version 1 rows, which name the key rollout_id, are still read, so a run upgraded with unconsumed captures on disk keeps them. Rename validate_rollout_ids to validate_capture_keys, the batch validator behind retire and delete, and refresh its import-surface entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
Finish the review follow-up on the removal surface. TokenSource.retire and delete, TokenCaptureStore.retire/retire_now/delete/delete_now, and CheckpointableLedger.retire/delete_unstarted with its lineage-store implementations take capture_keys, matching CaptureLedger. Every caller passes the batch positionally. validate_capture_keys now says "capture keys" in its error, and the external harness docs show the new name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
1f7f429 to
3e8bbcd
Compare
|
/ok to test 3e8bbcd |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41781648474 |
What changed and why
Gym #4128 renamed the staging wire models to
capture_key/source_capture_key, the close-admission route and the refusal header. The rest of the training-token-capture control surface still saidrollout_id. This PR finishes that rename, so that the following PRs, which add agent instance identity to exactly these signatures, touch each one once.GET /training-token-capture/control/rollouts/{capture_key}/manifestiscapture_key. The URL does not change.LedgerBatchRequest.capture_keys. The routes still acceptrollout_idsfor one release (validation_alias=AliasChoices("capture_keys", "rollout_ids"));RolloutControlClientsends the new name.CaptureLedger.record_failure,manifest,retireanddelete, andTokenSink.mark_incomplete, name their parametercapture_key/capture_keys, as do the same methods onInMemoryLineageStore,FileLineageStoreandTokenCaptureStore, andRolloutControlClient.manifest/retire/delete.CaptureContext.rollout_idandTokenCaptureSnapshot.rollout_idarecapture_key, with every call site, including the vLLM model server's measurement context.TokenEntry.rollout_idiscapture_key, andTOKEN_ENTRY_RECORD_SCHEMA_VERSIONis 2. A row markedschema_version: 1that names the keyrollout_idis still read, so a run upgraded with unconsumed captures on disk keeps them.validate_rollout_idsisvalidate_capture_keys, and its import-surface entry is refreshed.model-call-capture.mdxshows the new body field and the alias.mark_external_staging_committed(rollout_id=...)keeps its public keyword.How it works
Two things change outside a process. On the wire, the retire and delete body field keeps its earlier name as an alias. On disk, token records are written as schema version 2 with
capture_key, and version 1 rows are still read: a before-validator onTokenEntryreadsrollout_idascapture_keyonly for a row markedschema_version: 1, so a version 2 row or aTokenEntry(rollout_id=...)call is rejected. Lineage ledgers, token state files, file names and rollout checkpoint records do not change. The rest of the rename is mechanical: every keyword and attribute use moved together, and a test pins the protocol's keyword names on both ledger stores.Where this sits in the stack
This is one PR in a stack of draft PRs that implements agent instance identity from the Gym capture identity design (draft 2): several agent instances (assistant, judge, simulated user, debaters) can call model servers in one episode, every record says which one made each call, capture computes lineage and outcomes per agent instance, and the trainer chooses which agent instances it trains on. Gym records; trainers select. Single-agent episodes do not change: an agent's own
/runnames no agent instance, and its records differ frommainonly by the newmodel_refcolumn.Each PR is one commit, and its base is the branch of the PR before it, so each diff shows only that PR's change.
pranav/agent-instance-00-capture-key-rename): refactor(capture): name capture keys capture_key on the ledger control surface (this PR)pranav/agent-instance-01-correlation-module): feat(core): add a correlation module that reads and builds the rollout pathpranav/agent-instance-02-record-identity): feat(model): record agent instance, agent kind and model server on every capture and model-call recordpranav/agent-instance-03-per-agent-capture): feat(capture): compute lineage, terminal chains and outcomes per agent instance and model serverpranav/agent-instance-04-direct-call-names): feat(core): let callers name an agent instance on model callspranav/agent-instance-05-agent-session-binding): feat(agent): bind agent sessions to an agent instance at seed timepranav/agent-instance-06-per-agent-results): feat(episode): report terminal calls and rewards per agent instancepranav/agent-instance-07-migrate-readers): refactor(core): read and build every rollout path through the correlation moduleThe first PR's base is
main@0b8783981. External dependencies: #5083 (session lifecycle names, open) for PR 5. #4969 (rollout prefix hooks for fixed-base-URL clients, open) needs one small change in whichever of #4969 and PRs 1 and 4 lands second:with_rollout_prefixdetects an existing prefix withresolveand takes the name fromagent_instance_context.The NeMo RL follow-up (selecting agent instances to train on, one
RolloutReceiptper selected agent instance, per-agent rewards) is separate; until NeMo RL bumps its Gym pin, none of these PRs affect NeMo RL training runs.Issue
No tracking issue exists; the work follows the Gym capture identity design (draft 2) and its implementation plan.
Validation
Tests ran on Slurm (one node,
rl-gym.nightlycontainer), each branch against a baseline worktree ofmain@0b8783981:python -m pytest -n 32 tests/unit_tests): 33 failed, 12,191 passed, 4 errors. Every one is environmental in this container (docker-compose, OpenSandbox compose, Harbor compose overlay, eval resubmit, reward profile, dataset orchestrator and sandbox supervisor tests, and four exporter modules that fail to import), and the same set fails on every branch of the stack. The docker-compose tests are flaky: one or two of them pass or fail from run to run.requirements.txtorpyproject.toml, asgym env testdoes.pre-commitcould not fetch its hook repositories from the build environment, soruff check --fix,ruff check --select I --fixandruff formatran with ruff 0.9.9 (the hook's pinned version) on every changed file. The guardwords and end-of-file hooks did not run here; CI runs them.Signed-off-byline.test_token_capture_control_routes.py: both body field names accepted; the client sendscapture_keysand splits large batches.test_token_capture_ledger.py: the ledger methods takecapture_key/capture_keysby keyword onFileLineageStoreandInMemoryLineageStore.7b573678b), run in this sandbox against the PR's first commit408c0e40c:ruff checkandruff format --check(ruff 0.9.9) pass on every changed file. Thevllm_model,switchyard_modelandclaude_code_agentsuites: 1,111 passed, 6 skipped. The core suite (python -m pytest -n 24 tests/unit_tests): 14,756 passed and 311 failed or errored. One docker-compose test hung, so the run was killed before pytest printed its summary. I reran the 28 files with failures on both commits: 293 fail with this commit and 294 on408c0e40c, and every failure with this commit also fails on408c0e40c(missingopensandbox/mlflow, read-only/raid/scratch, buildah/tar, worker sockets).test_token_capture.py: a version 1 row written to a token file next to a version 2 row is read back byfreeze_nowwith itscapture_key; a row that names the keyrollout_idis accepted only when marked version 1.CaptureContextandTokenCaptureSnapshot(test_token_id_capture.py,test_framework_context_capture.py,test_checkpoint_model.py,test_external_capture_handlers.py,test_token_capture_staging_worker.py,test_trajectory_builder.py,test_token_capture_conformance.py,test_rollout_collection.py,test_base_responses_api_model.py) pass.Rollout evidence
N/A: no rollout behavior changes. The retire and delete body field keeps an alias, and the token record schema bump keeps reading version 1 rows; both are covered by unit tests above.
Compatibility
LedgerBatchRequestacceptsrollout_idsfor one release;RolloutControlClientsendscapture_keys, so a framework on this Gym talking to an older Gym server is not supported (one Gym version per training run, as the staging wire models already require).validate_rollout_idsis removed fromnemo_gym.models.token_capture.store(and its old pathnemo_gym.token_id_capture.store); usevalidate_capture_keys. Code that buildsTokenEntry(rollout_id=...)or readsentry.rollout_idmust usecapture_key.rollout_id=/rollout_ids=by keyword tomanifest,retire,delete,record_failureormark_incomplete, or readCaptureContext.rollout_id/TokenCaptureSnapshot.rollout_id, must use the new names. The NeMo RL sources checked make no such keyword calls; NeMo RL's pinned Gym predates feat(capture): support framework-owned context reconstruction #4128 and needs its own catch-up before it bumps Gym.🤖 Generated with Claude Code