Skip to content

Cluster: plan a serving cluster's model change again once its memory is free (local mode fell back to a pipeline) - #1677

Merged
davidtai merged 2 commits into
devfrom
fix/cluster-replan-after-stop
Oct 30, 2026
Merged

davidtai merged 2 commits into
devfrom
fix/cluster-replan-after-stop

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Changing the model of a serving two-Mac cluster (m in darkbloom cluster, or darkbloom cluster local <model>) planned the new model while the running parts still held their memory, then stopped them and started that plan. A tensor-parallel split therefore did not fit "now", and a pipeline started in its place.

Found on DevNet (two M5 Ultra 256 GB, GLM-5.3-Flash, 0.10.4-dev.branch.8). darkbloom cluster local glm-5.3-flash was run while the pair served GLM in tensor parallel:

  • The planner said: "tensor parallel is predicted 2.45 s against 5.85 s for the chosen placement, but it does not fit as these Macs are now (mac-928917db1830 needs 144.75 GiB and admits 142.95 GiB now; mac-cff934455dca needs 144.75 GiB and admits 144.39 GiB now)".
  • A pipeline started (24 / 21 layers). The setup's test request ran at 47.9 tok/s. The pipeline serves the memory profile's 65,536-token context (GLM5NextResidentAdmission.memoryProfile), not the native 1,048,576.
  • Stopping the cluster first (s; both Macs back to 7 / 4 GiB wired) and running the same command chose tensor parallel 50/50:
    • the test request ran at 126.9 tok/s;
    • both workers log darkbloom-serving-context-v1 … tokens=1048576;
    • a 300,939-token prompt was served (3,417 tok/s prefill).

The re-plan after a Darkbloom update (ClusterService.checkForUpdate) already does this right: it stops both parts, waits until both Macs report "nothing left running", re-asks the other Mac (ClusterOnboardingUpdate.reportPricesPlan) and plans again. The guided model change never did.

This change:

  • ClusterOnboardingLive.localAdopt: when it has to stop a serving cluster, after the parts drained it now:

    • waits until both Macs gave the memory back (awaitReleased, extracted from the update path);
    • plans again (localPlanModels, which asks the other Mac for a report taken after the stop);
    • adopts the chosen model's new plan, found by its id.

    When the plan changed, one line says so ("Planned again with both Macs' memory given back: …"). A model that is no longer offered fails with the reason. When the re-plan cannot run, the listed plan stands; it was priced with less memory than the Macs then have.

  • ClusterOnboardingUpdate.servableIndex(of:in:): one rule for "this model, startable as listed". The guided change, the update re-plan and the memory-refusal re-plan all use it; before, the predicate was duplicated inline twice in ClusterService.

  • Memory-refusal re-plan (ClusterService.noteMemoryRefusal): it adopts through localAdopt, which now plans once more after the stop. Its log line therefore quotes the deployment the start recorded, not its own earlier plan's line.

  • Docs and changelog: docs/architecture/inference.md and docs/provider/two-mac-cluster.md describe the model change's re-plan; changelog.d/cluster-model-change-replans-after-stop.md.

Before

flowchart LR
  subgraph Behavior
    A1["serving GLM, tensor parallel"] --> B1["darkbloom cluster local glm-5.3-flash"]
    B1 --> C1["plan while the parts hold ~96 GiB each: TP 'does not fit now'"]
    C1 --> D1["stop both parts"] --> E1["start the listed pipeline: ~48 tok/s, 65,536-token context"]
  end
  subgraph Code
    P1["chooseAndServe → planModels (parts running)"] --> Q1["localAdopt: localStop + drained"]
    Q1 --> R1["context.adopt(listed plan key)"]
    U1["checkForUpdate: stop → wait for release → localPlanModels → find by id → localAdopt"]
  end
Loading

After

flowchart LR
  subgraph Behavior
    A2["serving GLM, tensor parallel"] --> B2["darkbloom cluster local glm-5.3-flash"]
    B2 --> C2["listed plan (parts running)"] --> D2["stop both parts, wait until both Macs gave the memory back"]
    D2 --> E2["plan again: tensor parallel fits"] --> F2["start TP: ~100+ tok/s, 1,048,576-token context"]
  end
  subgraph Code
    P2["chooseAndServe → planModels"] --> Q2["localAdopt: localStop + drained"]
    Q2 --> R2["awaitReleased → localPlanModels → servableIndex(model id)"]
    R2 --> S2["context.adopt(new plan key)"]
    U2["checkForUpdate: awaitReleased + servableIndex (shared)"]
    M2["noteMemoryRefusal: servableIndex; logs the recorded deployment"]
  end
Loading

Validation

  • provider-swift/Tests/ClusterOnboardingChecks/run.sh: 599 passed, 0 failed, including 7 new servableIndex checks:
    • found by id where the new list put it;
    • a catalog name is not an id;
    • a choice without an id is found by its title;
    • a blocked model, a model to copy first, or one that is gone cannot start;
    • an entry that can start is found past one to copy first.
  • swiftc -parse on the changed Swift files.
  • scripts/docs-impact-check.py --base origin/dev: coverage OK. scripts/changelog.py check: 103 valid. scripts/docs-check.sh: the same 4 submodule-link lines as origin/dev, none added.
  • Live (above): planning while serving chose a pipeline at 47.9 tok/s. With both Macs' memory released first, the same command chose tensor parallel at 126.9 tok/s and served a 300,939-token prompt. That is the order this change makes localAdopt follow.

