Skip to content

feat(cluster, provider): 0.10.12 — Gemma 4 tensor parallel serves as many requests at once as both Macs admit - #1936

Merged
jonathan308 merged 12 commits into
devfrom
feat/gemma-tp-lanes-by-memory
Nov 12, 2026
Merged

jonathan308 merged 12 commits into
devfrom
feat/gemma-tp-lanes-by-memory

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

For 0.10.12. First step of the concurrency work: every pair option serves several requests at once (owner, 2026-11-09: "all of these options should be concurrent"). Plan: CONCURRENCY-PLAN.md §2.2. Draft. C1 ran on the M5 Ultra pair on 2026-11-10 (all six Gemma TP sessions passed), and the independent review's changes are in (round 2, below).

Status (2026-11-10, after the 0.10.12 candidate's SIGBUS): planning runs on its own stack

Build What Stack used Thread Margin
debug (CI) this test, CI's bundle, stack pattern-filled under lldb 504 KiB 524 KiB (Swift Testing) 20.3 KiB (20,744 bytes)
debug the guided step (ClusterSetupPlanning.decide), 27B tensor parallel, CI's bundle 692 KiB 524 KiB (onboarding, the service's update and memory re-plans) overflows: its tests ran it on a 16 MiB thread
release the guided step on the service's re-plan thread: frames of the installed 0.10.11 binary plus an -O -wmo build of the planner about 220 KiB 524 KiB about 300 KiB
  • Every real call site runs on a 512 KiB stack (524 KiB reported):
    • darkbloom cluster's planning, and the service's update and memory re-plans (Thread.detachNewThread);
    • the automatic replacement (Task.detached);
    • darkbloom cluster plan (an async command, so it runs on the cooperative pool).
  • The deepest families plan tensor-parallel widths (GLM's lane charge, the Qwen 27B's quotes). Stack used below decide, debug / release:
    • GLM and the Qwen 27B: 287 / 81 KiB;
    • Gemma 4: 274 / 63;
    • MiMo: 265 / 63;
    • Qwen 3.5 9B: 194 / 51.
  • The fix (red first). ClusterPlanningStack.run runs both planning entry points on a thread of their own with a 16 MiB stack while the caller waits: ClusterPlacementFlow.decide and ClusterSetupPlanning.decide.
    • It binds again the one task-local value planning reads (ClusterPublicModels.declarationOverride, which only tests set).
    • A caller's stack now holds only the wait, in debug and release alike.
    • 50ca322f77: the tests. Its CI run (42777175333) failed exactly the two new checks. decide used 414 KiB of its caller's stack and the guided step 694 KiB, against a 64 KiB budget. They measure on a pattern-filled 16 MiB thread, so a planner that is too deep fails a check instead of killing the test process.
    • 4720063e82: the fix. The budget is now 128 KiB: a replica of the check on the CPU runner measures 72 KiB in debug, the wait plus the check's own call. The guided step's tests drop onLargeStack and run on their test task.
    • 8ace9d99ac: docs (inference.md Planning stack, test.md Planning stack checks).
    • Also passed locally: placement setup checks (274), run-flow.sh (33), ClusterConsoleChecks (79,396 expectations), ClusterDiagnosticsChecks, ClusterInstalledSessionChecks, changelog check, docs-impact-check.
  • Into the candidate: 0552b096a9 merged with 8ace9d99ac has no conflicts (git merge-tree); nor does feat(cluster, provider): 0.10.12 — GLM tensor parallel serves as many requests at once as both Macs admit #1939 merged with it. feat(cluster, provider): 0.10.13 — a Gemma 4 pipeline keeps the lookahead; a saved serial width is checked whole at load #1937 carries the same three commits for 0.10.13.

Status (2026-11-10, review round 2)

  • Head efb5cd5610. CI (dev) green (run 42759670913).
  • Red first: e6192f05c6 (tests only). Its CI run (42745016900) failed on exactly those tests: PlacementChecks' LOAD check, ProcessChecks' projection, 11 issues in ClusterPlacementTensorWidthTests, the burst test. Then the changes: 08c0dee3ae (P2-1), a54dd1b5ba (cap), b3b1fda6a8 (projection), and 523d44922b (the burst test keeps its streams; see below). CI on 523d44922b: green (42747717380), every new test passing.
  • Review-only refactor pass (an independent agent that read the round's diffs and edited nothing; its findings taken in efb5cd5610): the cap became one table (gemmaQualifiedLanes); the planner and docs say why one lane keeps its load peak (its gap predates widths, and one-request plans stay byte for byte, the review's own form); the owner's projection says it prices a request's images or video as text tokens, the vision tower's time aside; the burst test also checks that a reserved lane leaves no prompt counted as waiting; no wave names in comments. It found the admission bookkeeping sound and no compile risk. Not taken: counting a one-lane plan's allowance (it would change every Gemma TP singleton plan).
