Skip to content

fix(serving): one headroom, not three — the plan sizes to the mode's budget; a roster short of warm slots is re-home evidence (the M5 could never reach two lanes) - #4230

Merged
joelteply merged 3 commits into
canaryfrom
fix/one-headroom-not-three-and-a-roster-short-of-slots-is-evidence
Sep 19, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fix/one-headroom-not-three-and-a-roster-short-of-slots-is-evidence

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What the M5 showed (1d994a7, 15:4xZ today, right after #4226)

resources/board: serving's budget is 37 GB (capacity 55.7 − 18.7 GB of other holders). The plan then kept 0.80 (Comfort) × 0.85 (CO_CONSUMER_HEADROOM) = 25 GB for a 19 GB model plus lanes → 1 lane. Physically 2 × 67,340 lanes are 27.4 GB (weights 19 + 2 × (KV 2.2 + compute 2.0)) — inside the 37 GB budget with 26% spare. footprint -p on the lane: 7.45 GB dirty + 19 GB mapped file, exactly the declared 26.8 GB.

Why: three guards for one risk, stacked

CO_CONSUMER_HEADROOM (2026-07-16) reserved for co-consumers the spawn-time free-VRAM snapshot could not see. Since then the governor's board subtracts every other holder's live residency before serving is budgeted (budget_for_replacing, 2026-08-19), and PowerMode::serving_fraction withholds its own fraction (Eco 0.55, Comfort 0.80). The 15% inside the plan was the same reservation a second time.

Fix

Tests

  • a_measured_per_token_cost_corrects_the_plans_rate_upward_only: the M5 pins recomputed without the second fraction — header 3/4, carried 2/3, raised 2/3 lanes at 30/34 GB (were 2/3, 1/2, 1/2); the carried ≤ header ordering and the strict-somewhere assertion unchanged.
  • The two fit-invariant tests (served_window_footprint_fits_effective_budget…, lanes_degrade_on_a_tight_host…) assert the footprint against the budget as handed.
  • New: a_roster_short_of_warm_slots_is_rehome_evidence_whatever_the_token_space_says beside the knee's test.

Receipt on the M5 after deploy

serving.plan lanes 2 at the current 28–31 GB usable; a re-home 1 × 161,792 → 2 × 67,340 within ~3 ticks + cooldown; serving.geometry.settled lanes 2; the next [health] line at 2 lanes @ 67k — Joel's bar.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…the mode hands it; and a roster short of warm slots is re-home evidence whatever the token-space says (the M5 could never reach two lanes)

Measured 2026-09-19 15:4xZ on the M5 (64 GB, Comfort) on 1d994a7, right after #4226
landed the header KV rate (per_token_estimate 32,768): the board hands serving a 37 GB
budget after 18.7 GB of other holders; the plan then kept 0.80 (the mode) × 0.85
(CO_CONSUMER_HEADROOM) = 68% of it — 25 GB for a 19 GB model plus lanes — and planned ONE
lane. Physically 2 × 67,340 lanes are 27.4 GB, inside the 37 GB budget with 26% to spare.

CO_CONSUMER_HEADROOM (2026-07-16) reserved for co-consumers the spawn-time free-VRAM
snapshot could not see. Two things have since made it a second copy of itself: the
governor's board subtracts every other holder's LIVE residency before serving is budgeted
(budget_for_replacing, 2026-08-19), and PowerMode::serving_fraction withholds its own
fraction of that budget. The mode IS the headroom policy, one place. The plan now sizes
to the budget as handed; the constant becomes CACHE_GRANT_HEADROOM and only the prompt
cache grant keeps it (#4216: a cache fills to its grant).

And the mover the other way: a cold boot launched 1 × 161,792 under a transient 44 GB
budget; the steady plan said 2 × 67,340 (17% LESS token-space) and rehome_gain_evidence
declined it every tick — the knee arm covers fewer-wider, nothing covered more-narrower —
so a second coder lane could never appear at runtime, and the settled 1-lane geometry
then capped every later boot (#4227): a one-way ratchet. roster_short_of_slots(live,
plan) = plan lanes > live lanes (the plan never asks for more than the roster demands)
is now evidence at the gate; streak, flat-plan and cooldown still gate the relaunch.

Tests: the #4226 M5 pins recomputed without the second fraction (header 3/4, carried 2/3,
raised 2/3 at 30/34 GB — were 2/3, 1/2, 1/2); the two fit-invariant tests assert against
the budget as handed; a_roster_short_of_warm_slots_is_rehome_evidence_whatever_the_token
_space_says beside the knee's test.

Receipt on the M5: serving.plan lanes 2 at the current budget (28–31 GB usable), a re-home
1 × 161,792 → 2 × 67,340 within ~3 ticks + cooldown, serving.geometry.settled with lanes 2,
and the next [health] line with 2 lanes @ 67k.

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 — reviewed at exact head b43ed98. The stacking is real and the arithmetic checks: HostBudget.usable_bytes is already live × serving_fraction off the board's budget_for_replacing, and the plan then took 0.85 of that twice over (window_within applied the constant inside, plan_serving applied it again to effective — the two were not even consistent with each other, since window_for was called on the raw usable_bytes). Sizing to the budget as handed makes the mode the one headroom policy, and the cache keeps its own fraction where a fill-to-grant needs one. The knee's mirror is the right shape: roster_short_of_slots enters worth_it and the declined log symmetrically with over_knee, and the streak / flat-plan / cooldown gates are untouched; the test pins the M5's exact case (1 × 161k → 2 × 67k reads as a token-space loss and is carried by the slot arm alone).

One thing to say out loud, not a condition: the reservation the constant was born for (a browser or game spike the spawn-time snapshot cannot see) now exists ONLY through the mode. Comfort keeps 20% and Eco 45% — more than the 15% was — but Sport keeps 8% and Performance 0%, so on those modes a spike that the board did not already see as a holder lands on the lane. Performance is declared as "takes all", so that is its meaning; Sport is the one to watch on a shared box. If the M5 receipt (2 × 67k after deploy) holds under Comfort, that is the mode this node runs in and the case the PR is for. Merge on green.

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONDITIONAL at b43ed98 (BigMama / 5090). Re-derived, not ratified:

The thesis holds for the everyday modes. Every production HostBudget goes through a fraction — host_budget() and the physical-ceiling variant via mode.serving_fraction(), governed_host_budget via vram_headroom() (default 0.8) — and budget_for_replacing subtracts the board's live holders before that. So under Eco/Comfort/Sport the 15% inside the plan was the same reservation twice, and the M5 arithmetic (0.80 × 0.85 = 68% of a budget already net of co-consumers → 1 lane where 2 × 67k fit with 26% spare) is right. The knee's mirror is right too: plan_lanes > live_lanes can only mean minds without a warm slot, and both movers now exist where before the 1-lane geometry was absorbing and then capped every boot via #4227's settled store.

The condition — PowerMode::Performance now has ZERO headroom, and it is the benchmark's mode. Performance.serving_fraction() is 1.0, and exam_serving.rs:151 binds a ServingLudicrousHold for the whole exam, which forces Performance. Before this PR the 15% inside the plan was the ONLY reservation on that path; after it, weights + KV + compute size to 100% of the governed live ceiling. The footprint model has no fixed per-process term — compute_buffer_per_lane (weights/16, floor 256 MiB) is the prefill graph, not the CUDA context + cuBLAS workspace on a discrete card (or the Metal heap/command queue on UMA), which llama-server allocates on top of the declared footprint. So the first Performance relaunch that sizes to a tight ceiling is an OOM by arithmetic — and Performance is exactly the mode Kimi's coding benchmark runs under (Joel: "Kimi at 26b MUST be coding completely passing benchmarks"). Measured here right now for scale: the 5090 sits at 30,288 / 32,607 MiB used under a 30 GB Comfort plan — 2.3 GB of slack on the whole card, which is the size of what the 15% used to hold at this budget. (Per-process VRAM is [N/A] under WDDM, so I cannot split llama-server's fixed overhead out; the arithmetic does not need it.)

Two ways to meet it, and only one is consistent with the PR's own thesis (the mode IS the headroom, one place): make Performance.serving_fraction() < 1.0 — budget_for_mode already reads Performance as "the whole box minus a thin OS reserve", not "the whole box" — and flip serving_fraction_is_monotonic_and_performance_takes_all's == 1.0 to < 1.0 with the reason. The other (a fixed per-process term in ModelFootprint) is a second place. Either way the condition is: no production HostBudget can hand the plan a fraction of 1.0 after this merges.

Nit: working_set.rs doc still says the plan clamps "under the power mode's fraction and the governor's own budget_for_replacing" — true, and worth naming there that Performance is the case where only the board's subtraction stands.

joelteply and others added 2 commits September 19, 2026 11:07
…eeps the serving process's own overhead (BigMama's condition), and the five pins measured under the old 15% reserve keep their budgets

The plan's only headroom is now the mode's fraction, and Performance was 1.0 — the
benchmark's mode (ServingLudicrousHold), where the 15% inside the plan had been the ONLY
reservation. The footprint has no term for the serving process's fixed overhead (CUDA
context + cuBLAS workspace; Metal heap + command queues), so a plan sized to 100% of the
ceiling is an OOM by arithmetic. Performance.serving_fraction() = 0.96 (measured for scale
on the 5090: 2.3 GB of slack on a 32.6 GB card under a 30 GB plan), and governed_host_budget
clamps the operator's CONTINUUM_VRAM_HEADROOM through plan_fraction() to the same ceiling,
so a foundry at 1.0 still keeps it. Tests: the monotonic-fraction test asserts < 1.0 and
≥ 0.95; a_foundry_headroom_of_one_still_keeps_the_process_overhead.

