Skip to content

fix(serving): the host cache holds the ACTIVE roster's prompt states at the served window — not every seed on disk at its unclamped peak (the M5's 27 GB grant that filled the box, card 7b01ed65) - #4253

Merged
joelteply merged 2 commits into
canaryfrom
fix/the-cache-holds-the-active-rosters-states-not-every-seed-on-disk
Sep 20, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/the-cache-holds-the-active-rosters-states-not-every-seed-on-disk

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What broke

The grant's want was Σ peak_tokens × kv over every seeded mind (23 × 225k–505k tokens — the whole assembled context, not what a turn sends): hundreds of GB. So every affordability guard only carved the afford, and the grant was always "everything the box can spare": 14,396 MiB at 2 lanes, 26,806 MiB for a 1 × 2,048 lane at boot, 26,985 MiB on the fresh engine after #4251 deployed. The cache filled to it, raw available fell under the Eco line, the plan shed a lane, and both deploys this morning went dark (no room for a warm build), each reaping the lane (#4252 / b57b19fd).

The law (pure, tested): active_cache_states(population, served_ctx, active)

  • one state per active mind — the roster bound the spawner already enforces (bounded_by_warm_slots: lanes × MINDS_PER_LANE_STARVED_ABOVE); a mind beyond it is dormant and re-prefills when a slot wakes it;
  • each state = the largest prompt the mind actually sent (sent_peak; the unclamped peak only when nothing was ever sent), never more than the served window (a cached state cannot exceed the slot it was prefilled in);
  • the largest states are kept (the worst case must fit); an unknown bound (no lanes yet) keeps the population.

On the M5's shape: four states ≤ 67k at 32.9 KB/token ≈ 5.7 GB, not 27 GB. The affordability guards (OS floor, available, Eco exit band, CACHE_GRANT_HEADROOM) stay as the net — they are no longer the whole decision. The receipt serving.prompt_cache.derived carries population and active_bound beside citizens.

Test

the_cache_holds_the_active_rosters_states_not_every_seed_on_disk: 23 seeds on 2 lanes → 4 states ≤ window, the never-sent mind's peak clamped to the window and kept as the largest, the want under 8 GiB, and through prompt_cache_decision a demand-sized grant (< 9,000 MiB) below the afford.

What this makes true without anyone watching

plan + grant + floor fits the box because the grant is bounded by what the active minds can actually cache, so a full cache cannot walk the box into Eco, and a deploy finds room for a warm build beside the serving core (the tracker's "no warm build: 0.0 GiB free" line is the receipt that should stop appearing).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…at the served window — not every seed on disk at its unclamped peak (the M5's 27 GB grant that filled the box, card 7b01ed65)

Measured 2026-09-20 on the M5: the grant's want was Σ peak_tokens × kv over every seeded mind
(23 × 225k–505k tokens — the whole assembled context, not what a turn sends), i.e. hundreds of GB,
so every affordability guard only carved the afford and the grant was ALWAYS "everything the box
can spare": 14,396 MiB at 2 lanes, 26,806 MiB for a 1 × 2,048 lane at boot, 26,985 MiB on the
fresh engine after the fix deploy. The cache filled to it, raw available fell under the Eco line,
the plan shed a lane, and both deploys of the morning went dark with no room for a warm build,
each reaping the lane (b57b19fd). Joel: "Measurement seems dumb or out of sync, too hacky and
unstable."

The law, pure and tested (`active_cache_states`): one state per ACTIVE mind — the roster bound
the spawner already enforces (`bounded_by_warm_slots`: lanes × MINDS_PER_LANE_STARVED_ABOVE) —
each the largest prompt that mind actually SENT (`sent_peak`; the unclamped peak only when
nothing was ever sent), never more than the served window (a cached state cannot exceed the slot
it was prefilled in); the largest states are kept; an unknown bound (no lanes yet) keeps the
population. On the M5's shape that is four states ≤ 67k at 32.9 KB/token ≈ 5.7 GB, not 27 GB.
The affordability guards (OS floor, available, Eco exit band, CACHE_GRANT_HEADROOM) stay as the
net; they are no longer the whole decision. The receipt (`serving.prompt_cache.derived`) now
carries `population` and `active_bound` beside `citizens`.

Test: `the_cache_holds_the_active_rosters_states_not_every_seed_on_disk` — 23 seeds on 2 lanes
→ 4 states ≤ window, the never-sent mind clamped, the want under 8 GiB, and through
`prompt_cache_decision` a demand-sized grant (< 9,000 MiB) below the afford.

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 small condition — reviewed at exact head c0fef34 (checks running at read time).

The law is right and it is the same law as #4244/#4245 applied to the cache: the states the cache must hold are the ACTIVE roster's, one per mind, each what she actually sent (sent_peak, the unclamped peak only when she never sent), never larger than the slot it was prefilled in, the largest kept so the worst case fits. That turns want from "every seed on disk at 225k–505k" (hundreds of GB, so the afford was always the answer and the grant always everything the box could spare) into a demand number — 4 × ≤67k on the M5 — and lets the affordability guards be the net again instead of the rule. The through-the-decision assertion ("resident_demand_kv_estimate", desired < afford) is the discriminating one.

The condition, in active_cache_states: active == 0 keeps the WHOLE population — the astronomical want this PR exists to delete, reintroduced for the unknown case, and the test pins it (…, 0).len() == 23). The comment says "an unknown bound never shrinks the cache to nothing", but an absence is not a number in either direction: unknown must not mean "everything" any more than it means "nothing". On a real plan lanes is the target's and never 0, so today the branch is unreachable — which is exactly when a pinned wrong behaviour survives until the next caller passes 0 (a probe path, a cold derivation before the plan) and the grant is 26,985 MiB again with a green test beside it. Ask: unknown → the floor (MINDLESS_RESIDENT_FLOOR states, the smallest roster that can serve), and the assertion flipped to say so. Two lines and one assertion; merge on green once they are in.

@joelteply

Copy link
Copy Markdown
Contributor Author

Condition taken at fe17190: active == 0 keeps MINDLESS_RESIDENT_FLOOR states (the smallest roster that can serve), never the population; the doc says an absence is not a number in either direction, and the assertion is flipped to pin the floor. A fresh word at fe17190 when green, please.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head fe17190. The condition is taken exactly: unknown keeps the floor, never everything, and the assertion now pins that direction. Merge on green.

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