Review item What changed Red → green
P2-1 LOAD's reservation was left out of a lane-charge width's load peak, about 0.75 GB a rank short batchLoadReservation counts it for a lane-charge width (?? (laneGrowth > 0 ? nativeFloor : 0); here nativeFloor already carries the lane growth), and so does what the allocator holds. One request plans byte for byte as before PlacementChecks: on two 24, 32, 36 or 48 GB Macs with up to 8 GiB more in use, LOAD must admit every planned width. Before: 9 refused (two 32 GB Macs with 5–5.5 GiB in use at 2 lanes, 36 GB with 4.25–4.75 GiB at 4, 48 GB with 5.75–6.25 GiB at 8). After: 1,657 pass. ClusterPlacementTensorWidthTests prices a width's need with the reservation in the load peak
P2-2 cap One constant, ClusterPlacementTensorWidth.gemmaQualifiedLanes (row → width, QAT 4-bit at 2), which qualifiedLanes reads. The owner chooses 2 or 4: at 2, 95.5 tok/s in all and 77 a request; at 4, 96.2 and 48.5 ClusterPlacementTensorWidthTests: decide saves 2 at most; the search itself is still checked at 8, 6, 4 and 2 (ClusterPlacementTensorWidth.plan with a cap of eight)
P3 the cap's scope QAT 4-bit only (the table's one row). The 8-bit rows are not covered by the same evidence: they run the same lanes on 8-bit kernels, and every synthetic lane check (Gemma4TensorParallelRuntimeTests) and C1 ran 4-bit. They save no width aGemmaRowThePairDidNotQualifySavesNoWidth
P2-2 the pair's first-token projection It counted nothing, not even the request's own prompt. Fixed: see below ProcessChecks (the real owner over two worker processes), DistributedCBv2DeadlineTests.aBurstOfLongPromptsTakesOnlyTheLanesWhoseFirstTokenMeetsItsDeadline
M23 A sized plan keeps the singleton's reasons. The test is a Gemma pair re-planned after an update: it keeps tensor parallel ahead of a pipeline whose share steps were not measured, and the TP-only width plan must keep that reason. Through decide, only keptModeReason can differ (whenever decide sets modesReason, the singleton's modes already leave the pipeline out) aSizedPlanKeepsTheSingletonsReasons. In a scratch copy in the light runner, deleting the two assignments fails it
P3 downgrade Below, for the release runbook —
  • The first-token projection, verdict. DistributedInstalledSession+Execution.swift:7 forwards to DistributedPipeExecutionOwner.projectFirstToken, which returned .unbounded for every request ("no measured peer transfer/control envelope"), and the slot forwards it unchanged. The engine refuses an unbounded projection, so:
    • before the bridge has a prefill rate, nothing is projected and every request takes a free lane (GH: the last of eight 8K prompts got its first token at 63.7 s, against 7.7 s alone);
    • since 7062b62664 (in dev, and also in 0.10.11, where DistributedCBv2Engine reports the prompt observation), once the bridge has measured the pair's prefill, every request carrying a first-content budget is refused deadline_unreachable, even a lone one. The coordinator sends that budget with every request. Within 30 minutes of the measurement, or while the Mac is busy, the rate stands. This is a static reading of the code, not yet confirmed in production data. A 0.10.11 hotfix would be this PR's owner change alone.
  • The fix.
    • The owner projects the request's whole prompt at the caller's prefill rate, in chunk steps. For a pair that rate is the pair's own, measured end to end from both ranks' reservation to the first committed token, so it carries the transfer and control costs. Without a usable rate it still projects nothing, and the request is admitted unprojected, as before.
    • The engine puts that behind every prompt already holding a lane without its first token, running or waiting for its reservation (behindPendingPrefill). A burst takes only the lanes whose first token meets its deadline; the rest are refused at once, so the coordinator sends them to another Mac.
    • Not charged: other lanes' decode steps between prompt chunks (a few milliseconds a chunk at 2 lanes).
  • Downgrade (release runbook). 0.10.11's ClusterConfiguration.validate refuses a saved Gemma or GLM tensor-parallel width (called from the codec). After a rollback to 0.10.11 such a pair's setup can't be read, and the update re-plan bails out at savedConfiguration(). Run the setup again on that pair.
  • The burst test's own fix (523d44922b). On the red run the burst admitted all eight lanes, as expected. One more failure was the test's own: it dropped each admitted stream, and a stream nobody holds cancels its request. A cancelled request no longer delays the next one, so the fix could never have passed. The test now keeps the streams.
  • Gemma's LOAD keeps gating its whole width. feat(cluster, provider): 0.10.12 — GLM tensor parallel serves as many requests at once as both Macs admit #1939's P2-3 fallback (reserve the widest width memory admits) is GLM's only. At a cap of 2, Gemma's width is one lane charge (2.6 GB) beyond one request, and the planner now prices LOAD's peak exactly.

Before

  • A Gemma 4 26B pair in tensor parallel served one request at a time.
    • Its owner already serves batch lanes: the shared batch driver with a Gemma executor, each row bitwise its request alone, per-lane live admission and D6's newest-lane abort.
    • But no setup ever saved it a width:
      • guided placement sized only Qwen TP rows, by their native tensor-batch-scope quotes;
      • ClusterConfiguration.validate refused a Gemma tensor-parallel batchLanes outright.
    • DistributedInstalledPlan.tensorParallelLaneAdapters[.gemma4LayerStage] is 1.
  • So the setup screen said "serves one request at a time", the slot's max_concurrency was 1, and through Darkbloom every request beyond the first was turned away as "at capacity".

