Skip to content

feat(vllm): forward session IDs to upstream routers - #2347

Draft
NolenLiang wants to merge 3 commits into
NVIDIA-NeMo:mainfrom
NolenLiang:nliang/vllm-router-session-affinity
Draft

feat(vllm): forward session IDs to upstream routers#2347
NolenLiang wants to merge 3 commits into
NVIDIA-NeMo:mainfrom
NolenLiang:nliang/vllm-router-session-affinity

Conversation

@NolenLiang

@NolenLiang NolenLiang commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • add optional session-affinity header forwarding to the vLLM model configuration
  • optionally forward the stable NeMo Gym session ID in session_params.session_id for cache-aware routers that consume request-body identity
  • preserve existing default headers, other session_params fields, and session-to-client reuse
  • request and consume inline prompt/generation token IDs while retaining token-string and /tokenize fallbacks
  • expose attach_trajectory_record as the public integration point for callers that use run_examples directly

Motivation

When NeMo Gym sends requests through one upstream Router endpoint, its in-process session-to-client mapping does not by itself expose a stable session identity to that Router. Header forwarding supports consistent-hash routing, while the optional request-body field supports vLLM Router 0.1.15 cache-aware routing.

NeMo RL also uses Gym's low-level run_examples path. Exporting the existing trajectory attachment helper lets that caller fold captured model-call timing, token usage, response metadata, and observation gaps into the standard ng_trajectory result without duplicating Gym logic or relying on out-of-band state.

Compatibility

Session-affinity forwarding is opt-in, so existing configurations retain their previous request shape. Existing session_params fields are preserved. Invalid non-mapping values are rejected instead of being silently overwritten.

External audit provenance

The two incremental commits originally published as 9ad35b3 and f075ce8 were consolidated only to correct the Git author identity. The current commit 4d6b55a has:

  • author and committer: Nolen Liang <nliang@nvidia.com>
  • DCO sign-off: Nolen Liang <nliang@nvidia.com>
  • source tree: e0807bfc5c40cf282c07b33aa8178c124dda4e9f, exactly identical to the former f075ce8 tree

The parent NeMo RL Phase 2 matrix observed complete model-call timing for all six accepted formal runs using this source tree.

Testing

  • focused tests for header forwarding, request-body session identity, field preservation, invalid types, inline token IDs, and capture behavior
  • parent NeMo RL integration tests for cache-aware body forwarding and consistent-hash compatibility
  • Ruff check and format check for the modified Gym files
  • DCO check

@copy-pr-bot

copy-pr-bot Bot commented Aug 5, 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.

Signed-off-by: NolenLiang <nliang@nvidia.com>
Signed-off-by: NolenLiang <nliang@nvidia.com>
Forward stable session IDs in request bodies and attach model-call capture to rollout results for auditable router metrics.

Signed-off-by: Nolen Liang <nliang@nvidia.com>
@NolenLiang
NolenLiang force-pushed the nliang/vllm-router-session-affinity branch from f075ce8 to 4d6b55a Compare August 19, 2026 10:55
waple0820 added a commit to waple0820/Gym that referenced this pull request Sep 2, 2026
…rify

NVIDIA-NeMo#2114 landed the rollout correlation contract, but it is one-directional. The
training side learns nothing about the handle the environment actually allocated
— the container, the browser context, the provider session that consumed quota —
so a rollout record and a provider-side log can only be joined on a timestamp.

`env_session_id` is optional on both `BaseSeedSessionResponse` and
`BaseVerifyResponse`, opaque to Gym, and absent unless an environment reports one,
so nothing changes for an environment that does not.

This originally also added a `rollout_correlation_enabled` key so the rollout
prefix could reach resources servers without turning on model-call capture. NVIDIA-NeMo#2783
removes that need by making correlation independent of the observability gate
rather than adding a second flag, which is the better shape, so that half is
dropped here.

No training framework needs a transport change: verl and NeMo-RL already carry the
whole verify response as `full_result`.

Terminology: this is the environment session created by `/seed_session`, not the
vLLM router KV-cache affinity of NVIDIA-NeMo#2570 / NVIDIA-NeMo#2347 / NVIDIA-NeMo#2369.

Signed-off-by: waple0820 <232305951+waple0820@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant