Repository navigation
feat(vllm-model): forward gym session id as backend conversation id - #3582
Conversation
Expose the Gym rollout session as the vLLM backend's conversation_params.conversation_id so a disaggregated serving setup can pin every turn of a conversation to the ADP rank holding its KV-cache prefix (conversation/rank affinity). Source: gitlab-master.nvidia.com/dl/mlperf/optimized qwen35_397b_grpo_trtllm patch patches/gym/conversation-affinity.patch Signed-off-by: shuyixiong <[email protected]>
Add coverage for the conversation-affinity change in the prior commit: asserts conversation_params.conversation_id is set from the Gym session id. Signed-off-by: shuyixiong <[email protected]>
trtllm_http_server reads a conversation id that nothing populates today. Gym is the only component that knows the rollout identity and no released Gym sends it -- conversation_params appears nowhere in the tree, including upstream main. It arrives with NVIDIA-NeMo/Gym#3582 ("forward gym session id as backend conversation id"), still open, after which the Gym submodule pin has to be bumped for this branch to see an id at all. Until then a turn lands on an effectively random attention-DP rank and the context engine re-prefills most of its history: 17-26% of turns find their prefix on the serving rank versus 96-97% once the id flows, measured at 2P-DEP8 / conc 512. Nothing fails, so the note also says not to treat such a run as a disaggregation baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: shuyixiong <[email protected]>
|
/ok to test 2f9f0bd |
| # as the backend's canonical conversation id so a disaggregated server can | ||
| # pin every turn of a conversation to the ADP rank holding its prefix. | ||
| _session_id = request.session.get(SESSION_ID_KEY) | ||
| if _session_id and not body_dict.get("conversation_params"): |
There was a problem hiding this comment.
Could we make this opt-in? Gym's session middleware assigns a session ID to every request, so this currently adds the TensorRT-LLM-specific conversation_params extension to every vllm_model chat request. It is not part of the OpenAI Chat Completions schema, and strict OpenAI-compatible backends may reject it.
For example, add a disabled-by-default config field:
# VLLMModelConfig
forward_session_id_as_conversation_id: bool = FalseThen gate the injection while preserving explicitly configured conversation_params:
if self.config.forward_session_id_as_conversation_id:
session_id = request.session.get(SESSION_ID_KEY)
if session_id and not body_dict.get("conversation_params"):
body_dict["conversation_params"] = {
"conversation_id": str(session_id)
}NeMo RL TRT-LLM deployments can enable it in their Gym model configuration:
policy_model:
responses_api_models:
vllm_model:
forward_session_id_as_conversation_id: true…nfig conversation_params is a TensorRT-LLM extension outside the OpenAI Chat Completions schema, and Gym's session middleware assigns a session id to every request, so the previous unconditional injection sent a non-standard field on every vllm_model chat request. Strict OpenAI-compatible backends reject it. Add VLLMModelConfig.forward_session_id_as_conversation_id (default False) and gate the injection on it. Deployments that route on conversation/rank affinity opt in via their Gym model config. When enabled, the session id is authoritative and replaces any conversation_params merged in from extra_body, matching the config-decides-it precedent of sampling_overrides. Cover both paths in the existing test via parametrize: enabled forwards the session id, disabled sends no conversation_params at all. Addresses review feedback on NVIDIA-NeMo#3582. Signed-off-by: shuyixiong <[email protected]>
|
/ok to test 59ad82d |
|
/ok to test 59ad82d |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36573935254 |
trtllm_http_server reads a conversation id that nothing populates today. Gym is the only component that knows the rollout identity and no released Gym sends it -- conversation_params appears nowhere in the tree, including upstream main. It arrives with NVIDIA-NeMo/Gym#3582 ("forward gym session id as backend conversation id"), still open, after which the Gym submodule pin has to be bumped for this branch to see an id at all. Until then a turn lands on an effectively random attention-DP rank and the context engine re-prefills most of its history: 17-26% of turns find their prefix on the serving rank versus 96-97% once the id flows, measured at 2P-DEP8 / conc 512. Nothing fails, so the note also says not to treat such a run as a disaggregation baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: shuyixiong <[email protected]>
trtllm_http_server reads a conversation id that nothing populates today. Gym is the only component that knows the rollout identity and no released Gym sends it -- conversation_params appears nowhere in the tree, including upstream main. It arrives with NVIDIA-NeMo/Gym#3582 ("forward gym session id as backend conversation id"), still open, after which the Gym submodule pin has to be bumped for this branch to see an id at all. Until then a turn lands on an effectively random attention-DP rank and the context engine re-prefills most of its history: 17-26% of turns find their prefix on the serving rank versus 96-97% once the id flows, measured at 2P-DEP8 / conc 512. Nothing fails, so the note also says not to treat such a run as a disaggregation baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: shuyixiong <[email protected]>
trtllm_http_server reads a conversation id that nothing populates today. Gym is the only component that knows the rollout identity and no released Gym sends it -- conversation_params appears nowhere in the tree, including upstream main. It arrives with NVIDIA-NeMo/Gym#3582 ("forward gym session id as backend conversation id"), still open, after which the Gym submodule pin has to be bumped for this branch to see an id at all. Until then a turn lands on an effectively random attention-DP rank and the context engine re-prefills most of its history: 17-26% of turns find their prefix on the serving rank versus 96-97% once the id flows, measured at 2P-DEP8 / conc 512. Nothing fails, so the note also says not to treat such a run as a disaggregation baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: shuyixiong <[email protected]>
Replace the unmerged Gym session_id_header fork with Gym main's forward_session_id_as_conversation_id (NVIDIA-NeMo/Gym#3582). - Pin Gym to 75bb53e6d494437d616019040f22a9df7dcacd26 and relock. - For the Dynamo backend, setup_nemo_gym_config enables forward_session_id_as_conversation_id on policy_model's vllm_model. - The Dynamo token wrapper reads conversation_params.conversation_id, sends it as X-Dynamo-Session-ID, and strips conversation_params from the forwarded body, which Dynamo's frontend rejects as unsupported. - Malformed conversation_params return 400. The incoming X-Dynamo-Session-ID header is no longer read. - Build the wrapper's FastAPI app in _build_app so the handler can be tested without binding a port. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
trtllm_http_server reads a conversation id that nothing populates today. Gym is the only component that knows the rollout identity and no released Gym sends it -- conversation_params appears nowhere in the tree, including upstream main. It arrives with NVIDIA-NeMo/Gym#3582 ("forward gym session id as backend conversation id"), still open, after which the Gym submodule pin has to be bumped for this branch to see an id at all. Until then a turn lands on an effectively random attention-DP rank and the context engine re-prefills most of its history: 17-26% of turns find their prefix on the serving rank versus 96-97% once the id flows, measured at 2P-DEP8 / conc 512. Nothing fails, so the note also says not to treat such a run as a disaggregation baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: shuyixiong <[email protected]>
What does this PR do?
Forward the Gym rollout session id to the vLLM backend as
conversation_params.conversation_id,so a disaggregated serving setup can pin every turn of a conversation to the ADP rank holding its
KV-cache prefix (conversation/rank affinity).
Validation
test_chat_completions_forwards_session_id_as_conversation_idinresponses_api_models/vllm_model/tests/test_app.py, assertingconversation_paramsisforwarded from the Gym session id.
uv/venv). To validate:gym env test --resources-server vllm_modelorpytest responses_api_models/vllm_model/tests/test_app.py -k conversation_id.pre-commit run --files responses_api_models/vllm_model/**/*not yet run.Rollouts
N/A — this only changes an outbound request field/header on the model server; no live
disaggregated-backend rollout has been run against it yet.
Compatibility and benchmark impact
Additive/backward-compatible: only sets
conversation_paramswhen a Gym session id is presentand no such field was already forwarded (see known limitation above). No benchmark results
affected.
Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).