Repository navigation
feat(vllm_model): default template kwargs and Dynamo session affinity - #5161
Draft
jthomson04 wants to merge 5 commits into
Draft
jthomson04 wants to merge 5 commits into
jthomson04 wants to merge 5 commits into
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. |
jthomson04
added a commit
to jthomson04/RL
that referenced
this pull request
Oct 27, 2026
…ery Gym rollout Re-pins Gym to NVIDIA-NeMo/Gym#5161 (e6800bb), on top of Gym#4817, and uses it: - The native server's default chat template kwargs now go to Gym's new `default_chat_template_kwargs`, which Gym applies under every other source of template kwargs. Writing them into `chat_template_kwargs` overrode a Gym YAML's own kwargs through Gym's config merge, and dropped its `extra_body.chat_template_kwargs`, the opposite of the native server. - Gym sends `x-dynamo-session-id` on every Dynamo call, not only on token capture calls, so the frontend keeps each rollout on one engine; the engine splices the echoed prefix after routing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
jthomson04
force-pushed
the
jthomson04/dynamo-dialect-defaults-affinity
branch
3 times, most recently
from
October 29, 2026 21:54
aa808b7 to
05101d0
Compare
…andler
Let the vLLM model server talk straight to an ai-dynamo 1.5.1 frontend,
replacing NeMo RL's Dynamo token wrapper proxy. The frontend rejects
unknown top-level request fields and returns token data only under
nvext.engine_data, when nvext.extra_fields asks for it.
- VLLMModelConfig.dynamo_frontend: strip echoed per-message token fields
from requests and mark every request with the "nemo_gym:rollout"
annotation in nvext.annotations, so the engine can tell Gym rollout
traffic from the training framework's own requests. With
return_token_id_information, request engine_data and copy
nvext.engine_data.{prompt_token_ids, completion_token_ids,
completion_logprobs} onto the message token fields, failing clearly when
engine data is missing or the log probability count mismatches.
- token_id_capture.external_staging_backend "dynamo_worker": the
admission rides in nvext.annotations as "ng_capture:<admission JSON>",
no top-level ng_capture or required_prefix_token_ids and no logprobs are
sent, and the acknowledgement is lifted from
nvext.engine_data.ng_commit_coords.
- ExternalCaptureHandler.request_headers(), threaded through
NeMoGymAsyncOpenAI.create_chat_completion(extra_headers=...) on top of
default_headers. The Dynamo handler sets x-dynamo-session-id to the
rollout id, since Dynamo 1.5.1 router affinity is header-only.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
…pture vLLM's NeMo RL server splices the last echoed assistant turn's prompt_token_ids + generation_token_ids into each multi-turn prompt (required_prefix_token_ids). The Dynamo dialect strips those message fields because the frontend rejects them, so without capture a turn-2 prompt was a fresh re-render and could diverge from the tokens the model generated (e.g. Qwen3 dropping the empty think block). Without an external capture handler, carry that prefix in nvext.annotations as "ng_prefix:<JSON list>", for the engine to splice. Capture calls still resolve their prefix from staging. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
… lift R3 routes From the NeMo RL NVIDIA-NeMo#4905 review: - dynamo_frontend now rejects request_prompt_and_generation_token_ids: Gym sends return_token_ids for it, which the frontend refuses with a 400. - It also rejects reasoning_field: both when reasoning is echoed: the frontend reads `reasoning` as an alias of `reasoning_content` and 400s a message that carries both. - _lift_dynamo_engine_data copies routed_experts onto the message when the engine sends it (router replay on), as the native endpoint attaches it. - Comments name NeMo RL's engine, not Dynamo, as the engine_data producer. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
The token-capture block is global, so a judge such as local_vllm_model sees external_staging_backend=dynamo_worker too and failed at startup. Only a server that sets dynamo_frontend=true must pair with dynamo_worker; the error now names it. A judge never gets a capture context, so its handler stays idle. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
Add default_chat_template_kwargs, applied under every other source of chat_template_kwargs: the configured value, the request's own kwargs, metadata.chat_template_kwargs and extra_body. It covers the chat, completions-render and Responses-native paths. A training framework that writes its defaults into chat_template_kwargs replaces an environment's own kwargs, and because a body that carries chat_template_kwargs wins the shallow extra_body merge, it also drops extra_body.chat_template_kwargs. With dynamo_frontend, send x-dynamo-session-id on every chat call, not only on token-capture calls. It is keyed like the client choice: the rollout id, else the Gym session. The engine splices the echoed prefix after the router has picked it, so a rollout's later turns could reach an engine that does not cache its earlier ones. Capture calls keep their admission's rollout id. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
jthomson04
force-pushed
the
jthomson04/dynamo-dialect-defaults-affinity
branch
from
October 30, 2026 22:49
05101d0 to
b0fff97
Compare
This branch has not been deployed
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.
What
Two changes to
vllm_model, both follow-ups to the Dynamo frontend dialect in #4817.default_chat_template_kwargs: a new config field with the lowest precedence. Every other source ofchat_template_kwargsoverrides a key set here: the configuredchat_template_kwargs, the request's own kwargs (withforward_request_chat_template_kwargs),metadata.chat_template_kwargs, andextra_body. It is applied after theextra_body | bodymerge on the chat path and on the Responses-native path. In the completions-render path it is the base layer of the kwargs passed toapply_chat_template.dynamo_frontend: true, every chat call now sendsx-dynamo-session-id, not only token-capture calls. The value uses the same key_resolve_clientuses to pick an endpoint: the rollout id, else the Gym session. The key expression now lives in one_routing_session_idhelper that both use. A capture call keeps the header the capture handler sets (its admission's rollout id).Why
chat_template_kwargs. Gym's config merge (nemo_gym/global_config.py) then lets them override an environment YAML's ownchat_template_kwargs. Because a body that carrieschat_template_kwargswins the shallowextra_body | bodymerge, they also dropextra_body.chat_template_kwargs. Native vLLM does the opposite: request kwargs override the server's defaults. With this field, NeMo RL can supply its defaults without replacing the environment's kwargs.ng_prefix:annotation from feat(vllm_model): Dynamo frontend dialect and dynamo_worker capture handler #4817) only after the router has picked an engine. So the router can send a rollout's later turns to an engine that does not cache its earlier ones. Pinning each rollout to one engine keeps its turns together, as the capture path already does.No issue. This continues the Dynamo parity work in #4817 and NVIDIA-NeMo/RL#4905. The NeMo RL side, which writes the defaults into the new field and re-pins Gym, follows in a separate RL PR.
Compatibility
default_chat_template_kwargsdefaults tonull, so nothing changes until a caller sets it.dynamo_frontend: true, which feat(vllm_model): Dynamo frontend dialect and dynamo_worker capture handler #4817 introduces and nothing has released yet.Validation
pytest responses_api_models/vllm_model/tests/test_app.py: 402 passed. Run on Python 3.13.14, importingnemo_gymandresponses_api_modelsfrom this branch.app.py, except the capture case, which already sent the header:test_default_chat_template_kwargs_have_lowest_precedence(new): the configuredchat_template_kwargsandextra_body.chat_template_kwargseach win over a default, and a key that no other source sets keeps its default.test_chat_template_kwargs_merged_with_metadata_override(extended): the same precedence on the completions-render path.test_dynamo_frontend_dialect(extended): every case sendsx-dynamo-session-id, keyed on the session without capture and on the admission's rollout id with capture.pre-commit run --files <changed files>: passed.Rollout evidence
Not run yet. This PR changes only the request body and headers the model server builds, and the unit tests above check both. The end-to-end check is a NeMo RL GRPO run through Dynamo (NVIDIA-NeMo/RL#4905), once NeMo RL is re-pinned to this commit. Results will be added here.
🤖 Generated with Claude Code