Skip to content

fix(serving): the snapshot tells the engine's truth — lanes from /props and the cache grant from the launch, never the plan's latest derivation (the M5's 07:52Z collapse to 1 × 2,048) - #4251

Merged
joelteply merged 4 commits into
canaryfrom
fix/the-snapshot-tells-the-engines-truth-lanes-and-grant
Sep 20, 2026
Merged

joelteply merged 4 commits into
canaryfrom
fix/the-snapshot-tells-the-engines-truth-lanes-and-grant

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What broke (the M5, 2026-09-20 07:52Z, serving 2 × 67,072 on a 14,396 MiB --cache-ram grant)

The box's raw available fell under 8 GiB as the engine's prompt cache filled → drive mode Eco (serving.mode.transition available_gib 7) → the plan fell to 1 lane → the reconcile "re-homed", which ADOPTED the running 2-slot engine (slots ≥ target never relaunch; pid 56926 from 00:05 kept --parallel 2). Two lies followed, both in the live ServingSnapshot:

  1. lanes was the TARGET's count (1) for an engine serving 2. snapshot_from_outcome(..., target.lanes, ...) while the window beside it is probed from /props. The footprint measurement halved its divisor (per_token_measured 162k → 262k), the ambient budget (lanes − 1) went to zero, the health line said "1 now", the roster bound read one warm slot.
  2. The grant cell served_prompt_cache_mib was rewritten at every TARGET derivation (reconcile_to_plan, 14,396 → 256 MiB for the 1-lane target) while the engine still held 14,396. The measurement subtracted the new number: per-token 33k → 162k, excess_is_fixed 8.6–15.4 GB, the prefill "spike" 2.8 → 16.6 GB, fits_on_gpu false, plan 1 × 2,048 — and ~/.continuum/state/lane-footprint.json now says 262,727 B/token for the 27B, which would rule the next boot's plan.

Receipts: serving.plan 07:46:58 lanes 2 usable 32 → 07:52:01 lanes 1 usable 24 → 07:52:13 window 2048 spike 9.87 GB → 07:53:18 spike 16.6 GB; serving.footprint.measured 07:52:12 host_cache_bytes 15,095,300,096 → 268,435,456 with lanes 2, then lanes 1 at 07:53:17; serving/status lanes 1 vs ps: --parallel 2 --cache-ram 14396.

The fix — one truth

  • ServingSnapshot.host_prompt_cache_mib (new, serde(default), ts-rs binding updated): the --cache-ram THIS spawn passed, recorded on LlamaServerProcess beside mmproj_on_lane and exposed as LlamaServerControl::launched_prompt_cache_mib() (default None, so fakes and adopted lanes stay honest → 0).
  • snapshot_from_outcome takes the grant and the ENGINE's lanes: published_lanes(served, target_lanes) (pure) — /props total_slots when the engine names one, the target's only when it names none / the probe fails (probed loud, same policy as the window).
  • The measurement (serving.footprint.measured), the MoE host-cache lease inputs and the board's FootprintFn (now (id, window, lanes, grant_mib), the consumer hands it from the same snapshot it reads window and lanes from) all read the grant off the snapshot. The daemon cell is deleted.
  • The corrupted record heals itself on the next honest reading (a reading replaces the record).

Tests

  • the_snapshot_reports_the_engines_lanes_and_grant_not_the_plans: a 2-slot engine under a 1-lane target publishes 2; no slot count / unreadable → the target's; the grant rides the snapshot; attribute_serving credits it.
  • snapshot_mapping_is_honest extended (grant carried when ready, 0 when nothing is live).

Named, not fixed here

  • A past form's custody record carries no grant → under-attributed by it until the record learns it.
  • The mode flip itself: the daemon's own cache grant filling the box into Eco is a grant-sizing question (the grant is sized against raw available at derivation; it then consumes that available). Card to follow on 9a9019b4.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…ps and the cache grant from the launch, never the plan's latest derivation (the M5's 07:52Z collapse to 1 × 2,048)

Measured on the M5, 2026-09-20 07:52Z, serving 2 × 67,072 on a 14,396 MiB --cache-ram grant:
the box's raw available fell under 8 GiB as the engine's prompt cache filled, the drive mode
went Eco, the plan fell to 1 lane, and the reconcile "re-homed" — which adopted the running
2-slot engine (slots ≥ target never relaunch). Two lies followed, both in the live snapshot:

1. `snapshot_from_outcome` published the TARGET's lane count (1) for an engine serving 2. The
   footprint measurement halved its divisor (per-token 162k → 262k), the ambient budget
   (lanes − 1) went to zero, the health line said "1 now", the roster bound read one warm slot.
2. The daemon's grant cell `served_prompt_cache_mib` was rewritten at every TARGET derivation
   (14,396 → 256 MiB for the 1-lane target) while the engine still held 14,396. The measurement
   subtracted the new number: per-token 33k → 162k, the fixed excess 8.6–15.4 GB, the prefill
   "spike" 2.8 → 16.6 GB, `fits_on_gpu false`, the plan 1 × 2,048 — and the record on disk
   (`lane-footprint.json`: 262,727 B/token) would have ruled the next boot's plan.

Fix, one truth: the snapshot carries `host_prompt_cache_mib` — the `--cache-ram` THIS spawn
passed, recorded on the process handle beside `mmproj_on_lane` (a fact about the running
process, `None` when adopted) — and its `lanes` is the engine's `/props total_slots` (the
target's only when the engine names none; `published_lanes`, pure). The measurement, the MoE
host-cache lease and the board's `FootprintFn` read the grant off the snapshot (the fn now
takes it beside window and lanes); the daemon cell is deleted. The corrupted record heals
itself on the next honest reading (a reading replaces the record).

Tests: `the_snapshot_reports_the_engines_lanes_and_grant_not_the_plans` (2-slot engine under
a 1-lane target publishes 2; the grant rides the snapshot; the board credits it),
`snapshot_mapping_is_honest` extended. ts-rs binding regenerated by hand in its format.

Named, not fixed here: a past form's custody record carries no grant (under-attributed by it);
and the mode flip itself — the daemon's own cache grant filling the box into Eco — is a sizing
question for the grant (card to follow).

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

Copy link
Copy Markdown
Contributor Author

APPROVE with one condition — reviewed at exact head c61c69b (checks running at read time).

This is the substrate defect shape exactly — one value (the grant, the lane count) carrying two meanings (what the plan wants, what the engine holds) — and the fix puts the facts where facts live: recorded at spawn on the handle, published on the snapshot, read by every consumer from the same snapshot. published_lanes is the window's own policy applied to lanes, the daemon cell is gone, the test pins the 07:52Z shape. I checked that the launched_prompt_cache_mib store sits inside the spawn function after the mmproj decision (llama_server.rs:3545), so an adopt never stores the target's number — right.

The condition is the ADOPTED case, because it is not the rare one: every deploy now leaves the lane up for the next core to adopt (the reboot path's own line), so after every deploy launched_prompt_cache_mib is None → snapshot 0 → and lane_footprint::observe is handed host_cache_bytes = 0. Zero there does not mean "nothing subtracted, honest"; it means the whole prompt cache is attributed as per-token bytes and WRITTEN to lane-footprint.json — the same corrupt record this PR exists to stop, produced on the deploy path instead of the re-home path. Before this PR the adopted case was accidentally right (the cell held the re-derived target, which matched the launch whenever the plan had not moved); after it, it is wrong by the full grant every time. Two acceptable shapes, your pick: (a) the grant is recovered for an adopted engine — the lane registry's custody record learns cache_ram_mib at spawn (the same record adoption already reads; your named gap #1 is this), or the engine's own argv (--cache-ram N on the pid the registry holds, the way serving_core_pid reads argv); or, at minimum, (b) an unknown grant WITHHOLDS the per-token reading — no observe, no record written, a serving.footprint.unmeasured probe naming why — so an absence stays an absence. (b) is a few lines and makes the PR safe on the deploy path tonight; (a) is the real fix and can follow.

One note, not a condition: the M5's lane-footprint.json currently says 262,727 B/token for the 27B; the PR says a reading heals it, but the reading needs a lane up, and the boot plan reads the record first — the first boot after this lands plans 1 × 2,048 until that reading arrives. Reset the record by hand on the M5 before the deploy, or accept the detour and say so in the receipt.

joelteply and others added 2 commits September 20, 2026 03:25
… an unknown grant withholds the reading (Cormac's condition on #4251)

Every deploy leaves the lane up for the next core to adopt, so the adopted case is the common
one: the handle has no spawn fact, the snapshot said 0, and `observe` would have been handed
host_cache_bytes 0 — the whole prompt cache attributed as per-token bytes and written to
lane-footprint.json, the same corrupt record this PR exists to stop, now on the deploy path.

(a) `lane_process::command_args(pid)` (sysinfo, single-pid refresh) + pure `cache_ram_mib_in(argv)`
    read `--cache-ram N` off the engine's own line — the process's truth, the way its window and
    slots come off /props; the daemon recovers it for a lane it did not spawn, cached by pid.
(b) An unknown grant (0) WITHHOLDS the per-token reading: probe `serving.footprint.unmeasured`,
    no observe, no record written, the previous record stands — an absence stays an absence.

Test: `cache_ram_is_read_off_the_engines_own_argv` (both spellings, absent/malformed = None,
0 stays 0).

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

Copy link
Copy Markdown
Contributor Author

Condition taken, at head adcd3c8, in shape (a) with (b) as the guard:

  • (a) recovered off the engine's own argv. lane_process::command_args(pid) (sysinfo, a single-pid refresh) + pure cache_ram_mib_in(argv) read --cache-ram N off the canonical pid's line — the process's truth, the way its window and slots come off /props. The daemon uses it when the control has no spawn fact (launched_prompt_cache_mib().or_else(adopted_prompt_cache_mib)), cached by pid so an adopted engine costs one read, not one per tick. I chose argv over the custody record because the M5's running engine (pid 56926, spawned 00:05 by a pre-PR core) has no record field to recover from — argv covers it tonight; a record field would only cover engines spawned after this lands.
  • (b) an unknown grant withholds the reading. serving.footprint.unmeasured probe, no observe (which would also RETIRE the record on a None sample), no record written; the previous record stands.
  • Test cache_ram_is_read_off_the_engines_own_argv: both spellings, absent/malformed = None, 0 stays 0 (a real value).

On the M5's 262,727 record: accepting the detour and saying so. With (a) the deploy adopts the running --parallel 2 --cache-ram 14396 engine as-is (slots ≥ target never relaunch), the snapshot reads 2 lanes / 14,396 from the engine, and the first honest reading (~1 min after boot) replaces the record; the boot plan is wrong for that minute but nothing relaunches on it. I will read serving.footprint.measured per_token_measured and serving/status lanes against ps after the deploy and post the receipt.

@github-actions github-actions Bot added size: L and removed size: M labels Sep 20, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head adcd3c8. The condition is taken as (a) with (b) as the guard, and in the right order: the adopted engine's grant is its own argv (single-pid sysinfo refresh, cached by pid since argv never changes for a pid's life), the spawn fact wins when present, and an unknown grant WITHHOLDS the reading with serving.footprint.unmeasured — no observe, so the record is neither written nor retired. Both argv spellings and the malformed cases are pinned. One nit, not a condition: cache_ram_mib_in returns Some(0) for a literal --cache-ram 0 ('0 is a value'), but the snapshot's 0 means unknown, so such a launch would be unmeasured forever — harmless today because our launches floor the grant at CACHE_RAM_HARD_FLOOR_MIB, worth one line in the snapshot doc so the two zeros are not mistaken for one. Merge on green.

… mapping test keeps its degraded tail, the footprint resolver tests take the grant (and pin that it is credited), the two zeros named in the snapshot doc (Cormac's nit)

The cargo test job runs `--no-run --message-format=json > lib-artifacts.jsonl`, so its log showed
"9 previous errors" and none of them; the windows-msvc check job's plain output carried them.

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

Copy link
Copy Markdown
Contributor Author

Pushed 905a6d1: the nine test-build errors (my new test had swallowed the original mapping test's degraded tail; the footprint-resolver tests still called the 3-arg resolver) plus your nit — the two zeros are named in the snapshot doc and its TS mirror. Also pinned in the resolver test that the grant is credited on top of the peak and nothing is charged with no lanes.

A CI defect worth a card in the deploy lane: the cargo test job runs --no-run --message-format=json > lib-artifacts.jsonl, so a compile failure prints only "could not compile … due to 9 previous errors" and the errors live in a file nobody uploads; I read them off the windows-msvc job's plain cargo check log instead. A red job must show its errors (jq -r 'select(.reason=="compiler-message") | .message.rendered' lib-artifacts.jsonl on failure would do).

A fresh word at 905a6d1 when green, please.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head 905a6d1. The delta from adcd3c8 is tests and the doc line: the mapping test's degraded tail is back where it was, the resolver tests pass the grant, the two zeros are named. Behaviour unchanged from the head I approved. Merge on green. Noted on the CI shape: a red cargo test job that prints no errors because --message-format=json goes to a file is its own defect — a failure that cannot be read is the 'success signal that cannot report failure' class (36e8fdd6); worth a card.

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