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.
dynamo: true is rejected at startup in this PR.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.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.
| Class | Runs in | What it does |
|---|---|---|
VllmGeneration | driver (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. |
VllmAsyncGenerationWorkerImpl | Ray actor, one per shard | Owns 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. |
NeMoRLOpenAIServingChat | worker, server thread | vLLM'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. |
GenerationRouterImpl | its own Ray actor | Reverse proxy for Gym only. Forwards to the same worker servers as lane B; it does not call the engine itself. |
NativeVllmEngine | worker, engine loop | Adapter 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. |
ManagedDynamoRuntime | driver | Starts and stops etcd, NATS and the Dynamo frontend as subprocesses. |
| Lane | URLs the caller holds | HTTP servers on the path | Who picks the shard | Does turn 2 land where turn 1's prompt is cached? |
|---|---|---|---|---|
| A · native rollout | none | none (Ray) | driver, round-robin | No. 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 worker | Dynamo KV router, most cached prompt | Yes, 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 worker | Dynamo KV router, plus a session pin | Yes, 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 native | N worker URLs | N worker FastAPI servers | Gym, hash of rollout id | Yes, 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 + router | 1 router URL | router, then 1 of N worker servers | router, fewest in-flight | No. 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). |
NativeVllmEngine to serve Gym's chat calls. The author split it out because it needs a Gym change too. (#4979's own page.)NativeVllmEngine inside the worker over its own TCP channel, and the worker's FastAPI server is not on that path.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.