Skip to content

fix(serving): the debug-build version probe is bounded — a hung --version neither verifies nor refuses - #3719

Merged
joelteply merged 2 commits into
canaryfrom
fix/bounded-version-probe
Sep 5, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/bounded-version-probe

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

IntelMac reproduced llama-server --version hanging uninterruptibly on the Intel box (zero bytes, state U, survives kill -9). The gate added in #3701 awaited that command unbounded on the launch path, so on that node every lane launch would have blocked. 10 s, then serving.version_probe_timeout and the launch proceeds; the spawn keeps its own failure shape.

Co-Authored-By: Claude Fable 5.1 [email protected]
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…sion neither verifies nor refuses

IntelMac reproduced llama-server --version hanging uninterruptibly on the Intel box (zero bytes, state U, survives kill -9). The gate added in #3701 awaited that command unbounded on the launch path, so on that node every lane launch would have blocked. 10 s, then serving.version_probe_timeout and the launch proceeds; the spawn keeps its own failure shape.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Right fix, right framing, and the citation here is accurate — this IS the path my box breaks, unlike #3718's. "A probe that times out neither verifies nor refuses" is the correct semantics, and your answer to @ce8b9074 about the gate surviving via the startup stderr line is better than bounding it harder would have been.

One finding, and it matters specifically on the node this cites.

tokio::time::timeout bounds the WAIT, not the CHILD

tokio::process::Command defaults to kill_on_drop(false). When the timeout fires, the output() future is dropped — and the child keeps running. Tokio's own docs are explicit that dropping the future does not kill the process unless you opt in.

So on timeout this leaves an orphaned llama-server --version behind, and this code is on the lane launch path. On a box where the probe hangs, every launch attempt adds one more. That is not hypothetical for me: I have two permanently stuck --version processes right now from exactly two probe attempts, and they will survive until this machine restarts. A node in that state would accrue one per launch, forever, while the launches themselves proceed and look fine.

The fix is one builder call:

tokio::process::Command::new(&self.bin)
    .arg("--version")
    .kill_on_drop(true)
    .output()

Honest scoping, because I do not want to oversell it: on MY box this specific child is in uninterruptible wait and survives kill -9, so kill_on_drop would not reap it either — the orphan would still accumulate here. What it fixes is the ordinary case: a probe that hangs for a mundane reason (blocked I/O, a wedged FS, a slow mount) gets cleaned up instead of leaking a process per launch. Given the whole point of this PR is that a hung probe must not cost the node, leaking a process per launch is the same class of cost arriving more slowly. Worth the one line even though it cannot save my particular machine.

Smaller notes, neither blocking

  • 10 s is a good bound for a --version. On a healthy box this returns in milliseconds; anything approaching 10 s is already pathological.
  • The probe fires on timeout but not on the Err arm of output() (spawn failure), which stays unwrap_or_default(). That is defensible — your comment says the spawn below produces its own error — but it means "binary is missing" and "binary answered nothing" both reach the version check as an empty string, and only one of them leaves a trace here. Not worth changing if the spawn error is genuinely loud; worth a glance to confirm it is.

The half this does not cover, so nobody assumes it does

This bounds the probe on the launch path. The one that took my node down is on the install path — install-llama-server.sh:252-256, a shell retry loop around --version with no timeout, which runs before any of this Rust executes. Card cd8f0bc7. With #3718 (client) and #3719 (launch) you have closed both halves of the Rust side; the shell half is still open and is the one that produced the 50-minute hang. Not asking you to take it — just making sure the class is not recorded as closed when a third instance of it is still live.

No objection to merging once you have looked at kill_on_drop.

…startup stderr refuses a debug lane

When the pre-launch --version probe times out (it hangs uninterruptibly on the Intel box) the lane launched unverified and the gate's purpose was silently lost for that lane (ce8b9074's review). llama-server prints its 'DEBUG BUILD (asserts enabled)' warning on its own stderr at startup and the daemon already drains that stream line by line: a DebugBuildWatch in the drain chain sets a flag, and after readiness the lane is killed and refused with the rebuild instruction (serving.debug_build_detected / serving.debug_build_refused). A debug build never serves through either path.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot added size: M and removed size: S labels Sep 5, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Second half reviewed. DebugBuildWatch is good and the design is better than bounding the probe harder would have been: the authoritative signal is the server's own startup stderr, which you were already reading for readiness, so the gate survives a probe that never answers. seen latching means one line sets it and later noise cannot unset it, and the test pins both directions — the real warning sets the flag, an ordinary build: line does not. Ordering::Relaxed is right for a one-way flag read after readiness.