After

  • A Gemma tensor-parallel placement saves the widest width both Macs admit now, up to 2 for the QAT 4-bit row (round 2; the search tries 8, 6, 4 and 2 below the cap), as a Qwen TP placement does. Where none fits, it saves no width and serves one request at a time, as before.
    • The lane charge. Gemma's layout states, beside its allowance (one request at the memory plan's 32,768 + 32,768 tokens plus the rank's reserve), what each lane after the first adds: one request's whole charge. That is ClusterTensorParallelFamilyPlan.laneBytes, from Gemma4TensorParallelRequestBudget.laneBytes, the charge reserveLane admits every lane with.
      • The native plan tool writes it where the allocator's bound is known.
      • Metadata-only layouts carry neither the allowance nor the lane charge, so the golden layouts are unchanged.
    • The planner. ClusterPlacementPolicy.tensorParallelLanes adds the lane charge for each lane after the first to every rank's native reservation (ClusterPlacementPlanner.tensorRequirement). LOAD holds that whole reservation while it reads the shard, so it is in the load peak too (round 2, P2-1).
      • requireLanePricing refuses a width for a family without a lane charge, or beside a native quote.
    • The width. ClusterPlacementTensorWidth sizes both kinds of owners through one loop: widths decides how the singleton's wider widths are priced (a Qwen row's native quotes, or a family's lane charge where nothing else priced it), and widest searches them. The placement chosen for one request keeps its leader and split, and the first admitted width (ClusterPlacementCandidate.admitted(requireNow: true)) is saved.
      • A Qwen TP row is priced by its native quotes, as before.
      • A family with a lane charge is priced by that charge.
    • The cap. No width exceeds what the family qualified on real Macs (qualifiedLanes).
      • Qwen TP rows: eight, as before.
      • Gemma: gemmaQualifiedLanes, 2 for the QAT 4-bit row (C1 qualified 2, 4 and 8; the owner chooses 2 or 4). The 8-bit rows: none.
  • Setup and serving. ClusterConfiguration.validate accepts a Gemma tensor-parallel width of 2, 4, 6 or 8 with serial prefill (ClusterRuntimeAdapter.savesTensorParallelWidth).
    • The setup screen (ClusterSetupPlanning.loads), both owners, the slot's max_concurrency and the leader's local API all read it through DistributedInstalledPlan.batchLanes, unchanged.
    • So the screen and the coordinator say the same number.
  • LOAD reserves the width. Each Gemma rank reserves reservedBytes(lanes:), the allowance plus a lane charge for each lane after the first: the figure the planner priced.
    • Its prompt-prefix memory tier is measured beside that same figure: every lane's request and the rank's reserve once.
    • The load line reports reserved=.
    • Each lane is still admitted against live memory, and one the host can't hold is refused alone.
  • Unchanged:
    • GLM tensor parallel's fixed eight (step 3 sizes it);
    • MiMo tensor parallel's one lane (step 6);
    • every pipeline (step 2);
    • the approval and committed-start digests (no width is named in them);
    • automatic replacement (it never plans an approved setup; a local Gemma TP pair is sized at its first plan).
  • One behaviour to note: through Darkbloom, the setup's mode advice ranks the mode that serves more at once first. A Gemma pair offered both modes will now be advised tensor parallel (2) over the pipeline (1 today) until step 2 (feat(cluster, provider): 0.10.13 — a Gemma 4 pipeline keeps the lookahead; a saved serial width is checked whole at load #1937) gives the pipeline lanes.
flowchart LR
  subgraph Before
    A1["Gemma TP placement"] --> B1["no width saved: validate refuses one"]
    B1 --> C1["owner and worker: 1 lane"]
    C1 --> D1["screen: one at a time<br/>coordinator max_concurrency 1"]
    D1 --> E1["through Darkbloom: requests beyond one refused at capacity"]
  end
  subgraph After
    A2["Gemma TP placement"] --> B2["price 8, 6, 4, 2 lanes:<br/>allowance + (w-1) x lane charge per rank"]
    B2 -->|"widest both Macs admit now (cap: 2, QAT 4-bit)"| C2["setup saves width w"]
    B2 -->|"none fits"| C3["no width: 1 lane"]
    C2 --> D2["LOAD reserves allowance + (w-1) x lane charge"]
    D2 --> E2["owner, worker, screen, max_concurrency: w"]
  end
Loading
flowchart TD
  subgraph "Code flow (after)"
    L["ClusterPlacementLayouts.layout<br/>Gemma4TensorParallelRequestBudget"] -->|"requestAllowance + laneBytes"| P["ClusterPlacementFlow.decide"]
    P --> W["ClusterPlacementTensorWidth.plan"]
    W -->|"Qwen rows: native quotes"| X["widest(...)"]
    W -->|"lane charge: tensorParallelLanes = w"| X
    X --> T["ClusterPlacementPlanner.tensorRequirement<br/>native floor + (w-1) x laneBytes"]
    X --> S["ClusterPlacementSetup: batchLanes = w"]
    S --> V["ClusterConfiguration.validate<br/>savesTensorParallelWidth"]
    V --> I["DistributedInstalledPlan.batchLanes = w"]
    I --> O["owner lease, DARKBLOOM_CLUSTER_BATCH_LANES, slot max_concurrency, ClusterSetupPlanning.loads"]
    I --> G["Gemma4TensorParallelResidentRuntime.load<br/>reservedBytes(lanes: w)"]
  end
Loading

Tests (red first)

