Repository navigation
feat(capture): stage framework attachments with the token record - #3513
Conversation
Pass immutable local tensor attachments through worker capture and preserve image descriptors in vLLM extras. Retain stage-before-ack ordering and token-only sink compatibility. Builds on the served-response ancestry fix from #3301 and the VLM capture work in #3368. Signed-off-by: Pranav Prashant Thombre <[email protected]>
Preserve versioned image/video descriptors in media_capture extras and exercise atomic staging of pixels, frame sizes, and frame counts. Retain token-only sink compatibility and optional router metadata. Validation: 152 Gym capture, staging, rebuild, conformance, and API integration tests passed in Slurm job 3831975; scoped pre-commit checks passed. Signed-off-by: Pranav Prashant Thombre <[email protected]>
Reuse the backend-independent media contract from lauradang#1. Keep vLLM placeholder metadata alongside common media geometry and route extras; leave tensor staging to RL and remove the attachment extension. No Megatron inference adapter or serving integration is imported. Signed-off-by: Pranav Prashant Thombre <[email protected]>
|
🌿 Preview your docs: https://nvidia-preview-pranav-vlm-capture-support.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
Let `complete_call` / `complete_call_from_response` accept keyword-only `attachments` and forward them to `StagingSink.stage(record, attachments=...)` so a framework can land media tensors in the same durable write as the token columns. Attachments never enter the record, extras, or any digest; the keyword is only passed when supplied, so legacy `stage(record)` sinks keep working for text calls and fail as `capture_failed` (never a retry without attachments) when given some. Drop the digest-covered media summary: remove `staging/media.py` (`MediaCaptureExtras`, `build_multimodal_extras`, `parse_multimodal_extras`, the unused compact-delta helpers) and its exports, and make the vLLM adapter reject a stale `media` payload key so worker/Gym version skew fails closed instead of dropping pixels. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
Update the model-call capture guide for the single-write protocol: media travels as opaque `attachments` into the staging sink beside the token record, the `media` extras summary is gone, and the vLLM adapter rejects stale payloads that still carry it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
The paired RL and Gym changes ship together, so the vLLM adapter no longer needs a one-release guard for workers that still send the removed `media` geometry summary. Remove the check, its test, and the doc note. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
Resolve conflicts in the staging capture core and worker tests: keep main's engine-native `response_payload: Any` on `complete_call_from_response` alongside the branch's keyword-only `attachments`, and combine the test imports. Migrate the two sink test doubles that arrived from main to the attachment-aware signature. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
|
/ok to test 19ef970 |
|
/claude review |
|
SHIP — no reliability concerns. Reviewed the framework-owned media staging change (attachments keyword + vLLM
Test coverage is thorough (legacy sink, empty/absent attachments, poison paths, digest invariance, adapter span validation). Nothing to block on. |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/35900234426 |
…timodal-capture Adopt the attachments route for media tensors. Drops the Megatron handler's multimodal-content rejection: this branch is the multimodal staging that guard was waiting on. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Laura Dang <[email protected]>
Media tensors now reach the sink as complete_call_from_response attachments (Gym NVIDIA-NeMo#3513); the digest-covered geometry summary is no longer needed. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Laura Dang <[email protected]>
Replace the Gym PR-branch pin with 17abf2ddc76f74e40d0ba5a15b0401710a46db26, the squash-merge commit for NVIDIA-NeMo/Gym#3513 on main. Keep the submodule pinned to that exact revision for reproducible builds. The capture staging tree and Gym package metadata are identical to the previous pin. uv lock --check --offline passes without lockfile changes. Signed-off-by: Pranav Prashant Thombre <[email protected]>
Extend NeMo-Gym token capture to Omni dynamic-resolution images and native video for async vLLM generation with a Megatron learner. The vLLM worker snapshots the processed media tensors the engine ran on, stages them in the same TransferQueue write as each call's token delta, and the finalizer reassembles the rollout's media chain into pixel_values / imgs_sizes / num_frames for the learner. Text-only runs are unaffected. Rebased onto main after the MInf ledger-capture and vLLM 0.29 landings: - reuse main's shared ChainPrefixCache / resolve_admission_prefix in the vLLM worker; the media path keeps its own handle on the same TQTokenSource - declare capture_media on GenerationInterface.setup_token_capture and reject it explicitly in MegatronGeneration; setup fails at validation time when media capture is requested with a non-vLLM generation backend - keep main's Optional-aware terminal_selection metric derivation - Gym pin 17abf2dd (includes main's pin plus the attachment staging contract); uv.lock reflects Gym dropping httpx-aiohttp Paired Gym change: NVIDIA-NeMo/Gym#3513. Signed-off-by: Pranav Prashant Thombre <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rad/pr2823-multimodal-capture NVIDIA-NeMo#3513 landed as squash 17abf2d; this branch already carried its final head (19ef970), so the merge only brings in main's drift. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Laura Dang <[email protected]>
Megatron Inference now stitches multi-turn multimodal prompts itself (NVIDIA/Megatron-LM#7598): the framework splices in the exact expanded prefix and the engine expands only the media placeholders after it. The payload no longer carries `compact_prompt_token_ids`, so nothing needs a compact-space delta. Remove `build_compact_token_ids_delta`, the adapter's compact extras, and their tests; the Megatron adapter stages no extras again. Keep lifting the multimodal rejection on Megatron capture requests: media reaches the sink as `complete_call_from_response` attachments (NVIDIA-NeMo#3513). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Laura Dang <[email protected]>
…IA-NeMo#3787) ## Summary Follow-up to NVIDIA-NeMo#2823 (Megatron capture adapter) and NVIDIA-NeMo#3513 (framework attachments). Moved here from lauradang#1. `MegatronWorkerCaptureHandler` refused any request with non-text content parts (`_reject_multimodal_content`) because the Megatron adapter staged no media geometry. Since NVIDIA-NeMo#3513, the framework hands media tensors to the sink as `complete_call_from_response` attachments, so that reason no longer holds. This PR removes the check. Image and video requests are now admitted exactly like text requests. No compact-space token delta is needed. An earlier revision of this PR staged `compact_token_ids_delta` so the next turn could splice against the compact render. Megatron Inference now stitches multi-turn multimodal prompts itself (NVIDIA/Megatron-LM#7598): the framework splices in the exact expanded prefix, and the engine expands only the media after it. The payload no longer carries `compact_prompt_token_ids`. The canonical expanded `token_ids_delta` is the only token space staged, and the Megatron adapter still stages no extras. Changes: - `nemo_gym/token_id_capture/external_capture.py`: remove `_reject_multimodal_content`. - `tests/unit_tests/test_external_capture_handlers.py`: drop the rejection cases; add an image/video admission test. The vLLM handler and both adapters are unchanged. ## Issue No separate issue; this is the multimodal follow-up to NVIDIA-NeMo#2823. ## Dependencies - Megatron-LM: NVIDIA/Megatron-LM#7598 (expanded-prefix stitching), reaching NeMo RL through the Megatron-Bridge pin. - RL consumer: NVIDIA-NeMo/RL#4332. It refuses multimodal Megatron capture at setup on Megatron-LM pins without #7598. ## Validation - `pytest tests/unit_tests/test_external_capture_handlers.py tests/unit_tests/test_token_capture_staging_worker.py`: 92 passed - `ruff check` / `ruff format --check` (v0.9.9) on the changed files: passed ## Rollout evidence The earlier (compact-delta) revision of this stack completed a 42-step Nemotron Omni video GRPO run through Megatron capture (see NVIDIA-NeMo/RL#4332). This revision has not had an end-to-end run yet. That needs a Megatron-Bridge pin carrying NVIDIA/Megatron-LM#7598. Draft until that is recorded. ## Compatibility Megatron capture requests with non-text content parts were rejected before this change. They are now admitted. Text-only calls are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Laura Dang <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Overview
This PR lets a training framework store large per-call payloads (today: the processed image/video tensors a VLM inference worker ran on) in the same durable write as the call's token record, so token capture for multimodal rollouts is acknowledged atomically. Gym stays engine- and tensor-blind: it forwards the payload, never inspects or digests it, and leaves storage, validation, and read-back to the framework (paired change: NVIDIA-NeMo/RL #4191).
Without this, a framework capturing VLM media had to write the token row through Gym and then write the pixels in a second store call, and reconcile the two at training time. With this,
stagedcoordinates mean "tokens and media are both durable", and a failed combined write surfaces ascapture_failedat call time.Net change against
main: 7 files, +255/-14. No new dependencies. No Megatron adapter or serving changes.What is added
1.
attachmentson the staging capture core (staging/capture.py)RolloutTokenCapture.complete_call(..., attachments: Mapping[str, Any] | None = None)andcomplete_call_from_response(call, response_payload, *, attachments=None)accept a keyword-only mapping and forward it to the sink.StagedCallRecord,extras, or any digest.digest,extras_digest, andCommitCoordsare byte-identical with or without them.stage(record)call shape, so every sink that exists today keeps working unchanged for text-only calls.TypeError) or rejects the bundle, the existing capture boundary reportscapture_failed. Gym never retries the write with the attachments dropped.2.
StagingSinkprotocol (staging/protocols.py)stage(self, record, *, attachments=None) -> StageResult, with the contract documented on the protocol: a sink that accepts the keyword must store every supplied attachment before returning success or reject the call; silently discarding attachments violates the protocol. Validation of tensor contents, layout, and read-back belong to the framework.3. vLLM adapter (
adapters/vllm.py)VLLMCaptureAdapter.extract_extrasnow also passes through amedia_spanslist from the response payload (validated as a list of objects) alongside the existingrouted_experts. These are small, JSON-native placeholder positions and token hashes the framework's worker needs to remap image/video placeholders when it reuses a captured prefix on the next turn. They ride the digest-covered extras; pixels do not.4. Docs and tests
model-call-capture.mdx: new "Framework-owned media staging" section describing the attachment contract.test_token_capture_staging_worker.py: legacystage(record)sink succeeds without the keyword; attachments reach the sink by identity; an explicit empty mapping is forwarded; absent attachments use the legacy call shape;TypeErroror explicit rejection yieldscapture_failedwith no fallback write; digests and coordinates are equal with and without attachments;complete_call_from_responseforwards attachments; adapter extras carrymedia_spansandrouted_expertsand never amediakey; malformedmedia_spansare rejected; the staging package exports no media-summary helpers.test_token_capture_integration.py,test_external_capture_streaming.py) migrated to the attachment-aware signature and assert no attachments arrive on text-only paths.Why this shape
An earlier iteration of this branch carried a digest-covered
mediageometry summary inextras(astaging/media.pymodule) so the framework could cross-check a separately written pixel store. Writing both in one sink call removes the divergence that summary guarded against, so that module and its exports are gone and the branch now adds only the attachment plumbing above. The framework validates the tensors it writes and reads.Compatibility
Validation
3884145, before themainmerge): 184 tests passing (test_token_capture_staging_worker,_core,_conformance,_rebuild,_routes, vLLMtest_token_capture_integration). After mergingmain(conflicts only instaging/capture.pyand the worker test):test_token_capture_staging_workerand_corepass locally (102 tests); a container re-run against the merged branch is in flight.fix(opencode): replay reasoning as reasoning_content on Gym model servers (4180)intor0.7.0#4191.string_match, vLLM generation, Megatron learner, 100 steps) with capture on via this branch (job 3884304) matches the capture-off baseline within run-to-run noise: reward 0.552 vs 0.546, step-wise reward correlation 0.943 (repeatability floor 0.952), zero staging failures, zero invalid rows. Details and W&B links in RL cp:fix(opencode): replay reasoning as reasoning_content on Gym model servers (4180)intor0.7.0#4191.🤖 Generated with Claude Code