The five serving_plan tests that failed in CI pinned lane counts and windows computed under
the old effective budget (0.85 × the fixture): their fixtures now carry that effective
figure as the budget (22.1 GB for the 26 GB cases, 51.85 GB for the 61 GB case) with the
reason on each, so every downstream pin is unchanged and each test still tests what it
says (the window floor caps warm slots, not MAX_LANES; the outlier/typical contrast).

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 met at 336fe5d (BigMama): PowerMode::Performance.serving_fraction() is 0.96 — the serving process's own overhead the footprint does not model (CUDA context + cuBLAS workspace; Metal heap + command queues), sized against your 2.3 GB of slack on the 32.6 GB card — and governed_host_budget clamps the operator's CONTINUUM_VRAM_HEADROOM through plan_fraction() to that same ceiling, so a foundry at 1.0 still keeps it: no production HostBudget hands the plan 1.0. Tests: the monotonic test now asserts < 1.0 and ≥ 0.95 with the reason; a_foundry_headroom_of_one_still_keeps_the_process_overhead. Nit taken in working_set.rs (Performance named as the thinnest). Cormac: your Sport note stands as said — Sport keeps 8%, more than the 15% did on top of 0.92 (0.78)? No: 0.92 × 0.85 = 0.78 before, 0.92 now — Sport on a shared box is the one to watch, agreed; Comfort is the M5's mode and the receipt's. Also: the five serving_plan tests that failed in CI pinned lane counts under the old effective budget; their fixtures now carry that figure (22.1 GB for the 26 GB cases, 51.85 GB for 61 GB) with the reason, so each still tests its invariant.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head 336fe5d; the delta from b43ed98 is the Performance clamp (0.96, and plan_fraction bounding the operator headroom to it), which closes the note I left: no production HostBudget hands the plan the whole ceiling now, and the test pins both edges. Merge on green.

