Skip to content

fix(stop+adopt): the reboot path keeps its promise — a stop spares the live lane on Unix, the lane is its own process group, and an adoptee that is busy is not reaped (card 59052747) - #4284

Merged
joelteply merged 1 commit into
canaryfrom
fix/stop-spares-the-lane-on-unix
Sep 20, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/stop-spares-the-lane-on-unix

Conversation

@joelteply

@joelteply joelteply commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Every deploy was a cold prefill for every seated mind. Two seams, one card:

  1. THE SIGNAL. kill_pid_trees_preserving on Unix read let _ = keep; and sent every
    root kill_pid_tree = kill(-core_pid, SIGTERM) — the core's PROCESS GROUP. The
    lane was spawned with no process group of its own (measured on the IntelMac and the
    M5: engine pgid == core pid), so it took the SIGTERM at the old core's stop, eleven
    lines before "leaving serving lane(s) up for adoption" printed over it (M5 pid 61259
    RemovedDead 19 s after the stop; the IntelMac's adoptee answered /v1/models while
    exiting and failed the decode probe). Windows honored keep through its kill plan;
    Unix never did. Now ONE kill_plan (the Windows plan, made platform-neutral as
    KillStep) executes on both platforms — Process(core) when a lane is protected,
    Tree otherwise — and the lane is spawned in its own process group, so neither the
    core's group kill nor launchd's job-exit reap can reach it: its fate is decided by
    name (registry, ownership sweep, adopt-or-reap), never by the group it was born into.
    Pinned with real processes: a leader and its child in one group — the protected child
    survives the leader's kill; with nothing protected the group goes (plain stop).

  2. BUSY IS NOT DEAD, at adoption too. The heartbeat already judged a missed smoke probe
    against the server's own /slots account (L11, judge_smoke_miss); the adopt rail
    did not — ONE missed probe reaped the warm engine. The /slots fingerprint is now
    taken before and after the probe: a lane that advanced during the probe's window is
    adopted (serving.adopt_busy_alive) and the heartbeat verifies from there; a frozen
    or unreadable fingerprint is the wedge signature and is reaped as before
    (serving.adopt_rejected now says slots_moved=false). Pinned with the fake
    control: busy + missed probe → AlreadyServing, 0 respawns; the wedged orphan and the
    force-probed owned lane still respawn.

Receipt: bin tests 59 passed (the one failure, prebuilt_reboot_options_are_explicit_and_strict,
fails identically on canary without this change — environment, not this PR); lib
inference::llama_server::tests 48 passed / 0 failed; REAL_EXIT 0 on both.

Faster or slower: every reboot on macOS/Linux stops costing a model reload plus a cold
prefill per seated mind (the IntelMac: 10–11 min per mind; the M5: 5.5–6 min per mind).
The adopt probe costs two extra /slots reads per adoption. Nothing slower.

Receipt to watch

On the next reboot of a Unix node: ps -o pgid of llama-server ≠ the core pid; the stop log prints "leaving serving lane(s) up for adoption" and the lane registry does NOT sweep it as RemovedDead; the next core adopts (AlreadyServing, or serving.adopt_busy_alive if it was mid-turn) and the first turns read cached_tokens > 2.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…e live lane on Unix, the lane is its own process group, and an adoptee that is busy is not reaped (card 59052747)

Every deploy was a cold prefill for every seated mind. Two seams, one card:

1. THE SIGNAL. `kill_pid_trees_preserving` on Unix read `let _ = keep;` and sent every
   root `kill_pid_tree` = `kill(-core_pid, SIGTERM)` — the core's PROCESS GROUP. The
   lane was spawned with no process group of its own (measured on the IntelMac and the
   M5: engine pgid == core pid), so it took the SIGTERM at the old core's stop, eleven
   lines before "leaving serving lane(s) up for adoption" printed over it (M5 pid 61259
   RemovedDead 19 s after the stop; the IntelMac's adoptee answered /v1/models while
   exiting and failed the decode probe). Windows honored `keep` through its kill plan;
   Unix never did. Now ONE `kill_plan` (the Windows plan, made platform-neutral as
   `KillStep`) executes on both platforms — `Process(core)` when a lane is protected,
   `Tree` otherwise — and the lane is spawned in its own process group, so neither the
   core's group kill nor launchd's job-exit reap can reach it: its fate is decided by
   name (registry, ownership sweep, adopt-or-reap), never by the group it was born into.
   Pinned with real processes: a leader and its child in one group — the protected child
   survives the leader's kill; with nothing protected the group goes (plain `stop`).