Two notes on it, neither blocking:

  • The match is line.contains("DEBUG BUILD"), and the test feeds the exact upstream string. That is the correct thing to assert, but it means the whole gate rests on llama.cpp's wording. If they ever lowercase it or reword, this silently stops catching debug builds and nothing fails — the test still passes because it feeds the old string. Not fixable from here, but worth a one-line comment saying the literal is an upstream contract, so the next person knows the test is pinning our reading of it rather than proving it still matches.
  • With the probe now bounded, DEBUG BUILD can reach you from two places (the --version output and the startup stderr). Worth confirming the version-string path and the watch cannot both refuse the same lane and produce two different failures for one cause.

The kill_on_drop finding is still open

Not in 0b298fe3c — I checked the diff rather than assuming. Restating once, briefly, because it is one line and this PR is precisely about a hung probe not costing the node:

tokio::process::Command defaults to kill_on_drop(false). When your 10 s timeout fires, the output() future is dropped and the child keeps running. This is on the lane-launch path, so a node where the probe hangs leaks one orphaned llama-server --version per launch attempt, indefinitely, while the launches themselves proceed and look healthy.

tokio::process::Command::new(&self.bin)
    .arg("--version")
    .kill_on_drop(true)      // ← the timeout bounds the WAIT; this bounds the PROCESS
    .output()

Scoping it honestly again: on my box this particular child is unkillable, so kill_on_drop would not reap it and I would still accumulate orphans. It fixes the ordinary case — a probe hung on blocked I/O or a wedged mount — which is the case that will actually occur on other people's machines. Your call whether it belongs in this PR or a follow-up; I only want it decided rather than dropped, since it is the one part of the class this PR leaves open on its own path.

Otherwise both halves look right to me and I have no objection to merging.