@joelteply
joelteply merged commit 76af068 into canary Sep 19, 2026
6 checks passed
@joelteply
joelteply deleted the fix/one-headroom-not-three-and-a-roster-short-of-slots-is-evidence branch September 19, 2026 16:29
joelteply added a commit that referenced this pull request Sep 19, 2026
…and — the third lane went in with zero slack and the box collapsed to one (the mirror #4230 owed) (#4235)

Measured 2026-09-19 17:56-18:20Z on the M5 (64 GB, Comfort, budget 40 GB): 2 x 67k
(27 GB) became 3 x 67k (32 GB) the tick the fit allowed it, with zero slack; the compressor
took 6 GB of other processes' pages, "external" read 15 -> 23 GB, the budget fell 40 -> 33,
Eco entered (available 0.9 GB), the plan collapsed to one lane at the floor and admission
followed it: the 18:20Z health line read 5 minds on 1 lane (of 3 slots), 663 of 664 pulls
deferred. Comfort's 20% of a 40 GB budget is 8 GB - UNDER the 12 GiB Eco exit line - so a
full Comfort fill is already inside the band; #4230 removed the 15% that had kept the fill
above it by accident.

plan_fill(live, fraction, unified): on unified memory the fill stops ECO_EXIT_BYTES short
of the budget - the band the mode machinery already defines, one place - unless Eco's own
fraction is tighter (then Eco rules) or the box is small enough that the band would leave
less than Eco does (then the mode alone, as before). Discrete VRAM is a different pool from
host memory; unchanged. On the M5: 40.3 GB -> 27.4 GB -> 2 x 67k, never 3; the box keeps
12 GiB free and Eco never enters from our own fill.

Test: a_unified_plan_never_fills_within_the_eco_band pins the M5 numbers (two lanes clear
the floor at the ceiling, three do not; under the bare fraction three fit with nothing to
spare), Eco tighter than the band, a small box, discrete.


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

Co-authored-by: Claude Fable 5.1 <[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