Repository navigation
serve: /health follows the backend; progress watchdog for a hung backend (P3) - #394
Conversation
…ung one down A hung GPU dispatch stops llama-server's main loop while its HTTP thread keeps answering /health 200, and serve's own /health was a flag set once at load, so Lemonade's BackendWatchdog never saw a wedged backend (ARCH-GAPS G3, goal P3). - /health: once loaded, serve asks each backend's own health route (3 s) and answers 503 with the reason when one has exited, does not answer, or the watchdog fired. - Progress watchdog (app/serve_watchdog.h): every forwarded chat, completion and Responses request is tracked; progress is a byte from the backend, or the backend's main loop answering GET /slots (probed while requests are in flight). No progress for --watchdog SECS (default 120, $ONEBIT_WATCHDOG_SECS, 0 = off), plus prompt tokens / --watchdog-prompt-tps (default 50) before the first byte, kills the backend and exits 1, so Lemonade reloads it. The log names the request, the wait, Tctl and the backend's last stderr lines. - The backend's stderr now passes through serve (Linux), unchanged, so serve keeps its tail. app/sysinfo.h reads Tctl, /proc/meminfo and amdgpu GTT. - tests/watchdog_serve.sh (ctest watchdog_serve, no GPU): fake_backend.py gains /slots and a "fake_hang" request that stops its stream and its /slots while /health stays 200. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍(Review updated until commit 19b09b7)Here are some key observations to aid the review process:
|
…tchdog interplay Lemonade's BackendWatchdog (our fork, wrapped_server.cpp) probes /health with a 2 s curl timeout and needs a 200. serve asked the backend for up to 3 s, so a slow backend made serve's own answer arrive after Lemonade gave up. It now asks for 1.5 s at most (0.5 s connect, 1 s read) and answers first with a 503 and the reason. docs/serve.md says how serve's exit meets Lemonade's 5 s process poll and reload-on-retry, which stay Lemonade's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Persistent review updated to latest commit 8550eed |
|
Hardware evidence for this PR's code, run as part of the #395 build (which contains it): strixhalo, HRX0, Qwen3-0.6B, pinned llama-server, under |
|
Persistent review updated to latest commit 19b09b7 |
#394 (squash 03f9b03) is byte-identical, in the four conflicting files, to the 1bit/serve-wedge-watchdog tip this branch already merged (8550eed); keep this branch's side, which builds on it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
All conflicts were additive: #398's --mem-check/--no-mem-check options, help text and 'Will it fit?' section sit next to #394's --watchdog options and the 'When a backend hangs' / 'Metrics' sections; both sides kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Goal P3 of the 2026-10-12 architecture review (gap G3): a hung GPU dispatch turns into a backend reload instead of a silent stall.
Problem: a hung dispatch stops llama-server's main loop, but its HTTP thread keeps answering
/healthwith 200. serve's own/healthwas a flag set once at load. So Lemonade's BackendWatchdog never saw a wedged backend.Scope: owner rule "What ever we are missing, lemonade provides". serve mirrors the child's health and exits on a stalled child. The restart and reload policy stays with Lemonade's BackendWatchdog, and serve has no restart logic.
Changes:
/health(and/v1/health): after load, serve asks each child backend's own health route (0.5 s connect, 1 s read, so it answers inside Lemonade's 2 s probe). It answers 503 with the reason when a backend has exited, does not answer, or the watchdog has fired.app/serve_watchdog.h). Every forwarded chat, completion and Responses request is tracked. Progress is either a byte from the backend on that request, or the backend's main loop answeringGET /slots; serve probes/slotswhile requests are in flight, and llama-server only answers it between decode steps. A request with no progress for--watchdog SECStriggers the watchdog. The default is 120 s;$ONEBIT_WATCHDOG_SECSchanges the default, and 0 turns it off. Before a request's first byte, it gets extra time: prompt tokens /--watchdog-prompt-tps(default 50). When the watchdog fires, serve SIGKILLs the backend and exits 1, and Lemonade reloads it.app/sysinfo.h: Tctl,/proc/meminfo, amdgpumem_info_gtt_*. P5 and P1 reuse it; the file is identical in those PRs./slots(ds4, onnx, mlx,--no-slots): only streamed requests are judged there, because from outside a long non-streamed answer looks the same as a hang.Tests:
tests/watchdog_serve.sh(ctestwatchdog_serve, no GPU, runs in CI).tests/fake_backend.pygains a/slotsroute and a"fake_hang"request, which stops the stream and/slotswhile/healthstays 200./healthreturns 503 while the backend is SIGSTOPped, and 200 again after SIGCONT;--watchdog 2is not killed;--watchdog 0disables the watchdog.smoke_serve,pm_route,bench_selftestanddevice_route.Docs:
docs/serve.md(new section "When a backend hangs", endpoint table, synopsis) anddocs/lemonade.md.Lemonade compatibility. Checked against our fork's
wrapped_server.cppat the pin 4812a683, then run with thatlemondon strixhalo; the backend wastests/fake_backend.py, so no GPU was used.LEMONADE_BACKEND_WATCHDOG_POLL_SECONDS) it checks that the process is alive;/health, with a 2 s timeout, needing a 200, and giving up after 3 failures./health200, so that probe never fires. serve's exit is the signal Lemonade acts on.onebit_args "--llama-server tests/fake_backend.py --watchdog 5", afake_hangstream through Lemonade):POST /v1/chat/completions (streamed) on the cpu backend ... made no progress for 5 s ... killing it and exiting so Lemonade reloads it, Tctl 76.0 C.BackendWatchdog llama-server backend marked unavailable: backend process exited while watchdog was active; reaped ... (exit_code=1).[DONE].Pruning unavailable backend for model: user.wd (state=watchdog_reset), reload the model, and answer "The capital of France is Paris."docs/serve.md.Not merged: the release is held until #389/#390/#315 are fixed.
🤖 Generated with Claude Code