Skip to content

Regrow: one owner, and no survivor grows while an idle unload is pending - #2844

Merged
jonathan308 merged 1 commit into
devfrom
fix/regrow-one-owner
Dec 2, 2026
Merged

jonathan308 merged 1 commit into
devfrom
fix/regrow-one-owner

Conversation

@jonathan308

@jonathan308 jonathan308 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2807 (review follow-up).

For the next release. Review required. This only changes what happens when [backend] regrow_idle_unload is on (default false). The new owner and floor function are refactors.

Problem.

  • With the switch on, a regrow set the idle victim's ceiling to 0, queued its unload, and then grew the survivors to the plan's targets right away. Those targets assume the victim's weights are already freed. Until the unload ran, the total of all ceilings could exceed the live budget, which still counts those weights. T1's own numbers show it: busy floors of at least 2 GiB against a contracted budget under 2 GiB.
  • ProviderLoop+EngineV2.swift and StandaloneServer.swift each had a copy of the same ~150-line regrow, with separate floor logic.
  • The victim loop judged every victim against one durable budget. It never counted the weights earlier victims would free, so it could unload more models than needed.
  • regrowUnloadTasks was cleared only by a test helper. The test hold flag and its wait loop were production state.

Change.

  • Order of grant changes. When a regrow has victims, survivors shrink first, then each victim goes to ceiling 0. No survivor grows while a victim the regrow queued is still resident. The unload's own regrow, which runs after the slot is removed, grows the survivors into the memory it frees. Until then every ceiling fits the live budget.
  • One owner. The new EngineV2RegrowHost (Inference/Memory/EngineV2Regrow.swift) is an actor protocol, and its extension holds the regrow:
    • the plan, the victims and the re-plan;
    • the order of every grant change;
    • the queued unloads and the test seams.
  • Host conformances. ProviderLoop and StandaloneServer each conform and supply their own:
    • budget reads, survivors and victim tiers;
    • idle check;
    • unload (unloadModel(forEviction:), or an evictSlot behind the load gate);
    • log wording.
  • Reclamation checks. Both hosts now check native MiMo reclamation before every grant change, as the server already did. ProviderLoop's shrinks used to skip this check.
  • One floor function. EngineV2KVSizing.serviceabilityFloor(declared:) serves both the load re-slice and the regrow.
  • Per-victim budget. regrowPlan gains a durableFleetKVBudgetBytesExcluding: overload. Each further victim is judged against the durable budget left once the earlier victims' weights are freed. The UInt64 overload delegates to it, so the existing plan tests are unchanged.
  • Unload tasks. regrowUnloadTasks is keyed by UUID, and each task removes itself when it ends. regrowUnloadHeld and its wait loop are #if DEBUG.
  • Changelog. New changelog.d/regrow-one-owner.md.

Tests.

  • New: "T1 strict" (both hosts, EngineV2RegrowFloorWiringTests). The unload is held. The test checks that the total ceiling stays within the contracted budget at the victim's ceiling 0 and right after regrow() returns, then checks the post-unload state. It fails on the old order: at the hold, the busy survivors still hold their large previous share.
  • New: an EngineV2RegrowPlanTests case. When one unload frees enough, the plan picks one victim.
  • Changed: R-ii now gives its first victim 64 MiB of weights instead of 1 GiB. With the per-victim budget, a 1 GiB unload alone would make room, so the smaller weights keep the two-victim path covered.
  • Local check: a standalone build in Swift 6 language mode with DEBUG (Swift 6.4.2, macOS 27.2.1). It compiles the real EngineV2Regrow.swift and EngineV2Reslice.swift against a fake host whose unload runs its own regrow. All 18 checks pass, covering:
    • T1 strict;
    • R-ii and R-iv;
    • the per-victim budget;
    • unload tasks that remove themselves.

Not covered by CI. Nothing beyond what the existing regrow wiring tests drive.

Rollback. Revert. No state or config format changes.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Follow-up to the review of #2807.

- With [backend] regrow_idle_unload on, a regrow that picks an idle victim
  now applies the survivors' shrinks first, then the victim's ceiling 0,
  and grows no survivor while a victim it queued is still resident. Until
  the unload runs, every ceiling fits the live budget, which still counts
  the victim's weights; the unload's own regrow then grows the survivors.
- A new test, "T1 strict", holds the unload and checks on both hosts that
  the ceilings fit the contracted budget at the victim's ceiling 0 and
  right after the regrow.
- One regrow owner: EngineV2RegrowHost (EngineV2Regrow.swift) holds the
  regrow that ProviderLoop and StandaloneServer each carried. Each host
  keeps only its reads, its unload and its log wording, and both check
  reclamation before every grant change. One floor function,
  EngineV2KVSizing.serviceabilityFloor(declared:), serves the load
  re-slice and the regrow.
- Each further victim is judged against the durable budget the earlier
  victims leave once their weights are freed, so a regrow no longer
  unloads more models than it needs. A plan test covers it; R-ii keeps
  its two victims with a 64 MiB first victim.
- Queued unload tasks remove themselves when they end; the test hold and
  its wait loop are DEBUG only.

Refs #2807
@jonathan308 jonathan308 added the run-ci Trigger one-shot PR CI run (auto-removed when run starts) label Dec 2, 2026
@vercel

vercel Bot commented Dec 2, 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 4:46am UTC
darkbloom-status Ready Ready Preview Dec 2, 2026 4:46am UTC
eigen-homepages-darkbloom Ready Ready Preview Dec 2, 2026 4:46am UTC

Request Review

@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 b064416 into dev Dec 2, 2026
27 checks passed

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — bad64cb5 Deployed Dec 2, 2026 by vercel[bot]
Preview – d-inference-landing — bad64cb5 Deployed Dec 2, 2026 by vercel[bot]
Preview – darkbloom-status — bad64cb5 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.

1 participant