729fb0b527 (red, tests only, with dev's own APIs), then 0092c1fed3 (the change):

Check What it proves On dev 0f11fbe01a (729fb0b527) After 0092c1fed3
ClusterPlacementTensorWidthTests.aGemmaTensorParallelPlacementSavesTheWidestWidthItsLaneChargeAdmitsNow A Gemma TP placement saves 8, 6, 4, 2 or none, as both Macs' free memory admits. Each rank's need grows by exactly one lane charge a lane. The smaller Mac decides. The screen's number equals the saved width and batchLanes. No lane charge means no width red by construction, not run on dev: dev saves no Gemma TP width, so the screen says 1 passes in CI (Provider Unit Tests, shard 1)
ClusterPlacementTensorWidthTests.aGemmaTensorParallelPairServesTheWidthItsSetupSaved Both Macs' saved setups keep 8; both plans serve 8; a lane retires alone; both ranks launch with 8. An unsized setup serves 1 red by construction, not run on dev: dev's validate refuses the saved width (the refusal the two CPU runners below show on the red commit) passes in CI (Provider Unit Tests, shard 1)
ConfigurationCheck (CPU runner, its run.sh fixed to compile again) A Gemma TP setup keeps 2/4/6/8 with serial prefill. GLM and MiMo TP save none. A width beside the lookahead is refused fails locally: "A planned batch width requires a supported pipeline or Qwen tensor mode with serial prefill" passes locally: 14 groups
InstalledBatchLanesCheck (CPU runner) A Gemma TP setup's saved width reaches its owner lease, its actual owner child and the rank fails locally (same refusal, exit 133) passes locally
PlacementChecks (Gemma) The product layout states the lane charge (2,644,717,688 bytes a rank). A width costs a rank exactly its lane charges: 12.7 GB reserved at 2 lanes, 28.6 GB at 8. Two idle 256 GB Macs hold 8, two idle 24 GB Macs 1. A layout without a lane charge prices no width fails locally: 1 failed, 1,646 passed passes locally
PlacementChecks (Gemma, refactor pass 4e7a1a6f03) One lane reserves the allowance alone and plans as no width; every width reserves every lane's request and the rank's reserve once (what the prefix tier is measured beside); LOAD and the planner refuse 0 and 9 lanes; a lane charge of nothing, or above the allowance's request part, is refused where the layout is read — passes locally: 1,656 checks; CI (Focused Checks)

Also local, with the change: ClusterPlacementChecks/run.sh (274 passed), run-flow.sh (33 passed), ClusterInstalledSessionChecks/run.sh (passed), changelog check (68 valid), docs-impact-check (coverage OK), docs-check (only the 3 links into the uninitialized libs/mlx-swift-lm submodule of my worktree).

CI on 4e7a1a6f03 (after the refactor pass): green (run 42707098361), as on 0092c1fed3 (run 42661043947). Every job passed, including the five Cluster Runtime Tests shards, both Provider Unit Tests shards, Cluster Release Build Checks, both Focused Checks shards (PlacementChecks, run-flow.sh) and the three non-blocking two-rank Cluster GPU Tests shards.

Refactor pass (independent, 4e7a1a6f03)

Behaviour unchanged; one signed commit.

  • ClusterPlacementTensorWidth: one function (widths) decides how a placement's wider widths are priced, and widest only searches them. The sizes flag and the second guard in plan are gone.
  • Gemma4TensorParallelRequestBudget.chargeBytes(lanes:) removed: it equalled reservedBytes(lanes:) at every width (the allowance is requestBytes plus rankBytes). The prefix tier's room is now measured beside the figure LOAD reserved.
  • Checks added (PlacementChecks, above): one lane, the identity the prefix room relies on, 0 and 9 lanes, the lane charge's bounds.
  • Docs: the changelog says what a further request costs (about 2.6 GB a Mac); configuration.md's date follows its edit.
  • Mutants: 23 on the lane arithmetic, its bounds and the width search.
    • 19 are killed by PlacementChecks, ConfigurationCheck, and ClusterPlacementTensorWidthTests' Gemma cases. The Gemma cases were run through decide in a scratch harness, since the provider test build is CI's.
    • The 4 survivors are equivalent here: the leader is already held by decide, the split is equal, Gemma has no native quote, and the sized plan's reasons equal the singleton's.
  • Screen, workers and coordinator:
    • They read one function, DistributedInstalledPlan.batchLanes: ClusterSetupPlanning.loads, DistributedInstalledSession.concurrentRequests (the slot's max_concurrency), the owner lease and DARKBLOOM_CLUSTER_BATCH_LANES.
    • Both Macs' setups carry the one width the leader's decision synthesized, and the load agreement binds it on both ranks. They cannot disagree except through the developer-only DARKBLOOM_CLUSTER_BATCH_LANES switch. The screen does not read that switch, and set on one Mac only, the load agreement refuses it.
  • One shared planner? Assessed, left for the second of feat(cluster, provider): 0.10.12 — Gemma 4 tensor parallel serves as many requests at once as both Macs admit #1936/feat(cluster, provider): 0.10.13 — a Gemma 4 pipeline keeps the lookahead; a saved serial width is checked whole at load #1937 to merge. Both PRs branch from dev.

Qualification on the M5 Ultra pair (window C1, 2026-11-10)

All six Gemma TP sessions passed (C1WIN-1110T0113Z), pair-check with real weights, JACCL, encrypted_v1:

  • GW (8 lanes, waves 1/2/4/8, staggered), GWL (logprobs, a mid-wave cancel), GF (dev-fault newest-lane abort: aborted:memory:1 on both ranks, the older lanes finished, the next request served), GH and GHL (eight 8K prompts at once), G1 (one lane): every lane's tokens equal its solo run, and its logprobs bit for bit where asked.
  • Memory: reserved=28573303008 on both ranks at 8 lanes; peak footprint 13.3 GiB against 7.49 + 26.61 GiB.
  • Throughput (GW): aggregate 83.1 / 95.5 / 96.2 / 60.8 tok/s at 1 / 2 / 4 / 8 lanes, a request's own 98.3 / 77.2 / 48.5 / 14.5. A lone request at 8 lanes ran about 18 % below one lane (G1: 117.7 tok/s, the one-request loop's build-ahead).
  • So the cap is 2 for now (round 2). The plan for C1, as requested, was:
  • pair-check with real weights, JACCL over rdma_en3, encrypted_v1;
  • solo runs, then waves of 1, 2, 4 and 8 lanes, with staggered joins, a mid-batch cancel and a dev-fault newest-lane abort;
  • tokens of every lane equal to its solo run (pair-check fails a TP run on any mismatch), and logprobs, which Gemma TP publishes, bitwise where the pair-check tooling captures them (otherwise recorded, and compared in C2);
  • no hang, and both ranks exit 0;
  • each rank's memory peak within reserved=, and the darkbloom-prefix-v1 line's room_bytes measured beside it (the refactor pass's one runtime change: the prefix room now reads LOAD's reserved figure, the same number as before);
  • on the real artifact, the layout states laneBytes of about 2.64 GB (the checks use a stand-in allocator bound) and the guided plan saves 8 on the pair's own profiles;
  • the aggregate throughput gain, and a lone request's cost at lanes 8 against lanes 1. Lanes take the shared driver's read-then-build decode, not the one-request loop's build-ahead.

Limitations

  • The cap is 2, the owner's choice of 2 or 4 pending; the 8-bit rows save no width until a pair qualifies them.
  • The first-token projection charges no decode steps of other lanes between prompt chunks.
  • The lane charge is the memory plan's request (32,768 + 32,768). A longer request (Gemma TP serves up to 262,144 tokens) is charged at its own context when reserved, as today, and refused alone if it doesn't fit.
  • The refactor pass is done (above), and so is the independent review (round 2, top).

jonathan308 and others added 2 commits November 9, 2026 08:58
… Macs admit and serves it (red)

Red first for 0.10.12's first concurrency step: a Gemma 4 pair in tensor
parallel serves one request at a time today. Its owner already serves
batch lanes (the shared batch driver with a Gemma executor), but no width
is ever saved for it: guided placement sizes only Qwen TP rows (by their
native quotes), and `ClusterConfiguration.validate` refuses a Gemma
tensor-parallel `batchLanes` outright. So the setup screen says "serves
one request at a time" and the slot's `max_concurrency` is 1.

These checks state the behaviour wanted, with the APIs dev already has:

- ClusterPlacementTensorWidthTests: a Gemma tensor-parallel placement
  whose layout states a lane charge (`laneBytes` beside the family's
  allowance, as the native plan tool will write it) saves the widest of
  8, 6, 4 and 2 lanes both Macs admit now, each lane after the first
  adding that charge to every rank's need; the smaller Mac decides; the
  setup screen's number (`ClusterSetupPlanning.loads`) is the saved width
  and `DistributedInstalledPlan.batchLanes`'s; a layout with no lane
  charge saves none and says one.
- aGemmaTensorParallelPairServesTheWidthItsSetupSaved: a Gemma TP setup
  saved with 8 lanes is accepted on both Macs, both plans serve 8, a lane
  retires alone and both ranks are launched with 8 (a new
  `.gemma4TensorParallel` shape of the approval fixture).
- ConfigurationCheck: a Gemma TP setup keeps a width of 2, 4, 6 or 8 with
  serial prefill; GLM and MiMo TP still save none; a width beside the
  one-chunk lookahead is refused.
- The configuration check runner compiles again: ClusterConfiguration's
  validation reads ClusterPublicModels, which needs the grant files and
  the placement module, which its run.sh did not build.
- InstalledBatchLanesCheck: a Gemma TP setup's saved width reaches its
  owner lease, its actual owner child and the rank.
- PlacementChecks: the product layout (the allocator's bound known)
  states Gemma's lane charge, one request's whole charge.

On dev 0f11fbe each fails: no width is saved, the screen says one,
the Gemma TP setups are refused at validation, and the layout states no
lane charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…many requests at once as both Macs admit

A Gemma 4 pair in tensor parallel served one request at a time: its owner
serves batch lanes, but nothing ever saved it a width. It is now sized at
placement the way a Qwen TP row is, by what both Macs' memory admits, and
LOAD reserves that width.

- The lane charge. Gemma's layout states, beside its allowance (one
  request at the memory plan's request plus the rank's reserve), what each
  lane after the first adds: one request's whole charge
  (`ClusterTensorParallelFamilyPlan.laneBytes`, from
  `Gemma4TensorParallelRequestBudget.laneBytes`), the charge `reserveLane`
  admits every lane with. The native plan tool writes it where the
  allocator's bound is known; metadata-only layouts carry neither.
- The planner. `ClusterPlacementPolicy.tensorParallelLanes` prices a
  tensor-parallel candidate at a width: each rank's native reservation
  grows by the lane charge for every lane after the first. It refuses a
  width for a family without a lane charge, or beside a native quote.
- The width. `ClusterPlacementTensorWidth` sizes both kinds of owners: a
  Qwen TP row by its native quotes, as before, and a family with a lane
  charge at 8, 6, 4 and 2. The placement chosen for one request keeps its
  leader and split; the first width both Macs admit now is saved, and none
  (one request at a time) when no wider width fits. It never exceeds the
  width the family qualified on real Macs (`qualifiedLanes`: eight for the
  Qwen TP rows, as before, and eight for Gemma, to be confirmed on the M5
  Ultra pair).
- The setup. `ClusterConfiguration.validate` accepts a Gemma
  tensor-parallel width of 2, 4, 6 or 8 with serial prefill
  (`ClusterRuntimeAdapter.savesTensorParallelWidth`). The setup screen,
  both owners, the slot's `max_concurrency` and the local API read it
  through `DistributedInstalledPlan.batchLanes`, unchanged.
- LOAD. Gemma's rank reserves `reservedBytes(lanes:)`, the allowance and
  a lane charge for each lane after the first: the figure the planner
  priced. Its prompt-prefix memory tier is measured beside every lane's
  charge. The load line reports `reserved=`.

GLM tensor parallel keeps its eight lanes, MiMo tensor parallel serves one,
and the pipelines are unchanged: later steps of the same work.

Checks: PlacementChecks prices each width as LOAD reserves it (12.7 GB a
rank at two lanes, 28.6 GB at eight; two idle 256 GB Macs hold eight, two
idle 24 GB Macs one) and refuses a width without a lane charge.

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

vercel Bot commented Nov 9, 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 Nov 10, 2026 8:10am UTC
darkbloom-status Ready Ready Preview Nov 10, 2026 8:10am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 10, 2026 8:10am UTC

Request Review

…nt's widths; LOAD's reservation is the prefix tier's charge

Refactor pass on the Gemma 4 tensor-parallel width (behaviour unchanged):

- ClusterPlacementTensorWidth: one function, `widths`, decides how the
  singleton's wider widths are priced (a Qwen TP row's native quotes where
  its singleton quote priced it; a family's lane charge where nothing else
  priced it; none otherwise), and `widest` only searches them. The `sizes`
  flag and the second guard in `plan` are gone; a placement with no width
  to try is planned once, as before.
