Repository navigation
feat(video): support video inputs in vLLM responses - #2324
Conversation
5b7301d to
e9fd77c
Compare
There was a problem hiding this comment.
Thanks for adding the video path and native vLLM token IDs. This branch predates several Responses fixes on main, so it needs to be rebased while preserving the current schema and token-metadata implementations.
The main schema concern is the second content-list union:
flowchart LR
subgraph PR["Current PR"]
INPUT1["Responses content"] --> LISTS{"Choose a complete list type"}
LISTS --> SDK["SDK list - text · image · file"]
LISTS --> CUSTOM["Custom model list - text · image · video"]
CUSTOM --> COERCE["Existing dictionaries become Pydantic models"]
SDK --> MIX["Cannot mix input_file with video"]
end
subgraph TARGET["Recommended"]
INPUT2["Responses content"] --> ITEMS["One item-level union"]
ITEMS --> TEXT["SDK input_text"]
ITEMS --> IMAGE["SDK input_image"]
ITEMS --> FILE["SDK input_file"]
ITEMS --> VIDEO["Gym input_video"]
VIDEO --> VALIDATE["Validate exactly one URL"]
VALIDATE --> CHAT["Convert to canonical video_url"]
end
Video should extend one SDK item-level union rather than add another list type. This preserves the existing dictionary representation and allows standard parts such as input_file to coexist with video.
Token handling has two separate validation layers:
flowchart TD
REQUEST["Generation request"] --> VLLM["vLLM response"]
VLLM --> SOURCE{"Native prompt and generation IDs present?"}
SOURCE -->|Both| NATIVE["Use complete native bundle"]
SOURCE -->|Neither| FALLBACK["Compatibility fallback"]
SOURCE -->|Only one| PARTIAL["Reject or use an explicit partial-response policy"]
FALLBACK --> EQUIV{"Can /tokenize reproduce every prompt-affecting field?"}
EQUIV -->|No| FAIL["Require native prompt IDs"]
EQUIV -->|Yes| TOKENIZE["Tokenize with all shared fields"]
NATIVE --> ADAPTER["vLLM adapter validation source policy and lengths"]
TOKENIZE --> ADAPTER
ADAPTER --> MAIN["Existing main validation from #2488 required fields are atomic, types are valid, empty arrays remain valid"]
MAIN --> TRAINING["Training message"]
TRAINING --> RESET["Clear metadata after the turn"]
#2488 now provides bundle validation and per-turn state clearing. The generic token-metadata propagation logic in this PR should be dropped during the rebase.
The generation ID and log-probability length check added here is provider-level validation and should remain with the vLLM token change. The remaining adapter cases are:
- partial native prompt/generation ID responses;
- prompt-affecting fields omitted from
/tokenize; - invalid token-source configuration.
It would be helpful to split the remaining work into separate PRs:
- Responses and Chat video schemas together with video conversion.
- vLLM native token IDs, fallback tokenization, and provider-level validation.
- CLI
PYTHONPATHprecedence.
e9fd77c to
d31df71
Compare
|
@ananthsub Thanks for the detailed review. I addressed all your comments in 5b8f04b:
All 15 Gym CI checks are green. Could you please take another look? |
#1558) ## Summary - Consume a complete token bundle from `choice.message` without making a second `/tokenize` request. - Support opt-in vLLM response token IDs for endpoints that return top-level `prompt_token_ids` and choice-level `token_ids`. - Retain `/tokenize` for integrations that return neither inline representation. - Reject partial or conflicting sources. Token capture supports one completion choice per request (`n` omitted or set to `1`). ## Why Gym needs the prompt token IDs, generated token IDs, and selected-token log probabilities used during generation. The previous adapter reconstructed prompt IDs through a second awaited `/tokenize` request. That request adds inter-turn latency and can reproduce a different prompt when prompt-affecting inputs are omitted. NeMo RL [#3390](NVIDIA-NeMo/RL#3390) attaches the token bundle to the assistant message. Gym reads that bundle directly and does not request duplicate response-level IDs by default. Gym cannot require that message shape from every training integration. Other integrations, including Verl, can request vLLM's response token IDs or continue using the compatibility fallback. ## Source precedence 1. A complete token bundle on `choice.message`. 2. Top-level `prompt_token_ids`, choice-level `token_ids`, and `choice.logprobs` from the vLLM response. 3. Generation metadata from `choice.logprobs` and prompt IDs from `/tokenize`. `request_prompt_and_generation_token_ids: true` enables the second source by sending `return_token_ids=true` to compatible vLLM endpoints. The option defaults to `false`. If both inline sources are present, their token IDs must agree. The selected training message is validated once to avoid repeated list scans and copies at long sequence lengths. The fallback forwards `model`, `messages`, `tools`, `chat_template_kwargs`, `mm_processor_kwargs`, and `required_prefix_token_ids`. This keeps fallback tokenization aligned with the generation prompt. `prompt_logprobs` is not requested. vLLM returns prompt IDs independently when `return_token_ids` is enabled, and Gym does not consume prompt-token log probabilities. ## Related work - Gym [#700](#700) is superseded by this change. - Gym [#2576](#2576) is superseded by this change. - NeMo RL [#3390](NVIDIA-NeMo/RL#3390) produces the message-level token bundle consumed by the first source. - NeMo RL [#3581](NVIDIA-NeMo/RL#3581) reuses replayed token metadata across turns. - Gym [#1784](#1784) can add the Dynamo `nvext.engine_data` source independently. - Gym [#2324](#2324) can retain its video-specific schema, conversion, and adapter behavior independently. --------- Signed-off-by: Ananth Subramaniam <[email protected]>
5b8f04b to
dc23f91
Compare
|
@ananthsub Rebased this PR onto the latest upstream Local validation passed: 216 focused unit tests plus Ruff checks. All CI checks passed on |
Signed-off-by: Ehsan Hosseini Asl <[email protected]>
Signed-off-by: Ehsan Hosseini Asl <[email protected]>
dc23f91 to
890b30a
Compare
Address all actionable review comments for PR #3648. - centralize image, video, and audio content aliases across preprocessing - validate cached frames as one video source and normalize local image aliases - align Nemotron Omni tubelet placeholders and timestamps with vLLM metadata - materialize one strict frame-sampling contract for rollout and policy paths - reattach deduplicated media to sync and async Gym message logs consistently - remove obsolete optional-epoch handling from SingleController step clamping - document video runtime, cache, epoch, and raw-TMPE contracts - add focused config, media, vLLM, and executable 2n/16n regression coverage - pin Gym to merged video Responses API integration NVIDIA-NeMo/Gym#2324 Signed-off-by: Ehsan Hosseini Asl <[email protected]>
Address all actionable review comments for PR #3648. - centralize image, video, and audio content aliases across preprocessing - validate cached frames as one video source and normalize local image aliases - align Nemotron Omni tubelet placeholders and timestamps with vLLM metadata - materialize one strict frame-sampling contract for rollout and policy paths - keep cached-frame policy timestamps identical to the vLLM synthetic timeline - reattach deduplicated media to sync and async Gym message logs consistently - remove obsolete optional-epoch handling from SingleController step clamping - document video runtime, cache, epoch, and raw-TMPE contracts - add focused config, media, vLLM, and executable 2n/16n regression coverage - pin Gym to merged video Responses API integration NVIDIA-NeMo/Gym#2324 Signed-off-by: Ehsan Hosseini Asl <[email protected]>
Summary
Add video-input support to the NeMo Gym Responses API and vLLM model backend for multimodal RL training.
input_videoandvideo_urlcontent parts.Motivation
Video GRPO requires Gym to preserve video content and the exact prompt and generation tokenization used by vLLM.
Using token IDs produced by a separate or differently configured tokenization request can cause rollout and policy log probabilities to reference different token sequences, resulting in
incorrect training data and elevated TMPE.
Validation
input_videoandvideo_urlconversion.Dependencies
None.
Related integrations
feat(video): enable canonical Nemotron Omni training for V2 MoE checkpointsfeat(video): add Gym support for sync and async GRPO