Skip to content

fix(serving): demand-derive served window (cap KV), not budget-max — cross-node swap/wedge fix (#234) - #2047

Merged
joelteply merged 1 commit into
canaryfrom
fix/serving-demand-window-cap
Jul 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/serving-demand-window-cap

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Cross-node serving-QoS fix (M5 + BigMama). plan_serving maxed the served window to fill the memory budget → -c 94190, ~33GB KV × lanes → swaps M5's 64GB Mac (5.08M swapouts, 1.77 tok/s) / wedges BigMama's 32GB 5090 (decode hang). Personas typically fill ~9-17k. Fix = one .min(BOOTSTRAP_WORKING_SET=16384) demand cap in the window derivation (serving_plan.rs).

Live-verified on M5: -c 94190→32768, llama RSS 38.9→26GB, free 4.5×, swapouts frozen (no new swap). All 20 serving_plan tests green (2 litigated budget-max tests updated to the demand contract, real invariants preserved: thinkable window, shed-on-squeeze, roomy=more-lanes).

Honest scope — this fixes SWAP/WEDGE, not tok/s. Post-deploy tok/s still ~0.36: the remaining bottleneck is re-prefill of large accumulated contexts (#205) + 4-persona over-subscription, NOT swap. Also a measured 61660-token outlier turn shows a flat 16k bootstrap truncates rare large contexts — the measured-p95 refinement (DEMAND_CEIL = max(BOOTSTRAP, p95+headroom)) is #234 A-next. BigMama verifies the un-wedge on the 5090 independently.

🤖 Generated with Claude Code

…-node swap/wedge fix (#234)

Root-caused 2026-07-26 (M5 + BigMama, Joel "address now"): plan_serving's
`window_for` maximized the served window to fill the memory budget — on a roomy
host that's tens of thousands of tokens (live: -c 94190), whose pre-allocated KV
is ~33GB × parallel lanes. On M5's 64GB Mac that SWAPS (5.08M swapouts → decode
collapses to 1.77 tok/s, 408s turns); the identical 94k×2 KV WEDGES BigMama's
32GB 5090 (500s generation, /health 200 but decode hung). Personas fill only ~9k
— the window was ~10× the working set, mostly-empty KV inducing the swap. The bug
is model-agnostic (bites any lane on any node), which is why one fix clears both.

Two static estimates conspired (serving_budget = 0.80×free snapshot; kv_per_token
tuned DOWN so big windows pass the fit-gate) — but re-tuning either just moves the
"always wrong somewhere" point and re-breaks #213/#214/#216. Instead: provision for
what personas USE, not for what RAM allows.

Fix (one min()): served_context_window = window_for(lanes).min(DEMAND_CEIL).max(MIN_SERVE_CTX)
where DEMAND_CEIL = BOOTSTRAP_WORKING_SET (= MIN_SERVE_CTX*8 = 16384 ≈ one persona
turn: ~9k assembled prompt + generation). This is the "B-now" cold-start prior; the
measured half — DEMAND_CEIL = max(BOOTSTRAP, p95(observed working set) + headroom),
feeding a throughput-degradation recognition loop into the existing tier-down — is
#234's A-next robustness layer. The cap only ever holds the window DOWN from the
budget-max, is bounded by the model ceiling in window_for, and refines UP with data
— never toward filling RAM. Anchored to the ONE runnable floor const, not a second
magic number; NOT the forbidden per-tier prompt clamp (it's a demand prior on
serving-lane residency, superseded by measurement).

Lane selection (shed-on-squeeze, concurrency-on-roomy) is UNTOUCHED — the cap
applies after lanes are chosen. Two litigated window-sizing tests updated from the
old "window scales with the budget" premise to the demand contract, preserving the
real invariants (mind gets a thinkable window; squeeze sheds a lane; roomy box buys
MORE lanes not a bloated KV cache). New regression test asserts the cap holds down
without inflating small-ceiling models up. All 20 serving_plan tests green.

Split (BigMama): M5 owns this window fix; BigMama verifies it un-wedges the 5090.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 3cd6393 into canary Jul 27, 2026
4 checks passed
@joelteply
joelteply deleted the fix/serving-demand-window-cap branch July 27, 2026 06:21
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