#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.
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.
| When F1 dies | What happens |
|---|---|
| The 4 engines | Keep 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 frontends | Keep serving their own sessions, and could reach all 4 engines for s2 and s5 too. Nobody sends those calls to them. |
| The v2 driver | Does not notice. It checks the frontends only at startup, and nothing restarts one. |
| A checkpoint cut | Gym 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. |
Gym's side is the same: the same client retries a dead URL forever. What differs is what can die.
| Native vLLM | Dynamo (this PR) | |
|---|---|---|
| What a Gym URL points at | An 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 anyway | Yes: the frontend can crash or run out of memory while every engine is fine |
| Can another URL take the call? | Not without that engine | Yes: every frontend reaches every engine |
| Restart cost | A GPU worker and its weights | One 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.
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.