- Gemma4TensorParallelRequestBudget.chargeBytes(lanes:) is gone: the
  allowance is `requestBytes` plus `rankBytes`, so it equalled
  `reservedBytes(lanes:)` at every width. The prompt-prefix tier's room is
  measured beside the figure LOAD reserved.
- PlacementChecks pins what the runtime relies on: one lane reserves the
  allowance alone and plans as no width; every width reserves every lane's
  request and the rank's reserve once; LOAD and the planner refuse 0 and 9
  lanes; a layout whose lane charge is nothing, or more than its
  allowance's request part, is refused where it is read.
- The changelog fragment says what a further request is charged (all one
  request holds, about 2.6 GB on each Mac), and configuration.md's date
  follows its edit.

Mutants of the lane arithmetic, its bounds and the width search are killed
by these checks and by ClusterPlacementTensorWidthTests' Gemma cases (run
through `decide` in a scratch harness); the survivors are equivalent here
(the leader and split are already held, Gemma has no native quote).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 9, 2026
Takes the parent's one-rule width search (`ClusterPlacementTensorWidth.widths`),
the Gemma budget without its duplicate `chargeBytes(lanes:)` and the
stronger Gemma lane checks. No conflict: the GLM lane charge's planner and
layout rules hold for those checks (a lane charge of nothing, or above a
stated allowance's request part, is still refused).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…allel width, and a pair's first-token projection (red)

Red first for the independent review of C1 (P2-1, P2-2, M23):

- PlacementChecks (P2-1): LOAD reserves the whole width while it reads the
  shard (the shard gate's resident charge), but the planner leaves that
  reservation out of a lane-charge width's load peak, about 0.75 GB a rank
  short. On two 24-48 GB Macs with up to 8 GiB more in use, LOAD must admit
  every planned width. Today it refuses 9 of them: two 32 GB Macs with
  5-5.5 GiB in use at 2 lanes, 36 GB with 4.25-4.75 GiB at 4, 48 GB with
  5.75-6.25 GiB at 8.
- ClusterPlacementTensorWidthTests:
  - a width's need counts LOAD's whole reservation in its load peak;
  - the 8, 6, 4 and 2 search itself (`ClusterPlacementTensorWidth.plan`
    with a cap of eight);
  - Gemma TP saves at most 2 (`qualifiedLanes`, the owner's choice of 2 or
    4), for the QAT 4-bit row only; the 8-bit rows save none;
  - M23: a sized plan keeps the singleton's kept-mode reason (a Gemma pair
    re-planned after an update keeps tensor parallel ahead of a pipeline
    its share steps were not measured against).
- The pair's first-token projection counts nothing. Its owner
  (`DistributedPipeExecutionOwner.projectFirstToken`) always returns
  unbounded, so once the bridge has measured the pair's prefill (since
  7062b62) every request with a first-content deadline, which the
  coordinator sends on every request, is refused `deadline_unreachable`,
  a lone one too. Before that, nothing was projected at all.
  - ProcessChecks: the real owner projects a request's prompt at the
    caller's prefill rate (the pair's own, measured end to end), and
    nothing without a usable rate. The MLX stand-ins gain the bounded
    projection and the prefill rate the owner reads.
  - DistributedCBv2DeadlineTests: a burst of eight 8,000-token prompts on
    eight lanes takes only the lanes whose first token meets a 30 s
    deadline (three at 1,000 tokens a second), and a prompt that has given
    its first token delays no other.

