Dynamo serving for vLLM generation#
SingleController runs (examples/run_grpo_single_controller.py) with non-colocated vLLM generation can serve their rollouts through Dynamo’s OpenAI frontend and KV-aware router. Add one line:
policy:
generation:
backend: vllm
dynamo: true
The same NeMo RL vLLM workers run the same engines, with the same refit transports, pause and resume, quantization, speculative decoding and metrics.
Each engine also registers with a managed dynamo.frontend, and NeMo RL’s own rollouts (generate_async) go through that frontend, so each request lands on the engine that already holds most of its prompt’s KV cache. The few settings Dynamo cannot serve fail at startup; see Not supported.
See the Dynamo integration design for how the engines are hosted and why Dynamo upgrades and vLLM bumps stay independent.
What happens at startup#
With dynamo: true:
vllm_cfg.async_engineis turned on, because Dynamo drives the engine’sAsyncLLM. Settings Dynamo does not serve are rejected at startup; see Not supported.The driver starts etcd and NATS. Each
dynamo.frontendruns on a generation node, from a small Ray actor, in the vLLM workers’ own venv, so it is the same ai-dynamo release.Each engine turns on vLLM’s KV-cache events for
router_mode: kvand registers with the frontends from inside its own worker process. Setup waits until every frontend routes to every engine.With NeMo-Gym (
vllm_cfg.expose_http_server: true), each frontend starts its render workers at launch and builds them while the engines load, from the settings one engine sends before it loads. Gym’s first calls then do not wait for them. Other runs start none.vLLM publishes KV-cache events only for blocks its prefix cache stores. With
vllm_cfg.enable_prefix_caching: false, the engines publish none, and the KV router routes on load alone.Shutdown stops the services after the engines.
Configure#
dynamo: true is a complete configuration. policy.generation.dynamo_cfg only tunes the frontend and registration. Its fields and defaults live in nemo_rl/models/generation/dynamo/config.py, and examples/configs/grpo_math_1B_dynamo_single_controller.yaml shows them all:
Key |
Default |
Meaning |
|---|---|---|
|
600 |
Bounds service start-up and engine registration |
|
null |
Deadline for one NeMo RL rollout through the frontend. null waits as long as generation takes, as native does; on the SingleController, |
|
|
Frontend routing policy |
|
300 |
Keeps a NeMo-Gym token-capture rollout on one engine while it is idle for up to this many seconds; null disables it |
|
16,777,216 |
Most sessions the frontends hold at once, across all of them; a new one past it gets HTTP 529. Entries are allocated as sessions start, so a high cap costs nothing until it is used |
|
1 |
Frontends, each with its own router, spread round-robin over the generation nodes. More than one adds |
|
8 |
Processes in each frontend that render NeMo-Gym’s chat calls and build their replies; every Gym call that frontend serves shares them. Each holds its own tokenizer and processor, about 1.7–2.3 GB. On one Grace core of a GB200, one serves about 640 single-turn calls/s, 45 for a 21K-token agentic history (22 with its prefix splice), or 200 with 1–4 images |
|
|
Extra |
|
|
Extra frontend environment, for settings Dynamo reads only from the environment, such as |
With vllm_cfg.enable_vllm_metrics_logger on, the SingleController’s telemetry also logs rollout/throughput/dynamo_frontend_requests_queued and rollout/throughput/dynamo_frontend_requests_inflight: the calls waiting in the frontends for their first response and the calls in flight, summed over the frontends. Each frontend’s own counts are logged as rollout/throughput/dynamo_frontend_<i>_requests_queued and ..._inflight, where <i> is the frontend’s place in the [Dynamo] frontends, by index line of the driver log. A call that waits in a frontend is in no engine’s vLLM metrics.
With telemetry.vllm_native_tracing on, NeMo RL also turns on Dynamo’s trace export (OTEL_EXPORT_ENABLED) in the frontends and the vLLM workers. vLLM’s request span then joins the trace of the frontend’s request span, and Dynamo exports its own frontend and engine spans to the same collector, which it reads from the same OTEL_EXPORTER_OTLP_* variables. The frontend continues the caller’s trace only when it accepts the call’s traceparent: Dynamo 1.8.0.dev20261117 ignores one whose trace flags are 03, which NeMo-Gym sends, and starts a new trace (ai-dynamo/dynamo#19106).
The etcd and nats-server binaries are found in NEMO_RL_DYNAMO_BIN_DIR when it is set (the image sets it to /opt/dynamo/bin), and on PATH otherwise.
Which requests go through the frontend#
Request |
Path |
|---|---|
|
Frontend (KV-aware); the engine samples and assembles it exactly as native |
NeMo RL’s own multimodal rollouts |
Native shard dispatch. Those rollouts send media to the engine directly rather than as OpenAI content |
|
Native shard dispatch |
NeMo-Gym’s chat calls |
Frontend, rendered by NeMo RL’s chat engine with the native server’s code. See NeMo-Gym |
A rollout through the frontend has the same GenerationOutputSpec as the native path: token IDs, log probabilities, truncation, routed experts with their r3_routed_experts_* counts, and gen_leader_worker_idx. Both paths build it with nemo_rl/models/generation/vllm/request_pipeline.py.
NeMo-Gym#
NeMo-Gym’s policy model calls the frontend. Setup turns on Gym’s Dynamo dialect (dynamo_frontend in Gym’s vllm_model config). The frontend takes only OpenAI fields plus nvext, so Gym sends the native request’s extra fields (ng_capture, required_prefix_token_ids), and ng_measure for the measure call it makes in place of /tokenize, in one nemo_rl:gym: annotation, and reads the call’s token fields (prompt_token_ids, generation_token_ids, generation_log_probs, routed_experts, ng_commit_coords) from nvext.nemo_rl.
The frontend serves chat with NeMo RL’s chat engine instead of Dynamo’s own renderer and parsers (it is the frontend’s custom chat processor). Each call takes the native server’s steps, with the native server’s code:
In the frontend, a render-pool process renders the call with the engine’s own tokenizer, template, processor and
vllm_cfgchat settings (parser plugins included), which each engine publishes when it registers. It also decides how a token-capture call’s prefix is served.The chat engine checks on-policy sampling, reads a captured prefix from TQ, splices the prefix into the render, clamps the output budget to the context, and routes the final token IDs through the KV router.
On the engine, the adapter snapshots the call’s media, begins its capture, generates with the
SamplingParamsthe native server builds, and stages the call in one TQ write. Only the commit coordinates travel back.A render-pool process builds the reply with vLLM’s reasoning and tool parsers.
tests/unit/models/generation/test_gym_chat_path.py sends the same calls down both paths and checks they run the same prompt and SamplingParams, stage the same record and return the same reply.
Where the behavior differs from the native endpoint:
The frontend refuses more than 32
stopstrings or 32stop_token_ids, and vLLM request fields its own request type lacks (for examplestructured_outputs,return_token_ids,truncate_prompt_tokens,priority,chat_template), with HTTP 400.gpt-oss (Harmony) chat calls are refused with HTTP 400.
A call that streams (
stream: true) or asks for more than one choice (n) is refused with HTTP 400. The native endpoint serves both, and fails the capture of a streamed token-capture call. NeMo-Gym sends neither.A call refused with a status other than 400 (a full queue’s 503, for example) is answered with that status and the status’s standard text. The engine’s own message is only in the frontend’s log. A 400 keeps its message, and a refused token-capture call is acknowledged in the
x-ng-capture-refusedheader, both as on the native endpoint.A call’s processed media travels to the engine inside the request.
A call NeMo-Gym marks as untrained, such as an LLM judge’s on the policy model, keeps its own sampling on the native endpoint, which reads the mark from the
x-ng-sampling: nullheader. Dynamo’s frontend does not forward that header, so NeMo RL’s chat engine reads the mark from thenemo_rl:gym:annotation (ng_sampling). The pinned NeMo-Gym does not send it there yet: until it does, such a call is refused with HTTP 400 unless it matches the training or validation sampling. Give a judge that samples differently a model server of its own.
Rollout recovery#
rollout_recovery.target_level: turn and prefix work through Dynamo with no extra setting. With prefix, NeMo-Gym asks the generation backend to cut its running calls at each checkpoint, and re-sends each cut call after a restore.
Two things differ from the native endpoint:
Where the cut goes. Gym sends the cut beside the URL its calls go to, which is a frontend, but the calls run in the engines. Each frontend takes the cut on its own port, as a Dynamo route extension, and sends it to every engine over Dynamo’s request plane; each engine cuts the calls it holds, up to that frontend’s deadline (
token_capture.control_timeout_sfrom the cut’s arrival there). A frontend runs at most 64 cuts at once, Dynamo’s limit for one route, and refuses a further one with HTTP 529. Every worker process of a Gym policy-model server (itsnum_workers, in every shard and replica) sends its own cut to each frontend that holds its calls, so a frontend gets that many cuts at one checkpoint, whatevernum_frontendsis; past 64, the calls of the refused workers regenerate after a restore.What the router sees for a resumed call. The engine replaces the prompt the frontend sent with the call’s saved tokens and generates the rest, and the frontend puts the saved text back in front of the reply. So the KV router scores that one call on a prompt without the saved tokens. A cut the engine cannot use is dropped and the call regenerates, as natively.
Not supported#
Startup rejects these with dynamo: true:
colocated.enabled: true: a colocated engine sleeps while the policy trains, and the frontend would keep routing to it.async_rl.generation_fleet_health.enabled: the frontend picks engines itself, and a restarted shard does not register with it yet.async_rl.generation_router: each frontend already routes to the whole fleet.bad_wordsinextra_bodyorsampling_overrideson the policy model (env.nemo_gym.policy_model.responses_api_models.vllm_model): the frontend answers every request carrying it with HTTP 400. Startup checks only this overlay, not Gym’s own YAMLs.vllm_cfg.skip_tokenizer_init: truewith NeMo-Gym: the engine detokenizes the replies Gym’s calls get through the frontend.vllm_cfg.expert_parallel_size > tensor_parallel_size: that runs data parallelism inside vLLM, which Dynamo does not serve yet. Above data-parallel rank 0, vLLM rejects each engine’sipc://KV-event endpoint.vllm_cfg.http_server_api_key_required: the frontend serves the same engines on 0.0.0.0 and checks no bearer token.vllm_cfg.http_api_server_countabove 1: NeMo-Gym’s calls go through the Dynamo frontend, so the extra vLLM HTTP frontends would serve none of them.frontend_args.render_workerssets how many processes render chat calls behind Dynamo.frontend_args.router_mode: direct: it needs a worker ID on every request, and NeMo RL’s rollouts name none.dynamo: trueon a backend other than vLLM, and adynamo_cfgblock withoutdynamo: true.
Build the image#
ai-dynamo is part of the vllm extra, so every vLLM worker venv carries it.
BUILD_DYNAMO=1 adds only the etcd and nats-server binaries, under /opt/dynamo/bin:
docker buildx build \
--build-context nemo-rl=. \
--build-arg BUILD_DYNAMO=1 \
--target release \
--file docker/Dockerfile \
--tag registry.example.com/nemo-rl:dynamo \
.
For a local checkout, install the binaries and keep the variable set for the runs that follow. The runtime looks for etcd and nats-server there, or else on PATH:
export NEMO_RL_DYNAMO_BIN_DIR="$PWD/venvs/dynamo-bin"
bash docker/dynamo/install.sh
Run#
Use any non-colocated SingleController vLLM recipe and add the switch:
uv run examples/run_grpo_single_controller.py \
--config examples/configs/grpo_math_1B_megatron_single_controller.yaml \
++policy.generation.dynamo=true
examples/configs/grpo_math_1B_dynamo_single_controller.yaml is the same run with every dynamo_cfg default spelled out.
Migrating from backend: dynamo#
backend: dynamo launched Dynamo’s own vLLM engine and was removed. Set backend: vllm and dynamo: true; vllm_cfg and vllm_kwargs keep their meaning. Startup rejects the old backend and each removed dynamo_cfg key (engine, control_timeout_s, metrics_*_prefixes, worker_args, frontend_args.tokenizer*) with what replaces it.