Repository navigation
fix(serving): demand-derive served window (cap KV), not budget-max — cross-node swap/wedge fix (#234) - #2047
Merged
Merged
Conversation
…-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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cross-node serving-QoS fix (M5 + BigMama).
plan_servingmaxed 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