Locally: PlacementChecks 1 failed (above), ProcessChecks fails at the
projection, and a scratch copy of the width tests in the light runner
fails 11 expectations. ProviderCoreTests run in CI only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 2 commits November 9, 2026 18:46
…rvation (review P2-1)

Gemma 4's LOAD passes the whole width's reservation to its shard gate,
which asks for it before every tensor beside the rest of the shard, two
whole tensors, the read scratch and the loading headroom. The planner
priced a lane-charge width's load peak without it (`batchLoadReservation`
was 0 without a native quote), about 0.75 GB a rank short (the 369 MB
embedding twice and the read scratch). A width sits within one 5.3 GB step
of what a small Mac admits, so about one memory-bound pair in seven on
24-48 GB Macs was planned at a width that LOAD then refused, and the
memory re-plan picked the same width again.

A lane-charge width now counts the reservation in the load peak (and in
what the allocator holds), as a Qwen TP batch quote does:
`rankReserved ?? quote?.allowance.reservedBytes ?? (laneGrowth > 0 ? nativeFloor : 0)`.
Here `nativeFloor` already carries the lane growth (the allowance plus a
lane charge per lane after the first, LOAD's figure). One request plans
byte for byte as before.

PlacementChecks: 1,657 passed (the red check's 9 refused shapes now plan
a width LOAD admits; two idle 24 GB Macs still plan one lane).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e QAT 4-bit row only (review P2-2)

The cap is one constant, `ClusterPlacementTensorWidth.gemmaTensorParallelLanes`,
which `qualifiedLanes` reads for the row the M5 Ultra pair qualified:
- 2 for now; the owner chooses between 2 and 4. C1 (2026-11-10) gave every
  lane its solo tokens and logprobs at 2, 4 and 8, but served a request
  fastest at 2: 95.5 tok/s in all and 77 a request, against 96.2 and 48.5 at
  4, and 60.8 and 14.5 at 8, where the last of eight 8K-token prompts sent
  at once waited 63.7 s for its first token (7.7 s alone).
- QAT 4-bit only (`gemmaQualifiedRuntimeModelID`). The 8-bit rows run the
  same lanes on 8-bit kernels: neither the pair nor the synthetic lane
  checks (`Gemma4TensorParallelRuntimeTests`, all 4-bit) ran them at these
  widths, so they save no width and serve one request at a time.
  `savesTensorParallelWidth` still says their owner can serve a saved width.

The width search still tries 8, 6, 4 and 2 below the cap (the tests check
it with a cap of eight). Docs and the changelog fragment say 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 2 commits November 9, 2026 18:57
… prompts already holding a lane (review P2-2)

The pair's first-token projection counted nothing, other lanes included:
its owner (`DistributedPipeExecutionOwner.projectFirstToken`) always
returned unbounded ("no measured peer transfer/control envelope"), and the
session and the slot only forward it. The engine refuses an unbounded
projection, so once the bridge had measured the pair's prefill (7062b62,
also in 0.10.11) every request carrying a first-content budget, which the
coordinator sends with every request, was refused `deadline_unreachable`,
a lone one too. Before any rate was measured, every request went into a
free lane with no first-token check, as GH's burst shows (the last of
eight 8K-token prompts gave its first token at 63.7 s, 7.7 s alone).

