Dynamo with several frontends: where each piece runs today, where it runs with this PR, and why it moves

#5115, stacked on #4979. "Today" links are pinned to #4979's head a29d55b; "this PR" links to 9d420a14. Dynamo 1.5.1 → 1.8.0.dev20261117.

Nine pages on this stack (#4905, #4979 and #5115), one question each. This one: what #5115 moves to several frontends, and why.

Before
One Dynamo frontend runs as a child process of the v2 (single controller) driver, on the driver's node. It holds one router, one session table (at most 65,536 Gym sessions) and every chat render. A small launcher patches Dynamo's code to plug in our chat engine, and checkpoint cuts go to a second port.
This PR
num_frontends frontends run on the GPU nodes, each started by a small Ray actor. They use stock dynamo.frontend with two supported plug-ins (our chat engine and the cut route), so the launcher and the second port are gone. The session table holds 16,777,216. A watchdog stops every service if its starter is killed.
Status
Open, under review. #4979 has merged, so this PR now targets main. The author still has to pin Dynamo 1.8.0 (it is a nightly today) and run two frontends on two different nodes. The review asks for one small fix, one docs fix, two tests, run numbers, and a fix for a run that hangs when one frontend dies (see below).
Background. Dynamo puts an HTTP frontend in front of NeMo RL's vLLM engines. Its router picks an engine, and the call travels to that engine over Dynamo's TCP request plane. etcd (service discovery) and NATS (events) let frontends and engines find each other. NeMo-Gym sends multi-turn chat calls and keeps each session on one engine. At a checkpoint, Gym posts a generation cut. Dotted words have a short explanation: hover or tap them.

Today vs this PR: processes, and one Gym call through each

The same example in both columns: 2 GPU nodes, 4 vLLM engines (e0–e3), and on the right num_frontends: 3 (F0–F2). Dashed boxes are OS processes; boxes inside them are the classes that do the work. ① to ⑤ is one Gym chat call; ✂ is a checkpoint cut.

Today: #4979 at a29d55b Dynamo 1.5.1 · one frontend, on the driver's node NeMo-Gym (Ray actors) base_urls = [A] generation_cut_control_url = [B] ① chat call → port A ✂ cut → port B Driver's node v2 driver process ManagedDynamoRuntime.start etcdchild process NATSchild process frontend process × 1 (child of the driver) Launcher that patches Dynamo's own main() frontend.py L68: swaps EntrypointArgs + DistributedRuntime Rust HTTP server, port A ① chat · /v1/completions uvicorn thread, port B ✂ start_generation_cut_server Our chat engine ② render + splice TQ prefix 8 render workers (1 core each) EngineCutFanOut ✂ sends the cut to every engine, merges the answers KV router (the only one) ③ picks 1 of 4 engines 65,536 sessions max: the next Gym session gets 529 Limits today: · one process renders every call · token fields (stop_token_ids, …) never reach the chat engine, so a start-up check refuses them ③ request plane (TCP): token ids ✂ to every engine 2 GPU nodes (frontend-free) vLLM e0 vLLM e1 vLLM e2 vLLM e3 ④ generate,TQ write⑤ reply back Ray actor+ DynamoWorker samesame This PR: #5115 at 9d420a14 Dynamo 1.8 nightly · num_frontends: 3 here (default 1) NeMo-Gym (Ray actors) base_urls = [F0, F1, F2] one session → one frontend ① ✂ ① ✂ ① ✂ 3 frontends F0 · on node 0 FrontendHost, 0 CPU stock dynamo.frontend ① one HTTP port ② chat engine plug-in + 8 render workers ✂ cut route plug-in ③ its own KV router 16,777,216 sessions F1 · on node 1 FrontendHost, 0 CPU stock dynamo.frontend ① one HTTP port ② chat engine plug-in + 8 render workers ✂ cut route plug-in ③ its own KV router 16,777,216 sessions F2 · on node 0 again FrontendHost, 0 CPU stock dynamo.frontend ① one HTTP port ② chat engine plug-in + 8 render workers ✂ cut route plug-in ③ its own KV router 16,777,216 sessions ③ any router → any engine, either node TCP request plane · cache info from all engines via NATS 4 engines vLLM e0on node 0④ generate ⑤ vLLM e1on node 0④ generate ⑤ vLLM e2on node 1④ generate ⑤ vLLM e3on node 1④ generate ⑤ Where they run (frontend i → node i mod 2): GPU node 0 F0, F2, e0, e1 16 render workers on its CPUs GPU node 1 F1, e2, e3 8 render workers on its CPUs Driver's node v2 driver process starts the 3 actors · L569 etcd+ watchdog NATS+ watchdog removed or limited by this PR new or changed by this PR same in both one OS process checkpoint cut starts Right column: frontends do not own engines. Each router can send a call to any of the 4 engines, and num_frontends is set on its own, apart from the engine and node counts. Node placement only decides whose CPUs and memory a frontend uses. v2 rollouts pick a frontend at random.

What happens to one Gym call, step by step.

  1. â‘  Gym sends the chat call to its session's frontend. Today there is one URL; with this PR, Gym holds one URL per frontend (client_base_urls) and keeps each session on one of them.
  2. â‘¡ Our chat engine renders it with the checkpoint's template and splices the earlier turns from TQ. Today it is plugged in by patching Dynamo's main() (frontend.py, deleted). With this PR, Dynamo loads it through its supported --dyn-chat-processor flag (provider), and its settings arrive as one typed ChatProcessorOptions instead of four env vars.
  3. â‘¢ That frontend's router picks one of the 4 engines, on either node: no frontend is tied to the engines on its own node. With several frontends, --router-replica-sync shares in-flight requests between the routers (in kv mode).
  4. â‘£ The engine generates and writes the call to TQ, the same in both columns.
  5. ⑤ The reply goes back through the same frontend to Gym.
  6. ✂ At a checkpoint, Gym posts its in-flight calls. Today that goes to a second port (a uvicorn thread), because Dynamo 1.5.1 routes could not take a POST, so RL had to pass Gym a second URL list. With this PR, the cut uses the frontend's own port as a routes() extension. The native and Dynamo routes now share one check-and-answer helper, answer_generation_cut.

Start-up, today (a29d55b)

# v2 driver process, VllmGeneration.__init__
runtime.start()
    etcd  = Popen(etcd, new session)                    # outlives a SIGKILLed driver
    nats  = Popen(nats-server, new session)
    front = Popen(python -m nemo_rl...vllm.frontend,   # patches Dynamo's main()
                  env={RENDER_WORKERS, RAY_ADDRESS, CUT_PORT, ...})
gym(base_urls=[front:A], cut_urls=[front:B])           # two ports for one frontend
v2 rollout → POST front:A/v1/completions

Start-up, this PR (9d420a14)

# v2 driver process
runtime.start(frontend_node_ids=cluster.get_node_ids())   # [node0, node1]
    etcd = _ServiceProcess(etcd)                       # + watchdog: stops it if the driver dies
    nats = _ServiceProcess(nats-server)
    for i in range(num_frontends):                     # 3 here
        host[i] = FrontendHost.remote(node=ids[i % 2])  # Ray actor, 0 CPU: node 0, 1, 0
    urls = ray.get([h.start() for h in host])       # all 3 start at once
# inside each FrontendHost actor, on its GPU node
    start: port = a free port on this node
        _ServiceProcess(python -m dynamo.frontend
            --dyn-chat-processor chat_engine:provider
            --frontend-route-extension generation_cut:routes
            --router-replica-sync                       # only when num_frontends > 1
            --router-session-affinity-max-entries 16777216)
gym(base_urls=urls)                                    # the cut goes to the same URL
v2 rollout → POST random.choice(urls)/v1/completions

Real code: _start_frontends, frontend_argv, service_watchdog.main, rollout URL pick.

Why the change is needed

What a large run hitsToday (1.5.1, one frontend)This PR
Live Gym sessions (about 0.5M rollouts in flight)Dynamo's table is fixed at 65,536. Session 65,537 gets HTTP 529.session_affinity_max_entries, default 16,777,216. Every frontend holds every session, so size it for the whole fleet.
Rendering and routing loadOne process on the driver's node renders every chat call and routes every request.num_frontends spreads it over the GPU nodes: each frontend has its own router and render workers.
Plugging our chat engine into DynamoPatch Dynamo's main(); breaks silently if Dynamo renames what it patches.Dynamo's supported --dyn-chat-processor hook.
Checkpoint cutsA second port per frontend, and a second URL list threaded through setup and Gym config.The frontend's own port, so the second URL list in setup.py, vllm_generation.py and nemo_gym.py goes away. One frontend runs at most 64 cuts at once (HTTP 529 past that).
Token-level fields (stop_token_ids, cache_salt, …)Dynamo dropped them before our chat engine, so a start-up check refused them.Dynamo passes them through. The check is removed.
Driver killed with SIGKILLetcd, NATS and the frontend keep running; the test scripts kill them by name.A watchdog beside each service stops its whole process group.
router_mode: power-of-twoAllowed.Rejected at start-up: Dynamo removed it. Use least-loaded or kv.

What the review asks

The design is a step forward: two patches of Dynamo's code become supported hooks, four env vars become one typed options object, and the native and Dynamo cut routes share one helper. The review asks for one small fix, one docs row, evidence and tests for the new multi-frontend setup, and a fix for a run that hangs when one frontend dies (C21; C22 is optional).

CommentWhat it asksWhere
C15When the second frontend never answers, the start-up timeout error prints the first frontend's healthy counts. Reset them when moving to the next frontend.wait_for_engines · C15 comment
C16The docs row lists two rejected flags; the code rejects three.guide L41 · C16 comment
C17Add the router-mode parser test the author declined: this PR's own power-of-two removal is the drift it catches.reply on C10 · C17 comment
C18The pending multi-node run should also report numbers for the move shown in orange above: the default frontend and its 8 render workers now sit on GPU node 0, uncounted by Ray.reply on C14 · C18 comment
C19The start-up check for six token-level fields is gone, but only cache_salt has an end-to-end test.reply on C1 · C19 comment
C20The code comment above num_frontends should say replica sync works only with router_mode: kv.reply on C3 · C20 comment
C21When one frontend dies, Gym retries its URL forever and the run hangs (forest training: 3 tries, then the rollout fails). Gym already has the fix; RL should turn on route_around_failing_endpoints and a retry time limit whenever Gym gets more than one URL. Explainer.num_frontends · C21 comment
C22Optional: restart a dead frontend on the same port, so Gym's trial call can pick it back up.FrontendHost · C22 comment
C23Each frontend picks a free port, releases it, then binds it seconds later, in a range that overlaps the vLLM servers' range on the same GPU nodes. Give the frontends their own range and retry a failed launch.FrontendHost.start · C23 comment
C24Small: log each frontend's Prometheus /metrics (queued and in-flight calls) next to the vLLM metrics._start_frontends · C24 comment
C25Small: Dynamo calls start a new trace instead of joining Gym's. Turn on Dynamo's OTLP export when RL exports traces, and pass the trace to vLLM's generate.adapter · C25 comment
So what. This PR is what lets a 0.5M-rollout run use Dynamo at all: the session table no longer caps out at 65,536, and routing and rendering spread over the GPU nodes instead of one process on the driver's node. It also deletes two patches of Dynamo's code. Before merge: pin the Dynamo 1.8.0 release, and run two frontends on two nodes with numbers (C18), since even the default setup now puts the frontend on a GPU node.