Skip to content

Compatibility with inference other than vllm < 0.10.2 - #700

Closed
tdene wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tdene:tde/new_vllm_compat
Closed

Compatibility with inference other than vllm < 0.10.2#700
tdene wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tdene:tde/new_vllm_compat

Conversation

@tdene

@tdene tdene commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

Inside vllm_model/app.py, there is a comment bloc that says:

       """
       START TODO remove this when NeMo RL upgrades to vLLM 0.10.2 support for prompt token ids
       """

The associated code always assumes that the user is using vLLM < 0.10.2. This removes that assumption, allowing NeMo Gym to work easily with vLLM >= 0.10.2 or any other inference framework.

@copy-pr-bot

copy-pr-bot Bot commented Feb 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@tdene
tdene marked this pull request as draft February 15, 2026 21:57
@tdene
tdene force-pushed the tde/new_vllm_compat branch from 9d30e72 to 94afba2 Compare February 15, 2026 23:01
@tdene
tdene marked this pull request as ready for review February 15, 2026 23:01
@tdene
tdene force-pushed the tde/new_vllm_compat branch from 94afba2 to 111ef6b Compare February 15, 2026 23:08
@tdene
tdene force-pushed the tde/new_vllm_compat branch from 08a7db2 to 6e604e2 Compare March 31, 2026 19:48
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
@tdene
tdene force-pushed the tde/new_vllm_compat branch from 6e604e2 to af3ebae Compare March 31, 2026 19:49
@tdene
tdene requested a review from bxyu-nvidia March 31, 2026 20:01
@tdene tdene mentioned this pull request Apr 27, 2026
tdene added a commit to tdene/Gym that referenced this pull request Apr 27, 2026
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
tdene added a commit to tdene/Gym that referenced this pull request Apr 27, 2026
Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
bxyu-nvidia pushed a commit that referenced this pull request Apr 27, 2026
This is a simpler, but less-complete, version of #700

While #700 addresses the `TODO`, this PR merely works around it.

Signed-off-by: Teodor-Dumitru Ene <teodord.ene@gmail.com>
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Jul 17, 2026
@tdene tdene closed this Aug 14, 2026
ananthsub added a commit that referenced this pull request Aug 18, 2026
#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 <ansubramania@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant