fix(vllm_model): prefer inline token metadata over prompt tokenization - #1558
Merged
ananthsub merged 5 commits intoAug 18, 2026
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
|
lgtm if its working in benchmarks and training validation |
ananthsub
force-pushed
the
ansubramania/vllm-model-inline-prompt-token-ids
branch
from
July 20, 2026 21:28
83bf8e1 to
0898834
Compare
ananthsub
marked this pull request as ready for review
July 20, 2026 21:36
ananthsub
force-pushed
the
ansubramania/vllm-model-inline-prompt-token-ids
branch
from
August 13, 2026 14:48
0898834 to
f5e8354
Compare
This was referenced Aug 13, 2026
5 tasks
ananthsub
force-pushed
the
ansubramania/vllm-model-inline-prompt-token-ids
branch
2 times, most recently
from
August 18, 2026 15:39
f800c69 to
1dcb166
Compare
Prefer exact inline metadata while retaining a validated tokenization fallback for training integrations that do not return token IDs. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Use NeMo RL's message-level metadata by default while retaining standard inline IDs as an operator-enabled source and preserving the compatibility fallback. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Let hosted vLLM endpoints return prompt and generation IDs with the generation response while keeping the default payload free of duplicate token arrays. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Validate the selected training message once so long token sequences do not incur duplicate list scans and copies. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Keep the newly added implementation details after the public request handlers so the existing class API remains easy to scan. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
ananthsub
force-pushed
the
ansubramania/vllm-model-inline-prompt-token-ids
branch
from
August 18, 2026 19:47
1dcb166 to
aa5283b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
choice.messagewithout making a second/tokenizerequest.prompt_token_idsand choice-leveltoken_ids./tokenizefor integrations that return neither inline representation.nomitted or set to1).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
/tokenizerequest. That request adds inter-turn latency and can reproduce a different prompt when prompt-affecting inputs are omitted.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
choice.message.prompt_token_ids, choice-leveltoken_ids, andchoice.logprobsfrom the vLLM response.choice.logprobsand prompt IDs from/tokenize.request_prompt_and_generation_token_ids: trueenables the second source by sendingreturn_token_ids=trueto compatible vLLM endpoints. The option defaults tofalse. 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, andrequired_prefix_token_ids. This keeps fallback tokenization aligned with the generation prompt.prompt_logprobsis not requested. vLLM returns prompt IDs independently whenreturn_token_idsis enabled, and Gym does not consume prompt-token log probabilities.Related work
nvext.engine_datasource independently.