- The owner projects the request's whole prompt at the caller's prefill
  rate, in chunk steps. For a pair that rate is the pair's own, measured end
  to end from both ranks' reservation to the first committed token
  (`DistributedCBv2Engine.timing`), so it already carries the transfer and
  control costs. Without a usable rate it still projects nothing.
- The engine puts that projection behind every prompt already holding a
  lane without its first token, running or waiting for its reservation
  (`behindPendingPrefill`, `pendingPrefillTokens`, `admittingPromptTokens`),
  priced at the same rate. A burst takes only the lanes whose first token
  meets its deadline; the rest are refused at once, for the coordinator to
  place elsewhere. Other lanes' decode steps between prompt chunks are not
  charged.

ProcessChecks, run-flow (33), the installed-session, console, diagnostics
and placement-setup (274) runners pass; the engine tests run in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The red run (e6192f0) showed the burst admitted into all eight lanes, as
expected, and one more failure that was the test's own: it dropped each
admitted stream at once, and a stream nobody holds cancels its request
(`continuation.onTermination`). A cancelled request has given up its prompt,
so it would no longer delay the next one, and the fix could never pass.
The test now keeps the streams until the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 10, 2026
#1936 now counts LOAD's reservation in a lane-charge width's load peak,
caps Gemma TP at 2 lanes for the QAT 4-bit row, and makes a pair project
each request's first token behind the prompts already holding a lane.

Resolutions:
- ClusterPlacementPlanner: here a width's growth sits outside the one-request
  floor (`nativeFloor` has no lane growth), so the load peak takes the
  review's form, `nativeFloor + laneGrowth`. The automatic merge kept
  `nativeFloor` alone, which would have left Gemma's lane charges out again.
  GLM's plans are unchanged: its every-rank charge already holds the load
  transients, so its request need still decides (PlacementChecks 1,667,
  the GLM decide tests and the setup checks' GLM pair unchanged).
- ClusterPlacementTensorWidth: GLM keeps eight; Gemma takes
  `gemmaTensorParallelLanes` for its qualified row.
- ClusterPlacementTensorWidthTests: #1936's Gemma tests on this branch's
  lane-row fixture (`LaneRow`, `laneChargeFixture`, `decideLaneCharged`,
  `savedAndScreenLanes`), beside the GLM test.
- inference.md and two-mac-cluster.md: both families' rows and bullets.

Light runners on the merge: PlacementChecks 1,667, placement setup 277,
run-flow 33, ProcessChecks, installed-session and configuration pass; a
scratch copy of the width tests passes for Gemma and GLM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ound-2 changes

A review-only refactor pass over this round (an independent agent that
edited nothing) found no compile risk and the admission bookkeeping sound.
Taken:
- Gemma's cap is one table, `ClusterPlacementTensorWidth.gemmaQualifiedLanes`
  (row to width, QAT 4-bit at 2), instead of a width constant beside a row
  constant compared by string.
- The planner says why one lane keeps its load peak: its shard gate holds
  the allowance too, so it stays the 0.75 GB short it was before widths,
  and one-request plans are unchanged (the review's own form). The docs
  say the same.
- The owner's projection says what it does with a request's images or
  video: its media tokens at the text rate, the vision tower's time not
  charged. The docs say a missing rate means no deadline admission (the
  request is admitted), while an admission without a prefill rate is
  refused.
- The burst test also checks that a reserved lane leaves no prompt counted
  as waiting (`admittingPromptTokens` back to 0).
- No wave names in comments (AGENTS.md); the code says "the M5 Ultra pair,
  2026-11-10".

Not taken: counting a one-lane plan's allowance in the load peak (it would
change every Gemma TP singleton plan, which the review chose to keep), and a
cancelled-but-cleanly-stopping lane's prompt in the pending prefill (reached
only where lanes do not retire alone).

PlacementChecks 1,657, ProcessChecks, placement setup 274 and the scratch
width tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 10, 2026
…llel width

#1936 made Gemma's cap one table (`gemmaQualifiedLanes`), explained why one
lane keeps its load peak, and documented the projection of media requests.

Resolutions:
- ClusterPlacementPlanner: this branch's `nativeFloor + laneGrowth`, with
  #1936's explanation and what the allowance is here (none for GLM, whose
  request need decides).
- ClusterPlacementTensorWidth: GLM's eight beside Gemma's table.
- inference.md: both families' planner and cap bullets, no wave names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 marked this pull request as ready for review November 10, 2026 06:00
jonathan308 added a commit that referenced this pull request Nov 10, 2026
… (0.10.12 candidate; head efb5cd5)

# Conflicts:
#	libs/darkbloom-cluster/Sources/DarkbloomClusterProtocol/ClusterRuntimeCapability.swift
jonathan308 added a commit that referenced this pull request Nov 10, 2026
The owner decided (2026-11-10) that a Gemma 4 pipeline pair keeps the
one-chunk lookahead and serves one request at a time by default in
0.10.12. On the M5 Ultra pair, serial prefill at 8 lanes made a lone
prompt's first token 1.84 to 1.94 times later at 8K to 64K tokens.

