Skip to content

Provider: keep survivors' memory floors when the KV budget regrows - #2807

Merged
jonathan308 merged 8 commits into
ink-engine/inkling-mtp-fixesfrom
fix/kv-regrow-floors-dev
Dec 2, 2026
Merged

jonathan308 merged 8 commits into
ink-engine/inkling-mtp-fixesfrom
fix/kv-regrow-floors-dev

Conversation

@jonathan308

@jonathan308 jonathan308 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

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-bot with what you need.

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.
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Dec 1, 2026
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Dec 2, 2026 12:30am UTC
darkbloom-status Ready Ready Preview Dec 2, 2026 12:30am UTC
eigen-homepages-darkbloom Ready Ready Preview Dec 2, 2026 12:30am UTC

Request Review

@davidtai davidtai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. 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, and statelessOrdinaryBehaviorIsUnchanged was rewritten to expect this. Add a kill switch, or state why none is needed.
  2. Medium, EngineV2RegrowFloorWiringTests.swift:529: the T1 check was loosened from total <= contracted to total <= after, the budget after the unload. The out-of-memory risk comes before the unload. Restore the old check at the .victimAtZero hold, and right after the regrow returns, while the victim's weights are still resident.
  3. 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 with excludingModelIDs: victims.
  4. Low, ProviderLoop+EngineV2.swift:854 and StandaloneServer.swift:1578: regrowUnloadTasks is 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.
  5. 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 in ProviderLoop+EngineV2.swift:696 and StandaloneServer.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.
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Dec 2, 2026
@github-actions github-actions Bot removed the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Dec 2, 2026
@jonathan308
jonathan308 merged commit 4ee8c06 into ink-engine/inkling-mtp-fixes Dec 2, 2026
34 checks passed

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — b03dcd0e Deployed Dec 2, 2026 by vercel[bot]
Preview – d-inference-landing — b03dcd0e Deployed Dec 2, 2026 by vercel[bot]
Preview – darkbloom-status — b03dcd0e Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants