When one Dynamo frontend dies, its Gym sessions retry it forever and training stops

#5115. RL links are pinned to 9d420a14, Gym links to the pinned Gym 9e2e5d0a. Review comments: C21 comment and C22 comment.

Nine pages on this stack (#4905, #4979 and #5115), one question each. This one: what happens when one Dynamo frontend dies mid-run.

Before
One frontend (#4979). If it died, every Gym session retried it forever and the run stopped with no error. RL never checked it after startup.
This PR
Several frontends, each able to reach every engine. Each one still fails alone the same way: only its own sessions hang, but the step waits on them, so the run still stops. (With forest training, Gym gives up after 3 tries and those rollouts fail instead.)
Status
Open, not fixed in this PR. Raised as C21 (RL turns on two options Gym already has: route around a failing URL, and a time limit on retries) and C22 (optional: restart a dead frontend), in a review that is still pending.
Background. A Dynamo frontend takes Gym's chat calls and passes each one to any of the vLLM engines. With num_frontends: 3, Gym gets 3 URLs and keeps each session on one of them. The engines run on GPUs and hold the calls; a frontend holds nothing the run needs to keep. Dotted words have a short explanation: hover or tap them.

Gym picks a URL per session by hashing the session id (_resolve_client). When that URL refuses the connection, Gym's HTTP client waits 0.5 s and tries the same URL again (http_client.py L818). It has no limit, because RL leaves Gym's limits off: route_around_failing_endpoints and endpoint_connection_retry_timeout_s both exist and default to off (app.py L1166-L1170); Gym's own comment says "a client retries a refused connection forever" (L714-L717). On the RL side, the driver reads the frontends' exit codes only while it waits for them at startup (L669, _assert_services_alive), and nothing restarts a frontend.

One frontend dies: this PR, and the proposed fix

This PR, when F1 dies 3 frontends · 4 engines · 6 Gym sessions, 2 per frontend NeMo-Gym s1 s4 → F0 s2 s5 → F1 s3 s6 → F2 (hash of session id) s1 s4 ② refused → retry every 0.5 s, no limit s3 s6 F0serving s1 s4 F1 · process exitedport refuses calls ① its in-flight calls lost F2serving s3 s6 e0 · fine e1 · fine e2 · fine e3 · fine F0 and F2 can still reach all 4 engines. v2 driver reads frontend exit codes only at startup · L669 never sees F1 die, never restarts it Result: s2 and s5 never finish. The step waits on all 6, so training stops, with no error. ✂ A cut for s2 s5 sent to F1 fails; they regenerate after restore (safe). Proposed: C21 (+ optional C22), not implemented Same 3 frontends, 4 engines and 6 sessions NeMo-Gym route_around_failing_endpoints: true (C21) s1 s4 s2 ② 8 tries, then fail ③ 3 fails: skip F1 s3 s6 s5 F0serving s1 s4 s2 F1 · skipped by Gymone trial call / 60 s ④ C22: restart it F2serving s3 s6 s5 e0 · fine e1 · fine e2 · fine e3 · fine s2 and s5 restart from their prompt on another frontend. v2 driver ⑤ re-sends the prompts whose calls failed (already in v2) max_infra_attempts_per_prompt: 5 · by then Gym skips F1 Result: all 6 sessions finish. If F1 comes back (C22), Gym's trial call gives it sessions again. If every frontend dies, prompts drop and the run stops with an error. working the problem proposed change ① F1's in-flight calls are lost: their replies have nowhere to go. ② Gym's next call to F1 is refused. ③ C21: RL turns on Gym's existing route-around. ④ C22 (optional): FrontendHost restarts F1. ⑤ v2's existing prompt retry.
When F1 diesWhat happens
The 4 enginesKeep running. The calls F1 had in flight are lost, since their replies have nowhere to go.
Gym's sessions on F1 (s2, s5)Retry F1's URL every 0.5 s, with no limit. With forest training (source_history), Gym tries only 3 times (openai_client.py L485-L486), so those rollouts fail instead of hanging. Either way, nobody tries F0 or F2.
The other frontendsKeep serving their own sessions, and could reach all 4 engines for s2 and s5 too. Nobody sends those calls to them.
The v2 driverDoes not notice. It checks the frontends only at startup, and nothing restarts one.
A checkpoint cutGym sends the cut for s2 and s5 to F1 (_cut_all). It fails, so those calls are generated again after a restore (_cut). That loses work but never gives wrong tokens.

Is the native vLLM path the same?

Gym's side is the same: the same client retries a dead URL forever. What differs is what can die.

Native vLLMDynamo (this PR)
What a Gym URL points atAn HTTP server thread inside one GPU worker (_setup_vllm_server)A frontend: its own CPU process, started by a FrontendHost actor
Can it die while the engines live?In practice no: it dies with its GPU worker, so the run has lost an engine anywayYes: the frontend can crash or run out of memory while every engine is fine
Can another URL take the call?Not without that engineYes: every frontend reaches every engine
Restart costA GPU worker and its weightsOne CPU process; it has no state the run needs

So the hang is not new in this PR, and #4979 had it with one frontend. What this PR changes is that the fix is now cheap: there are other frontends to fall back on, and Gym already knows how to fall back. C21's two settings apply whenever Gym gets more than one URL, so they cover the native path too.

The fix, as pseudocode (proposed, not implemented)

Where the fix lands: RL only, one function. C21: _build_gym_actor_config sets two defaults on Gym's vllm_model block. No Gym change: the pinned Gym already has both options. C22 (optional): FrontendHost.

Gym today (options off): a call to a dead URL

# Gym vllm_model · serving event loop, one task per call
def chat(session, call):
    url = pinned[session] or urls[hash(session) % 3]  # _resolve_client
    ticket.backend = url                              # note_generation_backend
    while True:                                       # max_connection_retries=None
        try: return await post(url, call)
        except ConnectionRefused: await sleep(0.5)    # same url, no limit

Gym with route_around_failing_endpoints: true (existing Gym code, no change)

# Gym vllm_model with route_around_failing_endpoints: true (already in Gym)
def chat(session, call):
    url = pinned[session]
    if url failed and not due its 60 s trial: url = a working url  # _endpoint_serves
    ticket.backend = url                                           # the cut follows the session
    for try in 1..8:                                               # endpoint_connection_retries
        try: return await post(url, call)
        except ConnectionRefused: await sleep(0.5)
    count failure on url; 3 in a row: mark url failed              # _note_endpoint_failure
    raise                                                          # v2 sends the prompt again

Real code: _resolve_client, _assign_client, _endpoint_serves, _note_endpoint_failure, the retry loop.

C21 · RL's Gym config, before

# v2 driver · building each Gym actor's config
def _build_gym_actor_config(cfg, base_urls):
    if dynamo: _apply_dynamo_dialect(cfg)  # sets dynamo_frontend, reasoning_field
    ...                                    # nothing about failover

C21 · RL's Gym config, after

# v2 driver · building each Gym actor's config
def _build_gym_actor_config(cfg, base_urls):
    if dynamo: _apply_dynamo_dialect(cfg)
    if len(base_urls) > 1:                                                  # native and Dynamo alike
        vllm_model.setdefault("route_around_failing_endpoints", True)       # 8 tries, then skip the url
        vllm_model.setdefault("endpoint_connection_retry_timeout_s", 60.0)  # time cap per call
    ...

setdefault keeps any value a recipe sets itself. Real code: _apply_dynamo_dialect, _build_gym_actor_config.

C22 (optional) · a frontend, before

# FrontendHost actor · one per frontend, 0 CPU, pinned to its node
def start(cmd):
    port = free_port()
    proc = launch(cmd, port)  # _ServiceProcess
    return url(port)          # nothing watches proc after this

C22 (optional) · a frontend, after

# FrontendHost actor · one per frontend, 0 CPU, pinned to its node
def start(cmd):
    port = free_port()
    proc = launch(cmd, port)
    start_thread(watch, cmd, port)  # new watcher thread in the actor
    return url(port)
def watch(cmd, port):               # watcher thread
    while True:
        code = proc.wait()
        log(url(port), code)
        if restarts_in(10 min) >= 5: log("giving up"); return
        proc = launch(cmd, port)    # same port, same chat files

Real code: FrontendHost.start, _start_frontends.

The few calls that fail before Gym switches are re-sent by v2 (max_infra_attempts_per_prompt: 5). If every frontend dies, every call fails, prompts are dropped, and the run stops with an error (max_consecutive_dropped_prompts: 0). C22 is only about getting the dead frontend's capacity back.

So what. Today, one frontend crash stops training with no error, even though the GPUs and the other frontends are fine. Gym can already route around a dead URL and cap its retries; RL just has to turn that on when Gym gets more than one URL (C21). Restarting the dead frontend (C22) is a nice-to-have.