How a generation request reaches vLLM: native, native with the router, and Dynamo

NVIDIA-NeMo/RL #4905 and the PR stacked on it, #4979 (with NVIDIA-NeMo/Gym#4817). Permalinks pin #4905 44671d3b, #4979 c4fe2bd5, Gym 5911d628.

Nine pages on this stack (#4905, #4979 and #5115), one question each. This one: which classes and servers each request passes through, including the next PR in the stack.

Today (main)
Three ways in. NeMo RL's own rollouts reach the worker by a Ray call (A). NeMo-Gym reaches it over HTTP, either straight to each worker (B) or through NeMo RL's router (C).
#4905
Adds lane D: NeMo RL's own rollouts can go through Dynamo instead of the Ray call. Gym with dynamo: true is rejected at startup in this PR.
#4979
The next PR in the stack. Adds lane E: Gym through Dynamo, and lifts that rejection. It needs a matching Gym change (Gym#4817).
Status
Both in review, not merged. #4979's base branch is #4905's branch.
Background. Each data-parallel shard runs one Ray actor, VllmAsyncGenerationWorker, which owns one vLLM AsyncLLM engine. Every lane below is a different door into that same engine. N is the number of shards. A NeMo RL rollout is the training loop's own token-in, token-out call; a NeMo-Gym call is an OpenAI-style chat request from Gym's environment servers. Dotted words have a short explanation: hover or tap them.

Five ways in, one engine

A · NeMo RL rollout, native D · NeMo RL rollout, Dynamo E · NeMo-Gym, Dynamo B · NeMo-Gym, native C · NeMo-Gym + router no HTTP at all new in #4905 next PR, #4979 Gym gets N URLs Gym gets 1 URL Driver: VllmGeneration generate_async(input_ids [1 prompt, P tokens]) vllm_generation.py:1486 Driver: VllmGeneration POST frontend/v1/completions {prompt:[t0..tP-1], tag} _generate_through_dynamo Gym's vllm_model server POST frontend/v1/chat/… {messages, tools} + tag _apply_dynamo_dialect Gym's vllm_model server POST /v1/chat/completions {messages, tools} Gym's vllm_model server same request as B, sent to the router's 1 URL Driver picks shard k round-robin over N (or the fleet selector) _next_dp_shard_idx · :1362 Dynamo frontend (Rust) KV router picks shard k by cached prompt blocks managed_runtime.py:53 Same Dynamo frontend renders the chat template, then KV router picks k Gym gets this 1 URL · :750 Gym picks 1 of N URLs sha256(rollout id) % N, same URL every turn Gym _resolve_client GenerationRouter actor aiohttp proxy holding N URLs; least in-flight wins generation_router.py:183 Ray actor call worker_k.generate_async.remote Dynamo request plane (TCP) not HTTP; found via etcd Dynamo request plane (TCP) token ids, not messages HTTP to worker k http://node:port/v1/chat/… HTTP to worker k router streams reply back One vLLM worker process · Ray actor VllmAsyncGenerationWorker · ×N, one per shard Engine event loop (the Ray actor's own loop) HTTP server thread (uvicorn), only if expose_http_server generate_async Ray entry (lane A) vllm_worker_async.py:2112 NativeVllmEngine ._generate_rollout (D) native_engine.py:183 NativeVllmEngine ._generate_gym (E) #4979 native_engine.py:492 _serve_rollout(TokensPrompt([t0..tP-1])) token budget, sampling from the generation config vllm_worker_async.py:2059 same code for A and D tag nemo_gym:rollout → on-policy sampling check, prefix splice, then capture FastAPI app built by NeMo RL (not vllm serve) /v1/chat/completions · /tokenize · /health NeMoRLOpenAIServingChat vLLM's OpenAIServingChat + NeMo RL mixins: chat template, prefix splice, token capture :1613 _AsyncLLMHTTPClient hands each call to the engine loop :151 worker._begin_request_capture → token capture E calls the same capture code as B and C's chat server vllm_worker_async.py:808 chat server call · :1381 E's call · :624 vLLM AsyncLLM (self.llm): the one engine every lane ends in AsyncLLM.generate → generated token ids [G] + log-probs [G] vllm_worker_async.py:472 shared by lanes new in #4905 new in #4979 (next PR) HTTP into the worker caller or routing step

A and D meet at _serve_rollout, so a NeMo RL rollout is sampled the same way either way. B and C meet at the worker's HTTP server. E, Gym through Dynamo, skips that server: the Dynamo frontend renders the chat template, and NativeVllmEngine redoes on token ids what the server's chat route does on messages. It then calls the same token-capture code.

Classes, URLs, and keeping a rollout on one worker

ClassRuns inWhat it does
VllmGenerationdriver (training loop)The handle training calls. Owns the N worker actors. Hands Gym its URL list: the N worker URLs, or with Dynamo in #4979 the one frontend URL (client_base_urls). Per rollout, _dynamo_serves picks lane D (Dynamo on, no images) or lane A. _generate_through_dynamo is an HTTP client, not a server.
VllmAsyncGenerationWorkerImplRay actor, one per shardOwns AsyncLLM. Has the Ray entry generate_async, the shared _serve_rollout, token capture, the optional HTTP server, and (new in #4905) start_dynamo_endpoint_async.
NeMoRLOpenAIServingChatworker, server threadvLLM's own chat handler class, subclassed with NeMo RL mixins. NeMo RL builds the FastAPI app and adds the routes itself (_setup_vllm_server); vLLM's vllm serve process is not used.
GenerationRouterImplits own Ray actorReverse proxy for Gym only. Forwards to the same worker servers as lane B; it does not call the engine itself.
NativeVllmEngineworker, engine loopAdapter for Dynamo's LLMEngine interface, holding the worker. Dynamo's Worker runs it on the actor's loop and registers it in etcd. It reads each request's tag: nemo_rl:rollout → _serve_rollout (#4905); nemo_gym:rollout → _generate_gym (#4979). In #4905 any other request is refused.
ManagedDynamoRuntimedriverStarts and stops etcd, NATS and the Dynamo frontend as subprocesses.
LaneURLs the caller holdsHTTP servers on the pathWho picks the shardDoes turn 2 land where turn 1's prompt is cached?
A · native rolloutnonenone (Ray)driver, round-robinNo. Every call takes the next shard, so a later turn usually lands on a shard that must recompute the whole history.
D · Dynamo rollout (#4905)1 frontend URL (driver)Dynamo frontend; then TCP to the workerDynamo KV router, most cached promptYes, with no session key. The router sees the prompt's token blocks and sends the call to the shard that already holds most of them, weighed against load. A later turn's prompt starts with the earlier turn, so it follows that cache, and the repeated samples of one prompt tend to land together.
E · Gym via Dynamo (#4979)1 frontend URL (Gym)Dynamo frontend; then TCP to the workerDynamo KV router, plus a session pinYes, with a session pin. The engine swaps Gym's staged prefix in after routing, so the router cannot see where it is cached. Gym names the session on token-capture calls, and the frontend keeps it on one engine for 300 s idle (session_affinity_ttl_secs).
B · Gym nativeN worker URLsN worker FastAPI serversGym, hash of rollout idYes, by hash. sha256(rollout id) % N sends every turn of a rollout to the same worker (_resolve_client). Different rollouts of the same prompt hash to different workers.
C · Gym + router1 router URLrouter, then 1 of N worker serversrouter, fewest in-flightNo. Each request goes to the least busy worker, with no session key. The router's own docstring names this as the trade-off (generation_router.py:40).

Short answers

So what. All five lanes end in the same AsyncLLM, so refit and pause behave the same for every caller. Dynamo changes two things: who picks the shard (cached prompt blocks instead of round-robin or a hash) and how the request gets there (HTTP to the frontend, then TCP, instead of a Ray call or HTTP to the worker). For NeMo RL's own multi-turn rollouts, D is the first lane that aims a later turn at the shard holding its earlier turns; A reuses that cache only when round-robin happens to land there. The extra hop is the cost the #4905 review asks the author to measure.