`ClusterPlacementPipelineWidth.qualifiedLanes` now reads a table keyed
by family, `qualifiedLanesByFamily`, which is empty. Every guided setup
and `darkbloom cluster plan` therefore keeps the placement chosen for one
request: for a Gemma layer split, the lookahead, no width, one lane.
Listing a family there (`.gemma4LayerStage: 8`) sizes its guided setups
again, as #1936's `gemmaQualifiedLanes` does for tensor parallel.

Unchanged:
- A setup saved with serial prefill and a width serves that width, and
  LOAD admits it whole. A local pair's automatic replacement saves such
  widths, Qwen 3.5's included.
- A setup saved without a width serves one lane.
- `ClusterPlacementPipelineWidth.size`, `pipelineLanes` pricing and
  `DistributedInstalledPlan.batchLanes`.

The re-plan after an update calls `decide` the same way, so a
coordinator pair approved with the lookahead keeps it and its approval.

Comments in `DistributedInstalledPlan` and two tests no longer say a
placement saves Gemma's width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stack (red)

The 0.10.12 candidate merged with #1937 died of SIGBUS in
`ClusterPlacementTensorWidthTests.aPlacementSavesTheWidestWidthBothMacsAdmitNow`:
a stack overflow on the 512 KiB thread Swift Testing runs a test on. In
CI's debug build, `ClusterPlacementFlow.decide` and the planner under it
used 387 KiB of that thread planning a tensor-parallel width (`decide`'s
own frame 99 KiB). The test left 20 KiB, and the merge grew `decide`'s
frame by 23 KiB. The guided step (`ClusterSetupPlanning.decide`) used
692 KiB, more than the onboarding's and the service's 512 KiB planning
threads have; its tests already run it on a 16 MiB thread.

Two checks measure how much of its caller's stack each entry point uses.
`stackUsed` runs a body on a thread whose 16 MiB stack it pattern-fills
first, so a planner that is too deep fails a check rather than killing
the test process. The budget is 64 KiB of the caller's 512 KiB:
- `decideLendsItsCallerLittleStack`: `decide` planning the 27B's widest
  width.
- `theGuidedStepLendsItsCallerLittleStack`: the guided step planning the
  27B's tensor parallel.

Both fail on this commit (debug: about 390 and 690 KiB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 2 commits November 10, 2026 00:08
…he planner only a wait

A plan is asked for on its caller's thread, and every caller's thread
has a 512 KiB stack: the onboarding's and the cluster service's planning
threads (`Thread.detachNewThread`), the automatic replacement's task,
`darkbloom cluster plan`'s task and every Swift Testing test. A debug
build's planner frames are large. On 2026-11-10 `ClusterPlacementFlow.decide`
used 387 KiB of a test's stack planning a tensor-parallel width (its own
frame 99 KiB). A test whose frames left 20 KiB died of SIGBUS when the
candidate's merge of #1937 grew `decide`'s frame by 23 KiB. The guided
step (`ClusterSetupPlanning.decide`) used 692 KiB, more than the threads
it runs on have, so its tests ran it on a 16 MiB thread of their own.
A release build used about 120 and 220 KiB, within 512 KiB.

`ClusterPlanningStack.run` runs a body on a thread with a 16 MiB stack
while the caller waits, and hands back its value or its error. The body
need not escape: the thread lets go of it before the caller goes on.
A thread inherits no task-local value, so it binds again the one the
planning reads (`ClusterPublicModels.declarationOverride`, which only
tests set). Both entry points now do their planning in a private
`decideOnPlanningStack` on that stack: `ClusterPlacementFlow.decide` and
`ClusterSetupPlanning.decide`.

The red checks pass. CI's red run measured 414 and 694 KiB. A replica of
`decide`'s check on the CPU runner measures 72 KiB in a debug build: the
wait, plus the check's own call. So the budget is 128 KiB, a quarter of
a caller's 512 KiB, rather than the red commit's 64 KiB. The red
measurements are well over both.

The guided-step tests no longer need `onLargeStack`. They call the guided
step on their test task, as the onboarding does. `ClusterPlacementChecks/run.sh`
compiles the new file; the other runners pick it up from the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- inference.md, Planning stack: both planning entry points run on a 16 MiB
  stack of their own while their 512 KiB callers wait, with the debug and
  release figures from 2026-11-10 and the task-local value bound again.
- test.md, Planning stack checks: what the two checks measure, how
  (`stackUsed` on a pattern-filled 16 MiB stack, so a planner that grows
  too deep fails a check instead of killing the test process), the
  128 KiB budget, and the debug figures before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 12, 2026
- docs/provider/two-mac-cluster.md: the Gemma example serves up to 2 at once (#1936's cap), not 8
- changelog.d/loop-guard.md: Super's text requests are covered (#2020)
- changelog.d/qwen35-card-rows-donate-checkpoints.md: the 9B has no default penalty again (#1961 via #2021)
- provider-swift/Sources/ProviderCore/Inference/Vision/MediaIngest.swift: no 64-image entry for the 9B
- provider-swift/Tests/ProviderCoreTests/Inference/Vision/MediaIngestTests.swift: the 9B's image-cap tests expect 16
- provider-swift/Tests/ProviderCoreTests/Inference/Vision/EngineV2VisionRoutingTests.swift: the preparer test expects the 9B's 17th image refused
- docs/architecture/inference.md: no 64 for the 9B
- docs/reference/configuration.md: no 64 for the 9B
- changelog.d/qwen35-9b-64-images.md: only the media_memory_unavailable bullet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 merged commit 63dae4f into dev Nov 12, 2026
26 checks passed

This branch was successfully deployed

3 active deployments
Preview – d-inference-landing — 8ace9d99 Deployed Nov 10, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 8ace9d99 Deployed Nov 10, 2026 by vercel[bot]
Preview – darkbloom-status — 8ace9d99 Deployed Nov 10, 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