Refactor pass

An independent refactor/review pass found no bugs in the change. It:

  • kept the earlier peer report, rather than refusing, when none is recorded after the re-plan;
  • spelled out the invariant that a failed plan replaces neither choices nor the decisions context.adopt reads, which is why the listed plan can stand;
  • made the memory-refusal re-plan log the deployment that was actually adopted;
  • corrected the docs' class name (OnboardingLive), documented that path, and added one check.

Checks rerun after the pass: onboarding 599 passed; swiftc -parse clean; docs-impact OK; changelog 103 valid; docs-check at the origin/dev baseline.

Limitations

  • ClusterOnboardingLive.swift and ClusterService.swift are compiled only by the full package build, which isn't run on the serving Macs. CI type-checks them; the new pure rule is covered by the onboarding checks.
  • A model change of a serving cluster now takes one more plan after the stop: the other Mac's report (about 20 s on this pair) and the planner.
  • The answer limit is unchanged: GLM-5.3-Flash still advertises 65,536 output tokens on a cluster (GLM5NextRegisteredSpecification.registeredOutputTokens, the catalog's max_output_length), also in local-only mode.

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

Changing the model of a serving two-Mac cluster (m in darkbloom cluster, or darkbloom cluster local <model>) planned while the running parts still held their memory, then stopped them and started that plan, so tensor parallel did not fit "now" and a pipeline started instead. On two M5 Ultras GLM-5.3-Flash came back as a pipeline at 47.9 tok/s, serving the pipeline's 65,536-token context instead of the native 1,048,576; with the memory released first the same command chose tensor parallel at 126.9 tok/s.

localAdopt now waits until both Macs gave the stopped parts' memory back (awaitReleased, taken from the update path), plans again and adopts the model's new plan, found by its id (ClusterOnboardingUpdate.servableIndex, shared with the update and memory-refusal re-plans). When the re-plan cannot run, the listed plan stands. The memory-refusal re-plan logs the deployment the start recorded.

Validation: ClusterOnboardingChecks 599 passed (7 new); swiftc -parse clean; docs-impact OK; changelog check OK; docs-check at the origin/dev baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 requested a review from davidtai October 30, 2026 02:02
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference Error Error Oct 30, 2026 8:14pm UTC
d-inference-console-ui-dev Error Error Oct 30, 2026 8:14pm UTC
d-inference-landing Ready Ready Preview Oct 30, 2026 8:14pm UTC
darkbloom-status Ready Ready Preview Oct 30, 2026 8:14pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 30, 2026 8:14pm UTC

Request Review

- The re-plan after the stop prefers the entry in the chosen folder: two
  folders can hold different artifacts under one model id.
- The re-planned list and choices are read under one lock, and the entry
  must still name the chosen model.
- A model change forwarded to the leader waits 600 s, not 240 s: the
  leader may drain for 5 minutes, wait for memory and plan again.
- The changelog gives the measured speeds (47.9 and 126.9 tokens/s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidtai

Copy link
Copy Markdown
Collaborator

Review pass before merge (for David). Fixed in b3da012 (signed):

  • Forwarded model change timeout. A change started on the Mac that does not lead waited 240 s for the leader's reply. The leader may now drain for up to 300 s, wait releaseWaitSeconds, plan again and retry the lease, so the requester could report a failure while the leader had already stopped both parts. It now waits 600 s, the same as the command lock.
  • Chosen folder on the re-plan. The re-plan found the model by id only. Two folders with different artifacts under one id both stay in the list, so it could switch folders. New ClusterOnboardingUpdate.servableIndex(of:folder:in:folders:) prefers the chosen folder's entry, with four new checks in ClusterOnboardingChecks.
  • One lock read. The re-planned index and choices are read under one lock, and the entry must still name the chosen model.
  • Changelog. It now gives the measured 47.9 and 126.9 tok/s instead of "about 48 instead of about 100".

Not fixed in code: no test runs localAdopt's stop, wait, re-plan and adopt sequence end to end. Please cover darkbloom cluster local glm-5.3-flash on a serving TP pair in the from-scratch DevNet run, and check that tensor parallel is adopted.

@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.

Reviewed: re-plan after stop is bounded and safe; fixes in b3da012 (forwarded adopt timeout 600 s, chosen-folder preference with checks, one-lock read, changelog figures). CI green.

@davidtai
davidtai merged commit aba3b39 into dev Oct 30, 2026
20 of 22 checks passed
davidtai added a commit that referenced this pull request Oct 30, 2026
libs/mlx-swift-lm conflicted: master pins 2beb401f (mlx-swift-lm main,
#368/#369), dev pins f98ced91 (#373's head). It takes 7933a0fa, the
#373 merge commit on mlx-swift-lm main, whose parents are both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidtai
davidtai deleted the fix/cluster-replan-after-stop branch October 30, 2026 20:39

This branch had an error being deployed

2 failed and 3 active deployments
Preview – eigen-homepages-darkbloom — b3da0125 Deployed Oct 30, 2026 by vercel[bot]
Preview – d-inference-landing — b3da0125 Deployed Oct 30, 2026 by vercel[bot]
Preview – d-inference — b3da0125 Deployed Oct 30, 2026 by vercel[bot]
Preview – darkbloom-status — b3da0125 Deployed Oct 30, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — b3da0125 Deployed Oct 30, 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