Skip to content

fix(serving): a header-declared KV rate is physics — a measured per-token cost may not raise it; the excess is fixed residency, named on a probe - #4226

Merged
joelteply merged 5 commits into
canaryfrom
fix/a-header-kv-rate-is-physics-a-measurement-cannot-raise-it
Sep 19, 2026
Merged

joelteply merged 5 commits into
canaryfrom
fix/a-header-kv-rate-is-physics-a-measurement-cannot-raise-it

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Measured 2026-09-19 on the M5 (build 97f480e, one lane at 67,584): the GGUF header
declares 65,536 B/token f16 → 32,768 at the launched q8 cache type. The footprint sample
read 55,925 B/token — the draft model's KV, the vision projector and the engine's fixed
buffers divided over one lane's tokens — corrects() fired (> 1.25 ×), and the plan
carried 44,740. At that rate two lanes do not fit a 30 GB budget; at the header rate the
same budget holds two lanes at 84k and 34 GB holds three. The correction bites hardest at
the smallest geometry, where fixed bytes per token are largest, so a shrunk lane raised its
own rate and pinned the shrink: a measurement that can only rise, third instance.

"The process beats the arithmetic" (#4165) was written for the weights-scaled GUESS. Against
a header rate the process cannot know better than the file: the only thing the sample can
add is a FIXED term. footprint_for now keeps the header rate whatever the sample says and
raises serving.footprint.excess_is_fixed (header rate, measured) when a sample would have
corrected it — the signal a fixed-residency term can learn from later. A model without a
header rate still learns from the process as before. kv_rate_for_plan is the pure law,
tested. Card 1c0b60a9.

Test plan

  • CI: cargo test -p continuum-core --lib serving_daemon (extended: the measured-cost test now pins kv_rate_for_plan in both arms)
  • Live on the M5: serving.footprint.measured per_token_estimate reads 32,768 and stays there; serving.footprint.excess_is_fixed fires with the measured figure; serving.plan lanes 2 at usable ≥ 30 GB, 3 at ≥ 34 GB.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…red per-token cost may not raise it; the excess is fixed residency, named on a probe, never per-token

Measured 2026-09-19 on the M5 (build 97f480e, one lane at 67,584): the GGUF header
declares 65,536 B/token f16 → 32,768 at the launched q8 cache type. The footprint sample
read 55,925 B/token — the draft model's KV, the vision projector and the engine's fixed
buffers divided over one lane's tokens — `corrects()` fired (> 1.25 ×), and the plan
carried 44,740. At that rate two lanes do not fit a 30 GB budget; at the header rate the
same budget holds two lanes at 84k and 34 GB holds three. The correction bites hardest at
the smallest geometry, where fixed bytes per token are largest, so a shrunk lane raised its
own rate and pinned the shrink: a measurement that can only rise, third instance.

"The process beats the arithmetic" (#4165) was written for the weights-scaled GUESS. Against
a header rate the process cannot know better than the file: the only thing the sample can
add is a FIXED term. `footprint_for` now keeps the header rate whatever the sample says and
raises `serving.footprint.excess_is_fixed` (header rate, measured) when a sample would have
corrected it — the signal a fixed-residency term can learn from later. A model without a
header rate still learns from the process as before. `kv_rate_for_plan` is the pure law,
tested. Card 1c0b60a9.

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

Copy link
Copy Markdown
Contributor Author

CONDITIONAL — reviewed at exact head da6aa08.

RIGHT: kv_rate_for_plan — a header-declared rate is physics and a footprint sample may never raise it. The M5's 55,925 → 44,740 "correction" is exactly the shape that starved it, and the four-arm test pins it (header wins; a guess still learns). The probe naming the excess is the right observability.

THE CONDITION: the excess is real memory and the plan now DROPS it. On the M5's own numbers, (55,925 − 32,768) B/token × 67,340 ≈ 1.56 GB per lane of fixed residency (draft KV, projector, buffers) that peak_resident_bytes no longer counts, so the fit check is optimistic by ~1.5 GB per lane — two lanes at 84k "fit 30 GB" on paper with ~3 GB unaccounted. That is the "correct parts composing into silence" class: a measured real term set aside with a note that a later term can learn from it. Either of these closes it:
(a) carry it: the excess becomes a FIXED per-lane term — (measured − header).saturating_mul(window) folded into compute_buffer_per_lane (or a new fixed_per_lane_bytes on the footprint) so the rate stays physics and the residency stays counted; the probe already has both numbers; or
(b) say it where the plan is read: serving.plan carries fixed_excess_bytes_per_lane and the doc names the optimism in GB, so the next Eco crossing on the M5 is not another mystery.
(a) is a few lines and the right one; (b) is the honest minimum. Test to add for (a): the M5 shape (header 32,768, measured 55,925, window 67,340, 30 GB) fits fewer lanes than the header-only plan and more than the raised-rate plan.

Not a condition: apply_kv_quantization now runs before the header/measured split — read it as intended (the quantized rate is the header's physics too), but it means a quantized model's measured > rate will fire the excess probe more often; fine, that is what the probe is for.

…CARRIED as fixed residency per lane, never dropped — fixed_per_lane_bytes on the footprint, counted in compute_buffer_per_lane (Cormac's condition on #4226)

(55,925 − 32,768) × 67,340 ≈ 1.56 GB per lane on the M5. Runtime-learned, serde/ts skipped so the row and the bindings are unchanged. Test: across 28–46 GB budgets the carried plan fits ≤ the header-only plan and ≥ the raised-rate plan, strictly fewer than header-only somewhere.

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 08f5301; the condition is met as (a), merge on green.

Checked: fixed_per_lane_from = (measured − header).saturating_mul(measured window) — the M5 shape lands at ~1.56 GB (the test's 1.50–1.62 GB band), and it is folded into compute_buffer_per_lane, so window_within and peak_resident_bytes both see it; no wire or ts-rs change (serde/ts skipped). The lanes test pins the ordering I asked for: header-only ≥ carried ≥ raised-rate across 28–46 GB, strict somewhere — so the fix neither drops the residency nor re-inflates the rate. The probe now carries measured_window and fixed_per_lane_bytes, which is the number a later fixed-residency model learns from.

One receipt to read on the M5 after it lands: serving.plan at the same 30 GB should show lanes between the pre-#4226 raised-rate count and the header-only count, and the Eco band untouched (#4222 already holds the cache side).

@joelteply
joelteply enabled auto-merge (squash) September 19, 2026 14:03
joelteply and others added 3 commits September 19, 2026 09:17
…s the code path, not a test-only mirror; apply_measured_cost and measured_per_token had no callers left and are gone (CI on #4226)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…lan, not ordered against the raised-rate plan — a fixed cost bites at small lane counts, a raised rate at large ones (31 GB: carried 1, raised 2); the M5's own numbers pinned

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 b4dc35f; the delta from 34317a4 is a routing change with the same answers, and the approval carries.

Checked: kv_rate_for_plan keeps both former arms — (header_known, _) returns the header rate untouched, (heuristic, Some(m)) is the old apply_measured_cost path through kv_per_token_from_measured, (heuristic, None) the estimate. fixed_per_lane_from still runs only under a known header, against the header rate the plan now carries. measured_record is read once and shared by both terms, and measured_per_token / apply_measured_cost leave with no callers — nothing unwired rides in.

One nit, not blocking: the doc line on kv_per_token_from_measured still reads "Pure half of [apply_measured_cost]" — a dangling intra-doc link now (rustdoc warning, not cargo check), and the paragraph that led apply_measured_cost ("THE PROCESS BEATS THE ARITHMETIC…") now leads kv_rate_for_plan. Both true statements, one stale name; fold on your next push or leave for the sweep.

Merge on green; auto-merge armed on your side per your note.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head f1b3a0a; test-only delta from b4dc35f, and the approval carries.

The dropped assertion (carried ≥ raised across 28–46 GB) was asserting an ordering that is not a property — a fixed term bites at small lane counts, a raised rate at large ones — so the exit-101 was the test being wrong, not the plan. What replaces it is stronger: header ≥ carried everywhere, strict somewhere, and the M5's own points pinned (2/3 header, 1/2 carried, 1/2 raised at 30/34 GB). Merge on green.

@joelteply
joelteply merged commit 1d994a7 into canary Sep 19, 2026
6 checks passed
@joelteply
joelteply deleted the fix/a-header-kv-rate-is-physics-a-measurement-cannot-raise-it branch September 19, 2026 14:58
joelteply added a commit that referenced this pull request Sep 19, 2026
…budget; a roster short of warm slots is re-home evidence (the M5 could never reach two lanes) (#4230)

* fix(serving): one headroom, not three — the plan sizes to the budget 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

* fix(serving): no production budget hands the plan 1.0 — Performance keeps 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

* docs(serving): the Performance fraction is 0.96 in the two comments that said 1.0

Co-Authored-By: Claude Fable 5.1 <[email protected]>
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