Repository navigation
Provider: keep survivors' memory floors when the KV budget regrows - #2807
Merged
jonathan308 merged 8 commits intoDec 2, 2026
Merged
Conversation
The SDK now exposes EngineV2.admissionCeilings: the ledger capacity and the admissible ceiling from one lock hold. The provider's regrow floor reads it in a later commit. No provider code changes here.
Tests for the KV regrow's floor plan and the sub-1 GiB serving rule, with stubs that compile and keep today's behaviour, so each new test fails on its own assertion: - regrowPlan (pure): unknown floors, floors over budget, idle-only victims behind the regrow_idle_unload switch, transient vs durable budgets, the shortfall report, and the re-slice's own split wherever it keeps every known floor. - Both hosts: the regrow keeps floors, unloads only idle survivors when the switch is on, and refuses submits to a victim whose unload is pending. - Bridge: below 1 GiB the heartbeat advertises width 0 and a zero token budget and the service allowance refuses, judged on the requested grant before any cache carve; a bridge never resized is never refused. - Wedge recovery keeps the requested grant across the rebuild. - Pins of today's shrink behaviour: two rows both complete after a preemption; a lone row that can't re-allocate ends with the retryable capacity marker after its tokens. - statelessOrdinaryBehaviorIsUnchanged: the sub-1 GiB zero-overhead cases now expect width 0, a zero token budget and a refused allowance. Adds the regrow_idle_unload setting under [backend] (default off) and the test seams the new tests use.
Three orchestration tests, appended to EngineV2RegrowFloorWiringTests (the regrow with the idle-unload switch on): - R-ii, both hosts: three survivors, two idle victims planned. While the first is at ceiling 0, the host's own local admission refuses it and a submit to it gets the retryable capacity marker before any token; the second victim turns busy before its turn, so it keeps its ceiling and its slot. No ceiling grows before the one re-plan, and after it the live ceilings fit the budget. - R-iv, both hosts: a victim that has work at ceiling 0 gets exactly its previous grant back and keeps its slot; that pass grows nobody. - R-i, ProviderLoop: a coordinator request for a model a regrow is unloading is refused before acceptance with a retryable capacity refusal; with the mark cleared the same request is accepted. Source stubs only, with production behaviour unchanged: the shared refusal message, the pending-unload set's declaration, and a DEBUG-only regrow hold (RegrowHoldPoint) with its setter on both hosts.
The KV regrow (after an unload or a budget change) no longer pushes a survivor below its serviceable floor when the re-slice's own split would: - regrowPlan keeps the re-slice's split wherever it leaves every survivor with a known floor at or above min(floor, previous grant). Otherwise an unknown floor holds its previous grant, known slots keep their floors (or min(floor, previous)), and the rest of the budget goes by weight. - With [backend] regrow_idle_unload (off by default), a contraction of the durable budget (MTP staging and a native MiMo retirement excluded) unloads idle survivors, least recently used first; a busy, pinned or held one is never chosen. An unload is queued outside the re-slice gate and the victim is held at ceiling 0 until it leaves. - When survivors still fall short, the split stands and one log line names the shortfall. A model the regrow is unloading takes no new work. The coordinator and local admission paths, and the standalone server's acquire, refuse it synchronously, before the request is registered or reserved, with a retryable 503. Each victim is re-checked as idle by its host's own state just before it is marked. After its ceiling goes to 0, the bridge's own active count and the host state are read once more; if either shows work, its exact previous grant comes back. A victim missed either way means that pass applies shrinks only, then one re-plan follows. A miss in the re-plan ends at the switch-off split of the live grants, so every completed plan ends within the budget. An EngineV2 slot whose requested grant (before any cache carve) is below the 1 GiB minimum KV grant advertises width 0 and a zero token budget, and its service allowance refuses new work with the existing retryable capacity marker (a continuation of a served request keeps its place). A provider-side log line names the reason. A wedge rebuild carries the slot's requested grant into the rebuilt bridge before it is registered. The serviceable-floor read takes the admission ledger's capacity and admissible ceiling from one locked read.
…oop poll T1 (KV regrow wiring) now compares the busy survivors with the fleet KV budget as it stands after the idle survivor's unload. An unload's own regrow grows the survivors into the weights it frees, so the budget read before the unload is stale. T1 also checks that the busy survivors still contract and that each keeps min(floor, previous grant). A guard requires that the post-unload budget still binds the busy pair. The setup is unchanged; its comment now states the arithmetic. The rebuild-grant fixture's engine loop now polls at the SDK's default idle re-check interval (0.001 s). A submit does not wake an idle CBv2 loop, so the hourly interval left a served request waiting.
…gment KV slot grants (hardware-support.md) now describe the regrow's own plan. The re-slice's split stands wherever it keeps every known floor. Otherwise, in order: with the default-off [backend] regrow_idle_unload key, the least recently used idle survivor is unloaded while the minimums exceed the durable budget; the survivors keep at least min(floor, previous grant) when those minimums fit the budget; and when they don't, the re-slice's split of the survivors that remain stands and the shortfall is logged. The section also describes the width rule below the minimum load KV size and the wedge rebuild's carried grant, and it drops the old claim that regrowth never shrinks a slot below its floor. configuration.md documents the key; inference.md and direct-mode.md point to the section. A changelog.d fragment names the behaviour and the key. No code change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 of 5 tasks
davidtai
approved these changes
Dec 1, 2026
davidtai
left a comment
Collaborator
There was a problem hiding this comment.
Approved by David, with requests. CI is green, cluster shards included. The arithmetic holds: grants stay within the budget in every branch, and a victim drops to ceiling 0, with its weights still counted, before any survivor grows. The regrow therefore can't run the Mac out of memory.
- Medium, a default change on DevNet,
EngineV2Bridge+ServiceAllowance.swift:111: any EngineV2 slot with a grant under 1 GiB now advertises width 0 and refuses requests with 503. It is on by default with no off switch, andstatelessOrdinaryBehaviorIsUnchangedwas rewritten to expect this. Add a kill switch, or state why none is needed. - Medium,
EngineV2RegrowFloorWiringTests.swift:529: the T1 check was loosened fromtotal <= contractedtototal <= after, the budget after the unload. The out-of-memory risk comes before the unload. Restore the old check at the.victimAtZerohold, and right after the regrow returns, while the victim's weights are still resident. - Low, opt-in only,
EngineV2Reslice.swift:281: the victim loop doesn't count the freed weights of victims it already picked, so it can unload more idle models than needed. Recompute the durable budget withexcludingModelIDs: victims. - Low,
ProviderLoop+EngineV2.swift:854andStandaloneServer.swift:1578:regrowUnloadTasksis emptied only in the test helper, so in production it grows forever. The hold flag and the spin loop are also production state outside DEBUG. - Design: this is the second fix for "a survivor shrinks below its floor on regrow"; the first put the floors into
resliceGrants. The ~150-line regrow is also duplicated inProviderLoop+EngineV2.swift:696andStandaloneServer.swift:1528. Under David's root-cause rule, this needs one regrow owner and one floor function, not another patch. David decides whether that blocks 0.10.20 or follows it.
The pin moves to b9969ce. mlx-swift-lm#556 and #560 have both merged to main with merge commits, so both pins are on main.
An EngineV2 slot whose requested KV grant is below the 1 GiB minimum now advertises width 0 and refuses new requests, on by default with no way back. DARKBLOOM_SUB_FLOOR_REFUSAL=0 (or false, no, off) turns the rule off, so such a slot keeps its width and serves, as in 0.10.19; unset or any other value keeps it on. The heartbeat and the service allowance read the one predicate (grantBelowMinimumKV), so the switch covers both. The key is forwarded to the launchd job. Tests: EngineV2SubFloorSwitchTests (the switch and its forwarding; below, at and above the floor, an unset grant and a non-EngineV2 slot, with the rule on and off).
DARKBLOOM_SUB_FLOOR_REFUSAL (EngineV2Bridge.subFloorRefusalKey) moves from passthroughEnvKeys' own entries into inferencePassthroughEnvKeys, which passthroughEnvKeys includes, so the daemon still receives it and EngineV2SubFloorSwitchTests.theSwitchIsOnUnlessSetOff, which reads the inference list, passes.
This branch was successfully deployed
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.
libs/mlx-swift-lmto the commit with the admission-ceiling pair: CBv2: read the admission ceiling pair under one lock mlx-swift-lm#560's head commit Layr-Labs/mlx-swift-lm@b9969ce2, which that PR merges into main by merge commit. This PR merges only after that.[backend] regrow_idle_unloadsetting, off by default, lets the provider unload an idle model instead. A slot under 1 GiB stops advertising width.devafter Provider 0.10.20 candidate, with the Inkling 2 MTP fixes #2794 merges.Part of landing the 0.10.20 release content on dev before the release is cut, as the release review on #2800 asked.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.