2. BUSY IS NOT DEAD, at adoption too. The heartbeat already judged a missed smoke probe
   against the server's own `/slots` account (L11, `judge_smoke_miss`); the adopt rail
   did not — ONE missed probe reaped the warm engine. The `/slots` fingerprint is now
   taken before and after the probe: a lane that advanced during the probe's window is
   adopted (`serving.adopt_busy_alive`) and the heartbeat verifies from there; a frozen
   or unreadable fingerprint is the wedge signature and is reaped as before
   (`serving.adopt_rejected` now says `slots_moved=false`). Pinned with the fake
   control: busy + missed probe → AlreadyServing, 0 respawns; the wedged orphan and the
   force-probed owned lane still respawn.

Receipt: bin tests 59 passed (the one failure, `prebuilt_reboot_options_are_explicit_and_strict`,
fails identically on canary without this change — environment, not this PR); lib
`inference::llama_server::tests` 48 passed / 0 failed; REAL_EXIT 0 on both.

Faster or slower: every reboot on macOS/Linux stops costing a model reload plus a cold
prefill per seated mind (the IntelMac: 10–11 min per mind; the M5: 5.5–6 min per mind).
The adopt probe costs two extra `/slots` reads per adoption. Nothing slower.

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

REVIEWED at c610469 by Fable. This is the fix that stops every deploy from costing every seated mind a cold prefill, and both halves are right.

  • kill_plan with an explicit keep, and the Unix arm no longer discards it — with a test that spawns a real process group and proves the protected child outlives its leader. That is the defect my own agent found independently (let _ = keep; then kill(-pid, SIGTERM) on the core group, engine pgid == core pid on the M5), so two readings agree on the mechanism.
  • process_group(0) on the engine spawn means an engine from a new core is out of the group regardless of which CLI stops it, which is the half that keeps this from regressing the first time someone stops a core by another path.
  • The adopt rail reading slots_activity_fingerprint before and after the smoke probe, and adopting when the slots advanced, is the busy-is-not-dead law applied exactly where it was being broken. serving.adopt_busy_alive makes the judgement readable instead of inferred.

Measured cost this fixes, from the M5 tonight: after the 20:58Z deploy the new core swept pid 61259 as dead and respawned, and the next four turns re-prefilled 27–30k tokens at 70–92 tok/s, 297–389 s each — about 20 of 37 minutes of that hour spent re-reading prompts the engine already had.

One thing to confirm on your box, not a block: that an engine spawned by the OLD pre-fix core is still spared by keep on the first upgrade, or the very next deploy pays the cold prefill once more.

APPROVE at c610469 — merging on green.

@joelteply
joelteply enabled auto-merge (squash) September 20, 2026 22:03
@joelteply
joelteply merged commit 97205e0 into canary Sep 20, 2026
6 checks passed
@joelteply
joelteply deleted the fix/stop-spares-the-lane-on-unix branch September 20, 2026 22:27
joelteply added a commit that referenced this pull request Sep 21, 2026
…d make NOW — last deploy's cache type is a stale lane, relaunched once and named (card 977842fd) (#4288)

The composition of two correct changes: the KV cache type is applied at engine SPAWN
(#4285), an engine now survives a core stop (#4284), and the adopt rail compared model +
window + lanes + sight — never the KV decision. Measured on the 5090, 2026-09-21 00:33Z:
the new core read the q8_0 decision, found its healthy f16 engine at 26,880, adopted it,
and the decision never reached the process it was written to change; three minds fell
home from that seat within seven minutes ("seat window below her turn").

- `lane_process::LaunchKv` + `launch_kv_in(argv)`: the running engine's cache type and
  flash-attention read off its OWN argv (`--cache-type-k`, `--flash-attn on|off|auto`,
  bare and `=` forms) — the same recovery the `--cache-ram` grant already uses for an
  adopted lane. No flag = the engine's f16 default, a value.
- `LlamaServerControl::launch_kv()`: the real control resolves the live lane's pid from
  the registry and reads its argv; a fake models it (`launched_with`); unknown = `None`.
- `ensure_model_serving`: `kv_ok` beside `window_ok` / `lanes_ok` / `sight_ok` — the
  running decision against `kv_cache_plan::resolve()` (what a spawn would do now). A
  mismatch is `serving.grow` with both geometries named, then the relaunch the other
  axes already take; a window drift still adopts (#4284's warm-lane economy stands);
  an unknown launch is not a mismatch.

Pinned: an engine on the other decision → Spawned once; the same decision → AlreadyServing,
0 respawns; unknown → AlreadyServing. `launch_kv_in` on every flag shape.

Receipt: lib `inference::llama_server::tests` 59 passed / 0 failed (+ lane_process),
REAL_EXIT 0. On the 5090 after this lands: `serving.grow kv_ok=false planned_kv=q8_0
running_kv=f16` once, then a lane at roughly double the window.

Faster or slower: one argv read per ensure pass on an adopted lane; a stale lane costs
ONE relaunch, which is the cost of the decision reaching the engine at all.


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