Repository navigation
fix(routing): relaunch safety — debounce cold-dispatch kick, real-free cold-load admission, safe-by-default flags - #389
Conversation
… storm kickColdDispatch fired TriggerModelSwaps (which takes the registry WRITE lock via expire/reservePendingModelLoads) on every queue enqueue, turning an O(1)/tick model-swap pass into O(request volume) write-lock acquisitions and starving readers under load. Coalesce the per-enqueue kick into a single-flight + min-interval gate (coldKickState): while a swap pass is in flight, all kicks drop; after it completes, kicks within the min-interval drop. A burst of N enqueues now collapses into one swap pass. Interval is env-tunable via EIGENINFERENCE_COLD_DISPATCH_MIN_INTERVAL (default 1s). TriggerModelSwaps is already idempotent (only loads models with queued demand and no warm provider, de-dups in-flight loads), so dropping redundant kicks loses nothing.
freeMemoryAdmits' cold-load branch (model on disk, not loaded, no in-flight requests) admitted a load when modelSizeGB + kvCacheGB + 4 <= TOTAL memory — i.e. it assumed the provider would LRU-evict *everything* down to bare OS overhead. The provider's authoritative ModelLoadAdmission gate instead checks against REAL FREE memory (total - resident, minus an activation + KV headroom), so the coordinator over-admitted cold loads the provider then OOM-rejected. Mirror the provider gate conservatively: realFree = totalMemoryGB - gpuMemoryActiveGB - coldLoadOSReserveGB (GPU cache is reclaimable, left as free); required = modelSizeGB + kvCacheGB + activationReserveGB (3.0). For any gpuMemoryActiveGB >= 0 this admits a strict subset of the old check, so it is monotonically safer and never over-admits. Added a strictly-safer-than-total invariant test plus OOM-regression and admit-when-fits cases. TODO noted in code: the clean long-term fix is for the provider to report freeForLoadGb in BackendCapacity so the coordinator consumes a single source of truth instead of re-deriving free memory.
Both autonomous load paths that drove the routing-v2 meltdown are now opt-in: - EIGENINFERENCE_COLD_DISPATCH now defaults to FALSE (added envEnabledDefaultFalse). Cold-dispatch spill + the proactive swap kick stay off until explicitly enabled with =true. QUEUE_BEFORE_SHED remains default-true. - WARM_POOL_OBSERVE_ONLY now defaults to TRUE: the warm-pool controller still computes targets and emits telemetry but issues no load_model actions unless an operator opts out with =false. Updated the flag/config default tests accordingly.
The Common Pitfalls / Mutation Checklist described the provider load gate as requiring estimatedMemoryGb * 3.0 headroom. That heuristic is gone: ModelLoadAdmission.canLoad now admits when weights + (activation reserve + min serveable KV) <= real free memory (clamped to OS-available, under the 90% unified cap) — no 2.86x/3x multiplier. Also note the coordinator's freeMemoryAdmits now mirrors this conservatively (Fix 2).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d8383db96
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if snap.availableOnDisk && !snap.modelLoaded && snap.totalPending == 0 { | ||
| const osReserveGB = 4.0 | ||
| return snap.modelSizeGB+kvCacheGB+osReserveGB <= snap.totalMemoryGB | ||
| realFree := snap.totalMemoryGB - snap.gpuMemoryActiveGB - coldLoadOSReserveGB |
There was a problem hiding this comment.
Don't count evictable idle models as unavailable memory
When a provider has only idle resident models and receives a request for another on-disk model, ensureModelLoaded can evict those idle slots before loading the requested model. Subtracting all GPUMemoryActiveGB here treats those evictable weights as non-reclaimable, so a 64 GB provider with a 45 GB idle model will reject a 16 GB cold load even though the provider would unload the idle model and serve it; with EIGENINFERENCE_QUEUE_BEFORE_SHED=false this becomes an immediate 429, and with the default it adds avoidable queue/heartbeat latency instead of direct cold dispatch.
Useful? React with 👍 / 👎.
| const osReserveGB = 4.0 | ||
| return snap.modelSizeGB+kvCacheGB+osReserveGB <= snap.totalMemoryGB | ||
| realFree := snap.totalMemoryGB - snap.gpuMemoryActiveGB - coldLoadOSReserveGB | ||
| return required+activationReserveGB <= realFree |
There was a problem hiding this comment.
Mirror the provider load headroom
For near-limit cold loads with small max_tokens, this equation can still admit requests the provider rejects: ModelLoadAdmission.requiredToLoadGb uses activation reserve plus a fixed minimum serveable KV headroom, and the provider's reserve is max(configReserve, physical-hardCap) for the 90% unified-memory cap, while this code uses the request's often-sub-1GiB KV estimate and a flat 4 GB reserve. A large model that fits total-4GB but not the provider's cap-aware load gate will be routed and then fail at load time, preserving the over-admission path this change is intended to close.
Useful? React with 👍 / 👎.
…table Codex #389 P2: the cold-load branch of freeMemoryAdmits subtracted ALL gpuMemoryActiveGB, treating resident models as non-reclaimable. But that branch is gated on totalPending == 0 — no in-flight requests — so every resident model is idle and the provider LRU-evicts it to load the requested one. The old subtraction wrongly rejected cold loads onto boxes whose only resident models were idle (e.g. a 64GB box with a 45GB idle model refusing a 16GB load), adding queue/heartbeat latency by default or an outright 429 with QUEUE_BEFORE_SHED=false. Drop the gpuMemoryActiveGB subtraction in the cold branch: idle weights are free, so the model only needs to fit in (total - OS reserve) plus the activation reserve the provider also requires. The activation reserve (+3GB over the old total-only check) remains the meaningful safety, so this is still a strict subset of the pre-fix admits (never over-admits relative to before). The standard/serving branch (totalPending > 0) still counts active memory as unavailable, since a serving model can't be evicted. Tests: repurpose the over-active-memory test to assert idle memory is evictable (admit), add a serving-branch test that still rejects, keep the strictly-safer grid invariant. Documents the residual Codex #389 P2 (cap-aware reserve) whose clean fix is the provider reporting freeForLoadGb (tracked follow-up).
|
Addressed the Codex review in P2 #1 — evictable idle memory (fixed). The cold-load branch is gated on P2 #2 — cap-aware load headroom (documented residual). Agreed: re-deriving the provider's Full coordinator suite green; gofmt clean. |
Routing v2 relaunch safety
Follow-up to the routing-v2 production incident (write-lock storm + OOM cold loads). Stacked on #387 (prefill-overflow gate); base is
fix/prefill-tps-coordinator. Together the stack is the Tier-1 relaunch posture: prefill gate fixed, cold-dispatch off, warm-pool observe-only — plus the safety fixes so Tier-2 (turning cold-dispatch back on) is safe later.Changes
1. Debounce the cold-dispatch kick (write-lock storm) —
coordinator/api/cold_dispatch.go,server.gokickColdDispatchfiredTriggerModelSwaps(registry write lock) on every enqueue → O(request volume) lock acquisitions → reader starvation (/v1/stats503s, stale heartbeats). NewcoldKickStatecoalesces into single-flight + min-interval: a burst of N enqueues collapses to one swap pass. Interval viaEIGENINFERENCE_COLD_DISPATCH_MIN_INTERVAL(default 1s). IdempotentTriggerModelSwapsmeans dropped kicks lose nothing.2. Cold-load admission uses real free memory, not total (OOM loads) —
coordinator/registry/scheduler.goThe cold-load branch of
freeMemoryAdmitscheckedweights + kv + 4 <= TOTAL(assuming the provider evicts everything), while the provider's authoritativeModelLoadAdmissiongate checks against real free memory. Coordinator over-admitted →insufficient memory to load model→ jetsam OOM → WSread_errordisconnects. Now:realFree = total − gpuMemoryActiveGB − 4and requireweights + kv + 3 (activation reserve) <= realFree. GPU cache is reclaimable so it is not subtracted.TODO left in code: the clean long-term fix is for the provider to report
freeForLoadGbinBackendCapacity(single source of truth) — intentionally not done here (no protocol change).3. Safe-by-default flags —
coordinator/api/cold_dispatch.go,coordinator/registry/config.goEIGENINFERENCE_COLD_DISPATCH→ opt-in (default false). It drove the meltdown; enable only after the safety fixes are validated.WARM_POOL_OBSERVE_ONLY→ default true. Warm pool plans + emits telemetry but issues noload_modelactions unless explicitly enabled.EIGENINFERENCE_QUEUE_BEFORE_SHEDleft default-true.4. Docs —
AGENTS.mdCorrected the stale
estimatedMemoryGb * 3.0/ "3× memory gate" claims (pitfall note + mutation checklist) to the realModelLoadAdmissiongate (weights + activation reserve + min serveable KV ≤ real free, no multiplier) and notedfreeMemoryAdmitsnow mirrors it conservatively.Tests
TestColdKickCoalescesInFlight,TestColdKickRunsAgainAfterInterval,TestColdDispatchMinInterval,TestEnvEnabledDefaultFalse,TestColdDispatchFlagDefaultsOff,TestFreeMemoryAdmitsColdLoadStrictlySaferThanTotal(grid),…RejectsOverActiveMemory,…AdmitsWhenRealFreeFits,TestReadConfigWarmPoolObserveOnlyOptOut.go build ./...clean;go test ./...green (incl.registry,api,routingsim,internal/e2e);gofmt -lempty;-raceclean on the kick tests.Note on stacking
Base is
fix/prefill-tps-coordinator(#387). After #387 merges to master I'll rebase this onto master so it reviews as a clean standalone diff.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.