Repository navigation
Conversation
…ver-admit) On the latest release the gemma-4-26b-qat-4bit model accepts far more requests than the fleet can serve, then stalls them in the queue until the 120s timeout instead of shedding up front with a fast 429. Root cause: the capacity preflight (quickCapacityCheck) admits a provider whenever freeMemoryAdmits passes, which keys on KV-cache MEMORY. gemma-4-qat is 4-bit and bandwidth-bound: its decode runs well below the static estimate (the open MLX 4-bit MoE / sliding-window throughput issue) while its KV/token budget stays ~99.9% free — so the memory gate never bites. The Routing-v2 per-request decode floor that should have caught this is advisory-only (selectBestCandidate LockedFull keeps the full pool when nothing clears it) and the preflight didn't apply it at all. Net: the scarce resource (decode throughput) was never gated; the gated resource (KV memory) is never scarce for this model. Fix (opt-in, default OFF, throughput-only): add a decode-floor SHED gate to the preflight. When EIGENINFERENCE_DECODE_FLOOR_HARD_SHED=true and a floor is set, a provider whose PROJECTED per-request decode TPS (with this request added) falls below the floor is counted as a capacity rejection. An all-slow fleet then yields candidateCount==0 / capacityRejections>0, so the existing capacity-shed path returns a fast 429/Retry-After instead of admit-and-stall. - registry: decodeFloorTPS/decodeFloorHardShed fields + SetDecodeFloorShed. - scheduler.quickCapacityCheck: the shed gate, after freeMemoryAdmits, before candidateCount++ (reuses projectedPerRequestDecodeTPS — same math the advisory floor uses, so the two paths can't drift). - main: wire EIGENINFERENCE_DECODE_FLOOR_HARD_SHED (default off), reusing the EIGENINFERENCE_MIN_DECODE_TPS value (15) as the floor. Deliberately orthogonal to the memory cap / free_for_load_gb / resource-count gates — those guard the [metal::malloc] 499000 buffer-count crash + OOM on this same 4-bit model and must stay separate. This sheds on throughput, not memory. Immediate mitigation without this build: EIGENINFERENCE_TTFT_HARD_REJECT=true + EIGENINFERENCE_QUEUE_BEFORE_SHED=false restore the pre-v0.6.14 hard sheds. Tests: decode_floor_shed_test.go — reproduces the over-admission with the gate OFF (default), proves it sheds (cc==0, capRej>0) with it ON, still admits a fast fleet (no over-correction), and no-ops at floor 0. Full registry + api suites green.
Follow-up to the decode-floor shed gate. Independent review found the gate was necessary but not sufficient: forcing candidateCount==0/capacityRejections>0 in the preflight is mapped by the consumer to capacity_queue_spill under the default EIGENINFERENCE_QUEUE_BEFORE_SHED=true, so a naive operator setting only DECODE_FLOOR_HARD_SHED=true got NO behavior change — the slow-fleet request still queued and timed out (the exact symptom). Queueing a fundamentally too-slow fleet only defers the same outcome by 120s. Fix: Registry.DecodeFloorShedArmed() exposes the gate state; both consumer.go capacity-rejection spill sites now take the immediate-429 branch when armed (`queueBeforeShedEnabled() && !DecodeFloorShedArmed()`), so an armed coordinator sheds a too-slow fleet right away regardless of queue-before-shed. Tradeoff (documented): when armed, ALL capacity-queue spills 429 immediately, not just decode-floor ones — acceptable because arming the flag is an explicit opt-in to hard throughput shedding, and far simpler/safer than threading a separate rejection counter through 4 preflight wrappers + the alias-fallback path. Tests: - api/decode_floor_shed_http_test.go (HTTP, the gap the reviewer flagged): a slow-decode/large-KV provider + armed shed returns an immediate 429 UNDER the default queue-before-shed=true; the same fleet with shed disabled does NOT fast-429 (queues/dispatches — pre-fix behavior preserved). - registry: added fresh-warm-provider edge case (observedDecodeTPS==0 falls back to static decodeTPS, must NOT be shed) and strengthened the fast-fleet test to assert zero capacity rejections (no partial shed). Full registry + api suites green.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR adds decode-floor load-shedding (coordinator) and VLM/vision request accounting (provider); it is neutral-to-positive on security posture with no new attack surface introduced by the security-relevant files. Trust boundaries touched
Per-threat assessmentT-007 — Provider serves manipulated model outputs
ℹ️ Neutral. Vision token accounting ( One note: the comment "this token figure is ADVISORY … does not double-charge the bytes" is correct, but T-028 — Residual inference data in GPU memory
ℹ️ Neutral. T-041 — Cross-tenant prefix-cache sharing / TTFT timing oracle
ℹ️ Neutral. No changes to T-034 — Provider runs modified code while advertising a trusted identity
ℹ️ Neutral. T-032 — Solana wallet mnemonic exfiltration
ℹ️ Neutral. The new env-var block ( T-038 — ReadHeaderTimeout / MaxHeaderBytes
ℹ️ Neutral. T-041 (TB-006) — Profile signing identity exfiltration
ℹ️ Neutral. New attack surface not covered by an existing threatUnbounded
Open findings resolved by this PRNone — no SEC-* findings are closed by this diff. SEC-007 (weight-hash fail-open) and SEC-035 (prefix-cache cross-tenant channel) remain open and are not touched. 🔐 Threat model: |
…LM load The gemma-4 over-admission incident telemetry showed two distinct defects the original decode-floor shed both mis-calibrated and under-addressed: 1. Shed threshold was coupled to the soft quality floor (15 tok/s). On the 4-bit fleet a healthy, uncontended request projects ~15 tok/s at p50, so a shed floor of 15 would 429 traffic the fleet could actually serve — trading a latency problem for an availability one. Decouple the shed floor from the soft quality bar and default it lower (10), with its own EIGENINFERENCE_DECODE_FLOOR_SHED_TPS override. The soft floor (15) still only ranks providers, so a high bar there stays harmless. 2. The provider under-reported load for VLM/media requests. The vision path serves through the container's non-batched prepare/generate route and reserves memory via reserveVisionRequest instead of inserting an activeBridges entry, but capacity().activeRequests was activeBridges.count alone — so a provider busy with N concurrent media requests reported itself idle to the coordinator, inviting over-admission. Track in-flight vision requests and include them in the reported active count (and release them in cancelAll). Tests: decode-floor decoupling regression (a fleet in the 10-15 gap admits, the same fleet at a coupled-15 floor sheds); VLM capacity accounting (reserve bumps the count, release/double-release/rejected-reserve/nil-budget/cancelAll keep it exact).
…arge VLM tokens Two review findings on the prior commit: 1. (High) Queue-before-shed was bypassed for ALL capacity rejections when the decode-floor shed flag was armed, not just throughput sheds. quickCapacityCheck folds concurrency, memory/token-budget, and decode-floor failures into one capacityRejections counter, and the consumer bypassed the queue on the global DecodeFloorShedArmed() flag — so arming the flag would fast-429 a healthy but momentarily-full fleet that should wait for a slot (a queue-before-shed regression). quickCapacityCheck now also returns decodeFloorRejections (the throughput subset); the consumer bypasses the queue only when every rejection is a throughput shed (decodeFloorRejections == capacityRejections > 0). A concurrency/memory-full fleet keeps queueing. 2. (Medium) In-flight VLM/media requests were reported in NumRunning but not in the token-budget telemetry (activeTokenBudgetUsed / maxTokensPotential derive only from activeBridges). The coordinator's freeMemoryAdmits keys on those token fields when a budget is present, so large media requests were invisible to its memory/token gate. activeVisionRequests now maps id -> KV-token span (captured at reserve time) and the heartbeat folds that sum into the token figures. This is advisory routing signal only: the byte reservation in kvBudget (the 90% unified-memory cap) remains the authoritative OOM gate and is not double-charged, and the local text-submit gate (activeTokenBudgetUsed computed property) is unchanged so text admission is unaffected. Tests: a fast-but-budget-full fleet reports decodeFloorRejections < capacity Rejections and still queues (registry + HTTP); a pure-throughput shed still 429s; vision token span is summed into the budget, released exactly, and a rejected reserve charges nothing.
684e1ac to
bc51562
Compare
stopCurrentEngine() (the unloadModel teardown) released and cleared only the activeBridges KV reservations, leaving activeVisionRequests — the byte reservation in kvBudget and the vision token accounting — untouched. LRU eviction targets idle work so it rarely hits this, but a forced shutdown, standalone stop, test teardown, or any direct scheduler unload while a vision stream is in flight could leak the reservation until the async stream termination eventually fired releaseVisionRequest. Mirror the activeBridges teardown: release each kvBudget reservation and clear the map. release is idempotent, so a later stream-termination release no-ops. Test: unloadModel with in-flight vision requests clears the count and token accounting and frees the kvBudget reservation (a same-id re-reserve succeeds).
…e short-circuiting The capacity preflight applied the per-model concurrency gate BEFORE building the backend snapshot, so a concurrency-full provider incremented only capacityRejections and continued — the decode-floor classification (which needs the snapshot) never ran for it. Under peak saturation a full AND below-floor gemma fleet therefore reported decodeFloorRejections=0 < capacityRejections, so the consumer's pure-throughput-shed test failed and the request queued for up to 120s instead of fast-429ing — the exact stall the shed exists to prevent. Build the snapshot first, capture concurrency headroom under the lock, then apply the gates after unlock with decode-floor classification folded in: a full provider that is ALSO below the floor counts in decodeFloorRejections too, so a full+slow fleet sheds immediately. A full-but-FAST provider stays a plain capacity rejection (decodeFloorRejections < capacityRejections) so queue-before-shed still queues it — a slot will free and serve at an acceptable rate. A mixed fleet queues (the fast provider is worth waiting for). Tests: full+slow sheds (decodeFloorRejections==capacityRejections); full+fast queues (decodeFloorRejections==0); mixed queues (1<2). Verified the full+slow test fails under the pre-fix early-short-circuit ordering.
The decode-floor (throughput) shed was recorded identically to an ordinary
full-fleet rejection — reason_code machine_busy, outcome capacity_429 — so once
armed in prod there was no way to measure whether it was shedding the right
traffic or how often it fired. It 429s on a tuned, opt-in threshold, so its shed
rate must be observable separately from genuine capacity pressure (the gemma
incident was diagnosable precisely because model_shed / ttft_too_slow had their
own reason codes).
A pure throughput shed now records reason_code=decode_floor_shed and
outcome=decode_floor_shed, and surfaces a distinct client message ("overloaded
below the decode-speed floor"); an ordinary capacity shed is unchanged
(machine_busy / capacity_429). Both consumer sites (chat + generic) route
through two shared helpers — pureThroughputShed and capacityShedReason — so the
classification can't drift between paths.
Tests: capacityShedReason maps both cases; pureThroughputShed only fires when
armed AND every rejection is below-floor (disarmed/mixed/none → queue); the HTTP
429 test now asserts the distinct decode-floor message.
…x checkpoints (SDK pin) Moves libs/mlx-swift-lm to Layr-Labs/mlx-swift-lm#398 (90a87928), which carries #397 unchanged on main 093563be: a cached text request that cannot speculate (the Qwen builds' default card penalty of 1.5, any other penalty, a stop string, logprobs, logit_bias or a token constraint) records the MTP head's prompt history over its prompt chunks, so it stages the same resident and SSD checkpoints a speculating request stages. It never drafts, verifies or seeds a carry; its history is released once its prompt completes. The penalty and sampling are unchanged. The pin also brings dev from 67110e7b to main's 0.10.12 SDK merges (093563be), as the release candidate does. No provider source change: the bridge enables caching per request whatever the sampling, and the SSD store and resident tier take what the engine stages. Docs: prefix-cache.md invariant 9 (history observation follows cache eligibility, not speculation eligibility) and a failure-mode row; inference.md (the MTP prefix-checkpoint section). Changelog fragment qwen35-card-rows-donate-checkpoints.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

What this fixes
Reworked from the original decode-floor-only approach after diagnosing the gemma-4 over-admission incident against admin route + rejection telemetry. The diagnosis was independently verified (adversarial review of the telemetry + a second-tool pass), which corrected the original framing and surfaced a provider-side accounting bug. Two distinct, verified defects:
1. The decode-floor shed threshold was mis-calibrated
The shed floor was coupled to the soft quality floor (
MIN_DECODE_TPS = 15). But on the 4-bit gemma fleet, a healthy, uncontended request (backend_running=0) projects ~15 tok/s at p50 — so a hard shed at 15 would 429 roughly half of serveable traffic, trading a latency problem for an availability one (the same blunt-rejection failure mode as the emergencymodel_shedmitigation).This decouples the shed threshold from the soft quality bar and gives it its own
EIGENINFERENCE_DECODE_FLOOR_SHED_TPS(default 10). The soft floor (15) still only ranks providers — never rejects — so a high bar there stays harmless. A floor of 10 sits in the gap between the ~8-9 tok/s normal-load projection and the genuinely-degraded overpacked projection, so it sheds only when the entire eligible fleet is too slow to be useful, not when the fast half briefly drops out.The shed remains opt-in (
EIGENINFERENCE_DECODE_FLOOR_HARD_SHED=true); default behavior is unchanged (advisory).2. The provider under-reported VLM/media load
Vision/media requests serve through the container's non-batched prepare/generate path and reserve memory via
reserveVisionRequest, but they never insert anactiveBridgesentry.capacity().activeRequestswasactiveBridges.countalone — so a provider busy with N concurrent media requests reported itself idle to the coordinator, which routes on that count. That invites over-admission of concurrent media work and (separately) made a VLM-only model eligible for idle eviction mid-stream.This tracks in-flight vision requests in a dedicated set (inserted on a successful reserve, removed on release, cleared on drain) and reports
activeBridges.count + activeVisionRequests.countas the active concurrency.Why not the levers considered and dropped
Tests
coordinator/registry/decode_floor_shed_test.go: decoupling regression — a fleet projecting in the (10, 15) gap is admitted at shed floor 10 but would be shed at a coupled floor of 15 (proving the decoupling is load-bearing). Existing shed/no-shed/fresh-warm/zero-floor cases retained.provider-swift/Tests/ProviderCoreTests/BatchSchedulerVisionCapacityTests.swift: VLM accounting — reserve bumps the count; release, double-release, rejected-reserve, nil-budget, mixed text+vision sum, and cancelAll all keep the count exact.go test ./registry/ ./api/ ./cmd/...and the Swift vision suite pass.