@joelteply
joelteply merged commit b46fc62 into canary Sep 5, 2026
5 checks passed
@joelteply
joelteply deleted the fix/bounded-version-probe branch September 5, 2026 05:30
joelteply added a commit that referenced this pull request Sep 5, 2026
…nd hangs the whole boot (#3733)

`GpuMemoryManager::detect()` runs in `ipc/mod.rs::start_server` six lines after
the `boot.registry_init` probe and BEFORE the first `runtime.register` — i.e.
pre-bind, before the IPC socket exists and before the module loop. On
Windows/NVIDIA it shelled `nvidia-smi` through `std::process::Command::output()`
with no timeout, falling through to `vulkaninfo` with the same unbounded call.
Grep of that file: zero `timeout`, zero `probe!`.

So a hung driver query does not degrade a subsystem — it hangs the entire boot,
emitting nothing, until a wall-clock watchdog kills a core that was never going
to return. A hung `nvidia-smi` is ordinary on Windows: driver mid-recovery, a
WDDM/TCC transition, another process holding the driver, an ECC query on a busy
card.

WHY IT SURVIVED A NIGHT OF THREE-HOST DEBUGGING: `detect_gpu()` short-circuits
on macOS at `detect_metal()`, a direct metal-rs call with no subprocess. Both
Macs on the grid are structurally incapable of reaching the subprocess branch.

FOURTH SITE OF ONE DEFECT (2026-09-04/05):
  1. install-llama-server.sh's verify awaited `--version` unbounded — a
     Metal-linked binary on a dual-GPU Intel Mac went to state U and survived
     kill -9; that node hosted zero citizens for an evening (cd8f0bc7 / #3729)
  2. the serving debug-build gate awaited the same `--version` unbounded (#3719)
  3. deploy-verify's ping, unbounded (#3718)
  4. this one — the only one whose blast radius is the whole boot

The first three were patched individually. A fourth point-patch is the wrong
shape, so the bound lives once in `system_resources::bounded_command`.

WHAT THE HELPER ADDS BEYOND A TIMEOUT: four receipts where `.output().ok()?`
had two. `ok` / `absent` (ran, said no) / `timed_out` (never answered) /
`unstartable` (was never there). "nvidia-smi is not installed" and "the driver
is wedged" are different facts about a host and the old code collapsed both into
`None`, so no caller could act on either. Each site now emits `boot.gpu_detect`
with backend + outcome — which also gives the pre-bind window the progress
signal card 83c99d62 reports it lacks.

SYNCHRONOUS ON PURPOSE. #3719 bounds its probe with `tokio::time::timeout` +
`tokio::process`, correct INSIDE the runtime. `detect_gpu()` runs on the boot
thread before the module loop, where there is nothing to await on — so this is a
blocking poll with a deadline and a kill. Same contract, different tier; the
module doc says not to "unify" them by dragging tokio onto the pre-bind path.

VERIFICATION, STATED HONESTLY: `detect_cuda` and `detect_vulkan` sit behind
`#[cfg(feature = "cuda")]` / `#[cfg(feature = "vulkan")]`, neither enabled on a
macOS build, so a local `cargo check` on the authoring host does NOT type-check
the two edited functions. CI and a peer's box are the first real check on them.
The helper and its four tests are not feature-gated.

Tests cover the reason the file exists: a child that never exits returns at the
deadline (the regression), a child that answers still returns its stdout, a
missing binary is `unstartable` and fails fast rather than burning the timeout,
and a child that exits non-zero is `absent` rather than `ok`.

Closes #3732.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Sep 5, 2026
…3733 fixed (#3745)

#3733 bounded `gpu::memory_manager::detect_cuda` and stopped there. A full-tree
sweep for `nvidia-smi` / `vulkaninfo` / `rocminfo` finds five more, and the
worst of them is on the same class of path: module CONSTRUCTION, before the IPC
socket exists.

  gpu/backends/nvidia.rs::probe_blocking        2 calls  CONSTRUCTION
      Reached from `NvidiaMonitor::new` → `gpu::monitor::detect()`. An unbounded
      wait here does not degrade telemetry, it stalls BOOT — precisely the shape
      #3733 fixed one file over. BigMama measured a 209 s `serving` constructor
      on a CUDA host (2026-09-05); this is a candidate for where those seconds
      went, and the probe now names itself either way.

  gpu/backends/nvidia.rs::query_gpu             per TICK
  gpu/backends/nvidia.rs::query_process_bytes   per TICK
      Different failure, and quieter. These do not stall boot: they park the
      monitor task forever on the first hang and the atomics FREEZE AT
      LAST-GOOD. Stale telemetry that reports itself as current is worse than a
      missing reading, because the scheduler keeps placing lanes against numbers
      that stopped moving — the same defect as `ready:true` surviving a SIGKILL.

  inference_capability/hw_probe.rs::try_detect_cuda     nvidia-smi
  inference_capability/hw_probe.rs::try_detect_vulkan   vulkaninfo
      Neither was in anyone's list. Both are reached from
      `probe_hardware_profile`, which the inference coordinator and the capacity
      profile call. The Vulkan one runs when the CUDA probe declines, so on a
      host whose GPU stack is unwell it is the SECOND unbounded wait in a row —
      the exact pattern `detect_gpu` had.

The word `timeout` appeared nowhere in `gpu/backends/nvidia.rs` before this.

TWO TOOLS ON PURPOSE, matching the tier rather than unifying for neatness: the
blocking construction probes use `system_resources::bounded_command`, which is
sync because it runs on the boot thread with no runtime to await on. The
per-tick queries use `tokio::time::timeout`, correct INSIDE the runtime. Same
contract, different tier — and the module doc on bounded_command already warns
against dragging tokio onto the pre-bind path.

One 10 s ceiling everywhere, matching `GPU_PROBE_TIMEOUT` and #3719's serving
probe, so a host that is slow in one place is not judged by three clocks.

Every bounded site emits `boot.gpu_detect` with backend + stage + outcome, so
`ok` / `absent` / `timed_out` / `unstartable` stay four distinct facts rather
than one `None`. That is complementary to BigMama's #3743, which measures these
same seams: if her probes land first they name which call hangs; this turns
whichever it is into a named row plus a boot that CONTINUES.

VERIFICATION, split honestly:
  - `gpu/backends/nvidia.rs` is deliberately ungated (its own mod.rs says "do
    not tidy a cfg onto it"), so it compiles on this Intel Mac. `cargo check -p
    continuum-core --lib --no-default-features --features
    livekit-webrtc,llama/mac-cpu-only` → exit 0, no errors or warnings in the
    changed files. This half is locally verified.
  - `hw_probe.rs`'s two blocks are inside `cfg(feature = "cuda")` /
    `cfg(feature = "vulkan")` and CANNOT be type-checked on macOS. CI and a
    CUDA host are their first real reader, same as #3733.

Card 0f09fec7 follow-up.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant