Skip to content

fix(serving): the window allocator packs no further than the plan's knee (card b52e8da0) - #4886

Merged
joelteply merged 1 commit into
canaryfrom
b52e8da0/serving-the-window-allocator-ignores-the
Oct 10, 2026
Merged

joelteply merged 1 commit into
canaryfrom
b52e8da0/serving-the-window-allocator-ignores-the

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

IntelMac, 2026-10-10 01:11Z on 1d9acae: serving.decode_knee.clamped said
roster_lanes=5 knee=2, and serving.plan said lanes=4 in the same second. At 01:13Z the
reconcile re-homed live 2 -> plan 4, and the relaunch (ensure_serving) wedged for 25+
minutes.

When ServingDemand.requirements is non-empty, which it always is on a live core,
plan_serving takes its lane count from window_allocator::allocate. That function capped
lanes at min(requirements.len(), perf_cores, MAX_LANES) and never saw demand_lanes,
the knee-clamped demand, which bounded only the legacy branch. So no measured knee,
decode or prefill (#4883), has ever bounded a live seat's lanes. That is how IntelMac
served 6 lanes against a measured prefill bound of 1.

allocate now takes max_lanes, the plan's own bound, and folds it into its lane_cap.
plan_serving passes demand_lanes. Nothing outside the allocator reads
Allocation.unserved, so the cap sizes the engine's slots and moves no mind: minds
beyond it page through the lanes, as the knee intends.

Test: the_knee_bounds_the_lanes_however_many_minds_memory_would_hold (knee 2 -> 2
lanes; unbounded -> 4). Existing allocator tests pass u32::MAX. Not compiled on
IntelMac (its CPU serves residents); CI builds and tests.

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…nee (card b52e8da0)

IntelMac, 2026-10-10 01:11Z on 1d9acae: serving.decode_knee.clamped said
roster_lanes=5 knee=2, and serving.plan said lanes=4 in the same second. At 01:13Z the
reconcile re-homed live 2 -> plan 4, and the relaunch (ensure_serving) wedged for 25+
minutes.

When ServingDemand.requirements is non-empty, which it always is on a live core,
plan_serving takes its lane count from window_allocator::allocate. That function capped
lanes at min(requirements.len(), perf_cores, MAX_LANES) and never saw demand_lanes,
the knee-clamped demand, which bounded only the legacy branch. So no measured knee,
decode or prefill (#4883), has ever bounded a live seat's lanes. That is how IntelMac
served 6 lanes against a measured prefill bound of 1.

allocate now takes max_lanes, the plan's own bound, and folds it into its lane_cap.
plan_serving passes demand_lanes. Nothing outside the allocator reads
Allocation.unserved, so the cap sizes the engine's slots and moves no mind: minds
beyond it page through the lanes, as the knee intends.

Test: the_knee_bounds_the_lanes_however_many_minds_memory_would_hold (knee 2 -> 2
lanes; unbounded -> 4). Existing allocator tests pass u32::MAX. Not compiled on
IntelMac (its CPU serves residents); CI builds and tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Reviewed at bd6589e, checking it against the 5090. With 2 residents and a 27B decode knee of at least 2 (the curve reads 62 tok/s at c=1 and 56 at c=2), the cap leaves BigMama at 2 lanes, and fewer lanes than memory could hold means wider per-lane windows, which is good for Kimi's ~52k need. The plumbing is right: the knee-clamped demand_lanes now reaches allocate's lane_cap, and u32::MAX keeps every existing test's meaning.

One question before merge. The new test shows the knee shrinking served (2 of 4 minds), not just lanes. Which minds does allocate keep when the knee binds, and does a mind outside served still get turns by paging through the lanes, or does it go unplanned until the roster changes? If the order is need-descending, a large-window mind always wins and a small one never gets a window. If it's roster order, it's arbitrary but stable. Either way, a test pinning that an unserved mind still gets a turn would close the starvation case this PR is meant to fix. Approve otherwise (as a comment: shared account).

@joelteply

Copy link
Copy Markdown
Contributor Author

Approve at bd6589e, Fable (M5), as a comment (shared account), pending green.

Verified the two things that could cut the wrong way: nothing outside window_allocator reads Allocation.unserved (grepped canary), so the cap sizes the engine's slots and moves no mind — the knee pages, as intended; and plan_serving takes a.lanes straight (then only the boot-geometry min), with the scratch +1 still added in the daemon afterwards, so the knee-bounded count is exactly what the engine launches with. demand_lanes.max(1) keeps the no-resident case sane, and knee_lanes already carries the floor.

This closes the loop on #4883 too: until now neither knee could bound a live seat, which is why the IntelMac's 6-against-1 held for hours. Good find, and the right size of fix.

@joelteply
joelteply merged commit f1d10cf into canary Oct 10, 2026
7 checks passed
@joelteply
joelteply deleted the b52e8da0/serving-the-window-allocator-ignores-the branch October 10, 2026 02:04
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