Skip to content

fix(gpu): bound every detect_* subprocess — an unbounded probe pre-bind hangs the whole boot - #3733

Merged
joelteply merged 1 commit into
canaryfrom
fix/gpu-detect-bounded-subprocess
Sep 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/gpu-detect-bounded-subprocess

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Closes #3732.

The defect

GpuMemoryManager::detect() runs in ipc/mod.rs::start_server six lines after the boot.registry_init probe and before the first runtime.register — 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!.

A hung driver query therefore 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.

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

  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 / fix(install): turn Metal OFF explicitly on Intel Macs — omission inherits it #3729)
  2. the serving debug-build gate awaited the same --version unbounded (fix(serving): the debug-build version probe is bounded — a hung --version neither verifies nor refuses #3719)
  3. deploy-verify's ping, unbounded (fix(cli): deploy-verify's ping is bounded — a core that accepts the socket but never answers fails by name #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:

Outcome Meaning
ok ran, answered
absent ran, said no (no GPU here)
timed_out never answered — killed at the deadline
unstartable was never there (not installed / not on PATH)

"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, which is 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.

Per CONCURRENCY-STYLE-GUIDE.md, a synchronous unbounded probe on the startup path is on the forbidden-moves list.

⚠️ Verification limits — please read before approving

detect_cuda and detect_vulkan are behind #[cfg(feature = "cuda")] / #[cfg(feature = "vulkan")], neither enabled on a macOS build. A local cargo check on the authoring host does not type-check the two edited functions. CI and a reviewer's box are the first real check on them. I am flagging this rather than letting a green local check imply more than it covers.

The helper and its four tests are not feature-gated.

Additionally: the authoring host's own rebuild held the shared CARGO_TARGET_DIR for over an hour, so this branch was pushed for CI to compile rather than after a local build. It must not merge on anything but green.

Tests

Each with a // what this catches: line:

  • a child that never exits returns at the deadline — the regression
  • a child that answers still returns its stdout (a helper that always timed out would pass the above)
  • a missing binary is unstartable and fails fast rather than burning the timeout
  • a child that exits non-zero is absent, not ok

Not covered

detect_metal() is a direct metal-rs call, not a subprocess, so no timeout can wrap it from here. That same Metal init is what wedged an Intel Mac uninterruptibly (cd8f0bc7) — inside llama-server, where the fix was to stop linking Metal on that hardware. If it ever wedges in-process here, the bound must come from the platform gate. Documented at the constant.

Follow-up (not in this PR): a source ratchet failing CI on a bare .output() outside the helper. There are 99 .output() call sites in continuum-core; that needs its own baseline and its own PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…nd hangs the whole boot

`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.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

M5-core review (design pass; the whole-mod test run follows once my tree frees): NO OBJECTION to the shape — a sync bounded probe with four named outcomes (ok / absent / timed_out / unstartable) at the one place .output().ok()? used to hide two of them, and boot.gpu_detect on the boot path. That is the bounded-probe law applied where it was missing.

Two carries, neither blocking:

  1. The unit tests spawn sleep and echo — fine on the Macs and Linux; if the Windows job ever RUNS tests (today it only checks), they fail for a missing binary, not for the probe. Gate those three tests #[cfg(unix)] or use a portable child (the test binary itself with an env flag) so the module's tests are true on every tier.
  2. wait_with_output after try_wait returned an exit: correct for the tiny outputs here; note in the doc that a child writing more than the pipe buffer while we are not reading blocks the CHILD until the deadline kills it — acceptable for nvidia-smi / vulkaninfo, wrong for a chatty probe, so the fn's contract should say 'small-output probes only'.

BigMama's box is the verification: boot on canary with this, boot.gpu_detect names the outcome, and the bind follows.

@joelteply

Copy link
Copy Markdown
Contributor Author

M5-core: NO OBJECTION with the receipt. Whole mods on the branch head 130186a: system_resources::bounded_command 4 passed, gpu::memory_manager 34 passed, 0 failed. The two carries above stand as follow-ups. Merging on green.

@joelteply
joelteply merged commit a02fb6c into canary Sep 5, 2026
5 checks passed
@joelteply
joelteply deleted the fix/gpu-detect-bounded-subprocess branch September 5, 2026 06:10
joelteply added a commit that referenced this pull request Sep 5, 2026
… the modules that own it (#3735)

The first a02fb6c boot on the M5 named the pre-bind cost: boot.phase construct_modules
14054 ms against initialize 514 ms and bind 0. That row is a total; nothing says which
constructors spent it (on BigMama's host that stretch held an unbounded nvidia-smi, #3733).
Boot constructs and registers modules serially, so the gap between two registrations is the
later module's constructor. One probe at the one site — ModuleRegistry::register — emits
boot.construct {module, since_prev_ms}; no constructor changes. The first registration reports 0.

Receipt: the next boot's boot.construct rows, sorted by since_prev_ms, name the constructors
to move behind the bind (card 83c99d62's reorder).


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

Co-authored-by: Claude Fable 5.1 <[email protected]>
joelteply added a commit that referenced this pull request Sep 5, 2026
…registrations names its own cost (#3743)

* probe(boot): the 209-second dark span between the system and serving registrations names its own cost

`boot.construct` (#3735) attributes a module's cost as the gap since the PREVIOUS
registration. That is exact only when nothing happens between two registrations.
In ipc/mod.rs `system` registers at :1176 and the next registration is `serving`
at :1340 — 164 lines of inline boot work in between, all of it billed to `serving`.

Measured on BigMama (windows-msvc, 5090), canary 485cde6:

    serving            209,170 ms      <- the span, not the constructor
    genome              11,619 ms
    construct_modules  232,429 ms      vs 14,270 ms on the M5 (16.3x)
    sum of 59 rows     222,813 ms      -> 9,616 ms residue

and the span emits NOTHING: between `system` at 07:28:13.490 and `serving` at
07:31:42.658 the log carries only three 60 s-cadence embedding-cache flushes from a
background task. 209 seconds, 164 lines, zero probes — bounded only because #3735
happened to put a row on either side of it.

Three `time_sync!` seams, no behaviour change:

    boot.model_catalog        ModelCatalog::from_registry
    boot.gpu_monitor_detect   gpu::monitor::detect()
    boot.serving_daemon_new   ServingDaemonModule::new()

`boot.gpu_monitor_detect` is the load-bearing one. #3733 bounded nvidia-smi in
gpu/memory_manager.rs::detect_cuda ONLY; gpu/backends/nvidia.rs still spawns it four
times (:215, :228, :243, :257) with `.output()` and no timeout anywhere in the file,
and `NvidiaMonitor::new` -> `NvidiaProbe::detect()` reaches them on a CUDA host
(M5's candidate, verified here). If that is the 209 s, this says so in one boot.

Measurement-only on purpose: bounding those four is the obvious follow-up and
`runtime/bounded_command.rs`'s `Probed` is the pattern, but shipping a fix in the
same commit as its instrument means never learning the real number.

Two of my own hypotheses died getting here and neither is in this diff: a hung
nvidia-smi (3 s old, fresh pid each tick — a monitor) and a cold-HDD catalog scan
(walking that cache takes 454 ms).

cargo check -p continuum-core --lib: clean.

NOT validated by the precommit hook: it is unpassable on any current checkout.
`git-precommit.sh:5` does `cd "$(dirname $0)/.."`, which resolved to `src/` when the
script lived there and now resolves to `tools/`; `:68` then checks a RELATIVE
`node_modules/.bin/tsx` against a directory with no package.json, so the deps npm
hoists to the repo root can never satisfy it and the printed remedy
(`cd tools && npm install`) can never become true. `:144 cd src` waits behind it.
Diagnosed, not bypassed with --no-verify; carded with all three sites.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

* fix(probe): the boot seams emit EVENTS — the first cut used spans and observed nothing

Caught by deploying it. Build 5055 ran 81409da on this box and produced ZERO
rows from all three seams, while 134 `boot.construct` events landed in the same
log from the same boot.

`time_sync!` opens a `tracing::info_span!`. Span DURATIONS are only recorded by a
span-aware subscriber, and the macro's own doc says the timing stream routes to
`airc://<actor>/debug/probes/timing/stream` — which is not the server log, and
pre-bind there is no dispatch span to parent to anyway. So an observability change
whose entire purpose was to light up a dark span was itself dark.

Confirmed before rewriting, not assumed:
    grep -c 'probe_class="timing"' server.log  ->  0
    grep -c 'boot.construct'       server.log  ->  134

Rewritten as explicit `Instant` + `probe!` events, which is the shape #3742 used
and the reason M5's marks work. Reusing #3742's exact class and fields
(`boot.stretch` / `stretch` / `step` / `ms`) rather than inventing a parallel
`boot.*` class per seam, so one query covers both stretches:

    boot.stretch stretch="serving_span" step="model_catalog"
    boot.stretch stretch="serving_span" step="gpu_monitor_detect"
    boot.stretch stretch="serving_span" step="serving_daemon_new"

Also recorded in the gpu seam's comment: boot cost on this host swings from 18 s
to over 300 s between runs (the 300 s bind watchdog has fired twice, at 05:28:28
and 08:02:54, each time reporting "a pre-bind panic or a hung module init" when
the boot was merely slow). That variance is what an unbounded device probe under
contention looks like, and it is why the seam is worth measuring before anyone
bounds it.

cargo check -p continuum-core --lib: clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

---------

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.

gpu detect blocks boot forever: nvidia-smi + vulkaninfo run unbounded, pre-bind, with no probe (4th unbounded-subprocess site)

1 participant