Repository navigation
Raise CBv2 mixed-step prefill geometry for Gemma 4 - #1547
Conversation
…mma 4 With one partial prefill a busy engine prefills only its plain chunk beside decode rows, so production fed every mixed step 512 prompt tokens. GPT-OSS, dense Qwen3.5/3.8 and Gemma 4 now default to a 2,048-token plain chunk and a 4,096-token step budget (EngineV2Factory.prefillGeometry). The chunk replaces the 2,048-token GPT-OSS and Gemma stripes and stays below dense Qwen's 4,096-token stripe, so paged ring sizes, KV charges and load quotations are unchanged. Other families keep 512 / 2,048. Gemma 4 image and video requests keep 512-token chunks through the SDK's new bidirectionalMediaPrefillChunkCeiling (libs/mlx-swift-lm moves to the commit that adds it): a paged span-bearing chunk attends in one unblocked call, so its score tensor grows with the chunk length times the history. DARKBLOOM_CBV2_PREFILL_CHUNK and DARKBLOOM_CBV2_STEP_TOKENS override the geometry for every family and reach the launchd provider job; 512 / 2048 rolls back. Scheduler-prefill receipts record the geometry (schema 5), the decision live runner pins its simulated geometry, and fixtures that pin a stripe also pin the SDK chunk. Docs, a dated measurement report and a changelog fragment record the load, inter-token latency and activation evidence and its limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Behavior-preserving refactor-pass follow-up to the prompt geometry change. - inference.md invariant 9: a Gemma 4 block chunk stays within the 2,048-token ring because Gemma4Processor delimits every image and video frame, not because submit validation bounds blocks, which now admits them up to the 4,096-token step. - configuration.md: a solo stripe that does not exceed the plain chunk, including an equal one, is disabled. - productionSchedulerConfig: the media ceiling comment names bidirectional media, which is all the ceiling applies to. - SegmentedFleetGeometry: window rings follow the largest schedulable chunk, which for GPT-OSS and Gemma is now the plain chunk, not a stripe. - libs/mlx-swift-lm moves to the SDK commit that files the ceiling tests under Unit/Scheduling, matching SDK main; no library change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raw scheduler-prefill schema 5 adds the plain chunk and step budget. Like the raw sweep 8 / arrival 6 note, say why the wrapper schema does not move: the default workload's prompts each fit one chunk and no step exceeds 2,048 tokens, so the Gemma 4 geometry change does not alter its chunking; longer prompts beside decode rows do not compare across the change. Comment only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refresh for publication: master moved past this branch's base (Nemotron Super, GLM-5.3-Flash and the SSD restore staging PRs). Keep master's mlx-swift and MLX pins, pin libs/mlx-swift-lm to the paired SDK PR head, and keep both sides of the documentation rows that conflicted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Deployment failed for project eigen-homepages-darkbloom with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
|
Deployment failed for project darkbloom-status with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
|
Deployment failed for project d-inference-console-ui-dev with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
|
Deployment failed for project d-inference with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
|
Deployment failed for project d-inference-landing with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. Reviewers: anthropic/claude-sonnet-5.5: first pass completed Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Failure diagnostics: Coverage: 137/137 source units; cross-file integration complete. 2 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. Bedrock: 30 request(s), 1531033 uncached + 0 cache-read + 0 cache-write input / 23048 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately. |
The merge kept both sides of the conflicting prefix-cache.md paragraph, which repeated two sentences. Keep this branch's 2,048-token plain chunk and master's Nemotron Super alignment sentence once each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed for project darkbloom-status with the following error: Learn More: https://vercel.com/docs/limits#rate-limit-examples |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1514eac525
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Layr-Labs/mlx-swift-lm#331 squash-merged as c8dce97d ("Add an opt-in plain-chunk ceiling for bidirectional media requests (#331)"). Move the gitlink from the PR branch head 204771c4 to that commit on SDK main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ca5b2d45c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The previous pin, c8dce97d (#331), also carries SDK #332: chunk deltas now carry [OpenAIToolCallDelta] and MLXServerGenerationEvent gains .toolCallDelta, so ProviderLoop+SSEParser.swift no longer compiled. Pin f77b384c, the merged SDK main commit that adds #333's MLXLMServerTests build fix on top of #331 (same library tree). The SSE parser and the six test-file hunks are copied byte for byte from #1549 (ttft/stream-auto-tool-calls), so whichever of the two lands second merges cleanly. They change types only; this branch does not request streamed fragments, so complete calls hash and encode as before. Flint response-format code added by master's #1552 also switches over MLXServerGenerationEvent; it ignores .toolCallDelta like .toolCall, and its tests count a completed delta as a call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Master's #1535 added SchedulerPrefillPromptTests against schema 4. After the merge its receipt fixture omitted this branch's new required prefillChunkTokens and maxBatchedTokensPerStep and expected schema 4 from a current-version report, so the test target failed to compile. The fixture now records the SDK geometry and expects the current schema; the legacy case decodes a faithful schema-4 payload without the geometry fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
summarize_cell copied only soloPrefillStripeTokens from a scheduler-prefill receipt. Under the wide plain chunk a nil stripe no longer means 512-token chunks, so derived summaries could not tell a default run from an explicit chunk or step-budget arm. Prefill rows now also keep prefillChunkTokens and maxBatchedTokensPerStep (None for schema-4 receipts, which lack them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PR's own KV-subtracted activation probe at eight rows of 32,768-token prompts, inside the floors' measurement range of eight rows at 4k tokens or more, shows 2,048 / 4,096 pushing GPT-OSS from its 3.5 GiB floor to 3.62 GiB and Qwen3.5-9B from 5.73 to 6.03 GiB against the 5.5 GiB default. No margin absorbs that: UnifiedMemoryCap.liveKVHeadroomBytes grants KV until MLX usage plus the reserve reaches the cap, so activation above the reserve lands past the cap once the KV budget is full. Floors are measured constants that move only with platform admission, so they stay unchanged here. usesWidePrefillChunk now selects Gemma 4 alone (3.73 GiB at 32k against 5.5). GPT-OSS and dense Qwen3.5/3.8, including the unmeasured Qwen3.8-27B, keep 512 / 2,048 and their stripes; DARKBLOOM_CBV2_PREFILL_CHUNK=2048 with DARKBLOOM_CBV2_STEP_TOKENS=4096 still opts them in for measurement. Tests pin GPT-OSS and dense Qwen to the SDK geometry and drive the GPT-OSS busy-engine and pool-lockstep cases through the opt-in. The GPT-OSS and Qwen live checkpoint fixtures no longer need to pin the SDK geometry and return to master's form; prefix-cache.md returns to master because no recurrent family takes the wide chunk by default. The report gains a default-scope section with the per-cell margins and names the SDK revision the probes ran on (cef662176, before SDK #326's GPT-OSS bf16 activations). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Gemma 4 chunk that starts at a bidirectional media block extends over the whole block, and submit validation bounds blocks only by the step budget, but the paged window rings hold max(chunk, stripe) tokens. With DARKBLOOM_CBV2_PREFILL_CHUNK=256 and DARKBLOOM_CBV2_SOLO_PREFILL_STRIPE=0 the rings held 256 tokens and a 280-token image block tripped the PagedSequenceKV precondition, killing the provider. prefillGeometry now raises a Gemma 4 chunk to 1,120 tokens, the vision family's largest image budget, whenever the override leaves max(chunk, stripe) below it. The default 2,048-token chunk, the documented 512 / 2,048 rollback (its 2,048-token stripe re-arms) and other families are unchanged. A geometry test pins the raised values; an engine test prefills a 300-token block beside decode under chunk 256 with the stripe off. With the guard disabled the first fails and the second stops on "windowed update of 300 tokens exceeds maxPrefillChunk 256". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scheduler-prefill receipt took prefillChunkTokens, maxBatchedTokensPerStep and soloPrefillStripeTokens from EngineV2Factory.prefillGeometry before production applied later policy: glm5NextServingScheduler (2,048 / 2,048, stripe off), the calibrated Nemotron clamp and any dedicated scheduler policy. A GLM or Nemotron run could therefore be attributed to the generic geometry. ProductionBuild now carries prefillGeometry, taken from the scheduler configuration assembleProductionBuild hands the engine. The benchmark records the warm-up engine's value and fails the run if a measured engine was built with different geometry, so one report-level field never describes samples it does not cover. A test builds a tiny paged GPT-OSS engine with and without a scheduler policy that narrows the chunk, step and stripe, and checks the build reports the narrowed geometry rather than prefillGeometry(model:). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1549 does FlintResponseFormatTests counted every .toolCallDelta event as a call, so it disagreed with FlintAnswerStopTests and with #1549 (ttft/stream-auto-tool-calls), which count a delta only when it completes a call. Both helpers now match #1549's files byte for byte, so this branch and #1549 merge without conflicts in either file. Behavior is unchanged: this branch does not request streamed fragments, so its engines emit only whole .toolCall events. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f95ff5ee4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e19f138 kept the windowed rings at least one Gemma 4 media block wide, but submit validation also refuses a block longer than the step budget (CBv2MultimodalPlan.validate). With a chunk below the block, a stripe that already covers it and an explicit step budget equal to the small chunk (for example 256 / 1,120 / 256), the ring guard did not fire and every image request failed with spanTooLong although the rings could hold the block. prefillGeometry now raises a Gemma 4 step budget below 1,120 tokens (gemma4MaximumMediaBlockTokens) to 1,120. Defaults, the 512 / 2,048 rollback and other families are unchanged. A geometry test pins the raised budget and that other families keep theirs. A real paged Gemma 4 engine test submits a 300-token block under chunk 256, stripe 1,120 and step 256. With the clamp removed, the geometry test fails and the engine test catches .spanTooLong(blockTokens: 300, maxBatchedTokensPerStep: 256). inference.md invariant 9 records the budget bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prompt-geometry docs said an explicit DARKBLOOM_CBV2_PREFILL_CHUNK applies to every family. Three later policies replace or cap it: glm5NextServingScheduler sets GLM5Next's own 2,048-token chunk and step; NemotronSuperLocalPrefill.Policy.apply sets Nemotron Super local serving's chunk (DARKBLOOM_NEMOTRON_SUPER_PREFILL_CHUNK) and step; and calibratedPrefillTokenLimit caps calibrated Nemotron chunks. inference.md and the configuration rows now name these exceptions, and point to the receipts' built geometry. The STEP_TOKENS row also records the Gemma 4 media-block budget raise. The changelog said solo prefill is unchanged. Solo chunking is, but the 2,048-token Gemma stripe used to shrink to 512 tokens once when KV could not be reserved, and a plain chunk does not. On contiguous KV (Gemma 4 artifacts other than the catalog's paged gemma-4-26b-qat-4bit, or with paging disabled), such a prompt now waits or is preempted. The fragment now says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts resolved by keeping both sides: - docs/architecture/hardware-support.md: the prompt-geometry paragraph stays under "Serving width by chip", followed by master's new "Deadline admission rates" section. - LaunchAgentRestartTests.swift: master's forwardsDeadlineAdmissionRollbackToProviderJob and this branch's forwardsPrefillGeometryRollbackToProviderJob are separate tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions Move forwardsPrefillGeometryRollbackToProviderJob up beside forwardsPrefillOperationalControlsUnchanged, mirroring the key order in inferencePassthroughEnvKeys, so it no longer shares an insertion point with the serving-stalls test after the deadline-admission test. Pure move; the test body is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raise CBv2 mixed-step prefill geometry for Gemma 4
Summary
EngineV2Factory.prefillGeometry,usesWidePrefillChunk,isGemma4).CBv2SchedulerConfig's SDK defaults (512 / 2,048) are unchanged.DARKBLOOM_CBV2_PREFILL_CHUNK=2048withDARKBLOOM_CBV2_STEP_TOKENS=4096opts them in for measurement.PagedLayerCache.prefillAttend), so a 2,048-token image chunk would quadruple a score tensor the activation reserve does not bound. SDK feat(coordinator): predictive model warming with thermal hysteresis #331 adds the opt-inCBv2SchedulerConfig.bidirectionalMediaPrefillChunkCeiling. The provider sets it to 512 whenever the plain chunk is wider, so Gemma image and video requests chunk exactly as before.max(chunk, stripe)below 1,120 tokens (gemma4MaximumMediaBlockTokens, the vision family's largest per-image budget) is raised to 1,120 and the stripe is cleared (e19f138). A block rides one chunk, and the paged windowed rings hold onlymax(chunk, stripe)tokens.max(chunk, stripe), the paged rings, KV charges and load quotations are unchanged. Activation floors stay unchanged; Gemma's measured peak at 8 × 32k leaves 1.77 GiB of its 5.5 GiB floor.DARKBLOOM_CBV2_PREFILL_CHUNK=512 DARKBLOOM_CBV2_STEP_TOKENS=2048. Both keys are forwarded to the launchd provider job. Explicit values apply to every family, except that GLM5Next, Nemotron Super local serving and calibrated Nemotron models replace or cap them with their own policies (documented in 8a9d48a). Malformed values restore the SDK geometry. Like everyDARKBLOOM_CBV2_*key, either one disqualifies reviewed profiles.scripts/gptoss_profilesummaries carry those fields (e541cbd).docs/reports/2026-10-21-mixed-step-prefill-geometry.md. Its new "Default scope" section gives the per-cell floor margins behind the Gemma-only default.Before / After: observable behavior
flowchart TB subgraph BEFORE["Before (master)"] direction TB b1["Rows decoding"]:::state --> b2["New 4k-32k-token text prompt"]:::req b2 --> b3["Every family: 512 prompt tokens<br/>per mixed step, step budget 2,048"]:::old b3 --> b4["8-64 mixed steps, each paying<br/>fixed host + readback cost"]:::old b4 --> b5["Late first token; decoders<br/>share many slow steps"]:::bad b6["Gemma 4 image / video request"]:::req --> b7["512-token chunks"]:::same b8["Operator"]:::req --> b9["only the solo-stripe key;<br/>no chunk or step key"]:::same b10["Scheduler-prefill benchmark"]:::req --> b11["receipt schema 4: stripe from<br/>the factory default, not the built engine"]:::old end subgraph AFTER["After"] direction TB a1["Rows decoding"]:::state --> a2["New 4k-32k-token text prompt"]:::req a2 --> a3{"Gemma 4?"}:::decide a3 -->|yes| a4["2,048 prompt tokens per mixed step,<br/>step budget 4,096"]:::new a4 --> a5["4x fewer mixed steps: earlier first token,<br/>more full-speed decode steps"]:::good a4 --> a9["Trade-off: a decode token that shares a<br/>prompt step waits for 2,048 tokens<br/>(p90 gap ~5x shorter, p99 2-3x longer)"]:::trade a3 -->|no| a6["512 / 2,048 unchanged: GPT-OSS, dense and<br/>MoE Qwen, Nemotron, Bonsai, MiMo, ..."]:::same a7["Gemma 4 image / video request"]:::req --> a8["still 512-token chunks<br/>(bidirectional media ceiling)"]:::same a10["Operator"]:::req --> a11["CHUNK / STEP_TOKENS keys: roll Gemma back<br/>or opt GPT-OSS / dense Qwen in"]:::new a11 --> a12["Gemma chunk or step override below a whole<br/>media block: raised to 1,120 tokens, so no<br/>ring-bound crash and no spanTooLong refusal"]:::new a13["Scheduler-prefill benchmark"]:::req --> a14["receipt schema 5: chunk, step and stripe of<br/>the engine actually built; a mismatch fails the run"]:::new end BEFORE ~~~ AFTER style BEFORE fill:#fff7f6,stroke:#c0392b,color:#111111 style AFTER fill:#f4fbf6,stroke:#1e8449,color:#111111 classDef state fill:#e8eef7,stroke:#4a6fa5,color:#111111 classDef req fill:#f3e8fd,stroke:#7d3c98,color:#111111 classDef old fill:#fde2e1,stroke:#c0392b,color:#111111 classDef bad fill:#f9c9c6,stroke:#922b21,color:#111111 classDef new fill:#dcf5e3,stroke:#1e8449,color:#111111 classDef good fill:#b9ecc8,stroke:#196f3d,color:#111111 classDef trade fill:#fff4e6,stroke:#d35400,color:#111111,stroke-dasharray: 4 3 classDef decide fill:#fff3c4,stroke:#b7950b,color:#111111 classDef same fill:#ececec,stroke:#7f8c8d,color:#111111Before / After: code flow
flowchart TB subgraph BEFORE["Before (master)"] direction TB p1["productionSchedulerConfig"]:::code --> p2["CBv2SchedulerConfig(maxConcurrentRequests:)<br/>SDK defaults: chunk 512, step 2,048"]:::old p2 --> p3["soloPrefillStripeTokens(abovePlainChunk: 512)<br/>2,048; dense Qwen 4,096"]:::code p3 --> p4["SchedulerV2.prefillChunkCap<br/>stripe or prefillChunkSize"]:::sdk p3 --> p5["makeSegmentedPagedBackend<br/>maxPrefillChunk = max(chunk, stripe)"]:::pool p6["SchedulerPrefillBenchmark receipt<br/>schema 4, stripe from the factory"]:::old p7["SDK pin 889fe3cc<br/>SSE parser collects OpenAIToolCall"]:::old end subgraph AFTER["After"] direction TB q1["productionSchedulerConfig"]:::code --> q2["prefillGeometry(model, environment)"]:::new q0["darkbloom start: LaunchAgent<br/>inferencePassthroughEnvKeys forwards<br/>both keys to the launchd job"]:::new -.-> q3 q2 --> q3{"DARKBLOOM_CBV2_PREFILL_CHUNK /<br/>_STEP_TOKENS set?"}:::decide q3 -->|no| q4["usesWidePrefillChunk = isGemma4:<br/>Gemma 4 2,048 / 4,096;<br/>others 512 / 2,048 and their stripes"]:::new q3 -->|yes| q5["explicit chunk for every family;<br/>budget explicit, else max(2,048, 2 x chunk);<br/>malformed values: SDK geometry"]:::new q4 --> q9{"Gemma 4 and max(chunk, stripe)<br/>below 1,120?"}:::decide q5 --> q9 q9 -->|"yes (overrides only)"| q10["chunk = gemma4MaximumMediaBlockTokens<br/>(1,120), stripe off"]:::new q9 -->|no| q14 q10 --> q14["stepTokenBudget; Gemma 4 budget<br/>at least 1,120 (overrides only)"]:::new q14 --> q6["media ceiling 512 when chunk > 512"]:::code q6 --> q7["SchedulerV2.prefillChunkCap<br/>plainPrefillChunkSize(hasBidirectionalBlocks:)"]:::sdk q6 --> q8["makeSegmentedPagedBackend<br/>max(chunk, stripe), unchanged for defaults"]:::pool q6 --> q11["assembleProductionBuild<br/>ProductionBuild.prefillGeometry =<br/>PrefillGeometry(scheduler:) after GLM / Nemotron policy"]:::new q11 --> q12["SchedulerPrefillBenchmark receipt schema 5;<br/>a measured engine with other geometry fails;<br/>gptoss_profile summary keeps the fields"]:::new q13["SDK pin f77b384c (SDK PRs 332, 331, 333)<br/>SSE parser collects OpenAIToolCallDelta (type only)"]:::new end BEFORE ~~~ AFTER style BEFORE fill:#fff7f6,stroke:#c0392b,color:#111111 style AFTER fill:#f4fbf6,stroke:#1e8449,color:#111111 classDef code fill:#e3ecfa,stroke:#2e5c9e,color:#111111 classDef old fill:#fde2e1,stroke:#c0392b,color:#111111 classDef new fill:#dcf5e3,stroke:#1e8449,color:#111111 classDef decide fill:#fff3c4,stroke:#b7950b,color:#111111 classDef sdk fill:#fdebd0,stroke:#b9770e,color:#111111 classDef pool fill:#efe3fa,stroke:#7d3c98,color:#111111Legend:
Evidence
All measurement arms ran on mlx-swift-lm
cef662176, the paired SDK change before its merge. That revision predates SDK #326 (GPT-OSS bf16 activations) and #327 (fused causal prompt attention). The GPT-OSS and Qwen3.5-9B rows were measured with the geometry forced through the environment. They now show the opt-in, not the default.Production-like load (lead measurement, standalone server)
Setup:
gather_qmmruns 26-31 TFLOPS at 512 rows, 57-68 at 2,048 and 85 at 4,096. Every step also pays a fixed host and readback cost. A prompt therefore finishes in a quarter of the mixed steps, which also gives decoders more full-speed steps.Engine cells: TTFT and inter-token latency (M5 Ultra, shared GPU)
darkbloom benchmark --sweep, production paged factory, 8 rows × 8,192-token prompts × 512 decode tokens submitted together, so later rows prefill beside up to 7 decoders. Arms are paired; absolute timings are contended.The p90 inter-token gap falls ~5x, because a quarter as many decode tokens share a step with prompt work. The p99/max gap grows 2-3x: a token that does share a step waits for the whole 2,048-token chunk. See Limitations and the #1534 note.
Activation memory (KV-subtracted, production paged factory, B=8)
ChunkGeometryActivationProbe(a temporary test, not committed) built each engine throughEngineV2Factory.makeProductionBuild, submitted 8 rows and polled the segmented pool's committed bytes every 2 ms. It used two estimates of the activation term:The table shows the larger. No MTP drafter was attached.
Units are GiB (larger of the two estimates) for 8 rows, with 512 decode tokens at 8k and 64 at 32k. The floors are measured at B=8 with prompts of at least 4k tokens, so both prompt lengths are in their measurement range. Findings:
UnifiedMemoryCap.liveKVHeadroomBytesgrants KV until MLX usage plus the reserve reaches the cap, so once the KV budget is full any activation above the reserve lands past the cap. That is why GPT-OSS and dense Qwen keep master's geometry by default.CBv2RecurrentCheckpointGeometry.isRecurrentBoundary).Gemma 4 media (paged, one 280-token image 768 tokens before the end, solo)
Consumer audit
makeSegmentedPagedBackend,maxPrefillChunk = max(chunk, stripe))PagedSequenceKV.writeprecondition)Gemma4Processordelimits every image and frame withboi/eoi, giving blocks of at most 1,120 tokens (280 in the catalog), and they never coalesce. Overrides that leavemax(chunk, stripe)below 1,120 are raised to 1,120 (e19f138). Submit validation (CBv2MultimodalPlan.validate) bounds blocks only by the step budget; this isinference.mdinvariant 9.gather_qmm)cb77239, upstream #4572) bounds the per-simdgroup row count. Sorted gathers of 32,767-40,000 rows pass on M5 Ultra NAX, so upstream #3922 needs no port.EngineV2.init,gatheredAttention)UnifiedMemoryCapactivation reserveSchedulerV2.plan)autodefault for Gemma 4 artifacts other than the catalog's pagedgemma-4-26b-qat-4bit, and applies whenever paging is disabled. The changelog states this (8a9d48a). GemmasoloStripeChunkscounts drop to 0. GPT-OSS and dense Qwen stripes are unchanged.mixedStepPrefillTokenCap(MixedPrefillPolicy)FirstTokenDeadlineAdmissionV2,prefillDeadlineProjectionSupported)multimodalWork), so the media ceiling needs no mirror. Support still requires a partial cap of 1.CBv2RecurrentCheckpointGeometry,demandedCheckpointRange)validateContiguousCheckpointChunk)[2048, max(2048, stripe)]. Older manifests were already invalidated by build identity.CBv2MultimodalPlan.validate,snappedChunkTokens)stepTokens > maxBatchedTokensPerStep,CBv2MTPAllocationLimits)EngineV2MTPProductionAdmissionTests(Gemma target, bounded test drafter) passed 8/8 on the native lane in the first round.ServingPerformanceProfiles,DeadlineRuntimeConfiguration)prefill_chunk_sizeand the stripe; the budget follows them when there is no override. Profiles pin the provider version, and anyDARKBLOOM_CBV2_*override fails closed.maximumChunkSize)max(chunk, stripe)is unchanged.scripts/gemma_contbatchaccepts schema 5, andscripts/gptoss_profilesummaries keep the fields (e541cbd). The decision live runner pins its simulated geometry. The GPT-OSS/Qwen live checkpoint fixtures are back to master's form.Smaller Macs
There is no RAM gate:
Not measured: 16-24 GB Macs, four-row widths, contexts beyond 32k, and inter-token tails on slow GPUs.
SDK pin and the tool-call delta type
libs/mlx-swift-lmmoves889fe3cc→f77b384c(SDK main). The three commits between them:tool_callsfragments, and changesOpenAIChatCompletionChunkdeltatoolCallsto[OpenAIToolCallDelta].bidirectionalMediaPrefillChunkCeiling.MLXLMServerTestsbuild after paper: restructure sections for cleaner information flow #332.feat(coordinator): predictive model warming with thermal hysteresis #331 merged on top of paper: restructure sections for cleaner information flow #332, so no SDK-main commit has the ceiling without paper: restructure sections for cleaner information flow #332. The previous head pinned
c8dce97dwithout Add provider owner email notifications #333, and the provider and SDK test builds failed in CI.The provider adaptation (e8dba33) is type-only:
ProviderLoop+SSEParser.swift(StreamChunkExtract.toolCallsDelta,encodeToolCallsForHash) and six test files are byte-identical to Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549's versions.FlintResponseFormat.swiftignores.toolCallDeltalike.toolCall.OpenAIToolCallDelta(call)encodes the same sorted keys as the whole call, so the attestation hash input for complete calls is unchanged.No tool-call behavior changes here. The provider's
ToolStreamPreparation.makeHandlerpasses no streaming options on this branch, so calls still arrive whole. Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549 owns the fragment-streaming feature and its changelog.Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549 also pins
f77b384c, andgit merge-treeof this head against Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549's head5deb03903is clean. The two PRs can land in either order. If Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549 changes the SSE parser or the shared test files again before landing, re-sync them here.Interaction with #1534 and sibling branches
productionSchedulerConfig, and no longer moves the SDK pin.merge-treeagainst it (its branch is not fetched locally).docs/architecture/hardware-support.md,LaunchAgentRestartTests.swiftLaunchAgentRestartTests.swiftdocs/reports/README.mdReview follow-ups
Fixed in this round (all review threads answered and resolved):
f77b384c(#333 test fix) and adapt the provider toOpenAIToolCallDelta(type-only, byte-identical to #1549)SchedulerPrefillPromptTestsbuilt schema-4 receipts without this PR's fields. The fixture now fills them, and a real schema-4 payload still decodes.isGemma4). GPT-OSS and dense Qwen3.5/3.8, including the unmeasured Qwen3.8-27B, keep master's geometry. Floors are unchanged. The report gains a "Default scope" section.ProductionBuild.prefillGeometrycomes from the built scheduler config; the benchmark records it and fails on a mismatch.gptoss_profilesummaries carryprefillChunkTokensandmaxBatchedTokensPerStep.spanTooLong. Covered by a geometry test and a real-engine test, both mutation-checked.inference.mdandconfiguration.mdname GLM5Next, Nemotron Super local serving and calibrated Nemotron as families whose policy replaces or caps the overrides.Follow-ups (deferred):
OpenAIToolCallDeltafragments,encodeToolCallsForHashadds one marker per fragment tofullResponseText, which feedsdeliveredCompletionTokenFlooron cancellation. This is not reachable here: no engine on this branch emits.toolCallDelta, so each call is one complete delta, encoded exactly as on master. The parser is byte-identical to Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549's, and Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549 owns the fix. This branch re-syncs if Stream auto tool calls while they are generated and seed content for plain Qwen prompt tails #1549 changes the parser.f77b384c; all measurements above ran oncef662176.maxPrefillChunk. The provider now guards Gemma overrides, but the SDK accepts any block that fits the step budget. Related and pre-existing:Gemma4Processordoes not validate amax_soft_tokensabove 1,120.solo_stripe_chunksdrops to 0 andprefill_chunk_tokens_maxreaches 2,048 under decode company.Validation
This round ran on the M3 Ultra, on the pushed tree with SDK
f77b384cand master8f6958689merged. Onf95ff5ee4, CI's Provider SDK Tests, Provider Prompt Parity, Release Integrity, Docs Lint, Docs Impact and Commit Signatures passed before the follow-up push. Full CI runs again on the pushed head8a9d48aec.swift build --build-tests -j 8inprovider-swift/(staged testmlx.metallibviascripts/stage-test-metallib.sh), re-run after each changeSchedulerPrefillPromptTests.swift:95(fixed in 4402b3a); every later build completed with no new warningsswift test --skip-build --no-parallel --filterover the touched suites, with isolatedDARKBLOOM_STATE_FILE/DARKBLOOM_LOADED_MODELS_FILE(the implementer's run)ProviderLoopStreamChunkTests,EngineV2PrefillGeometry*,EngineV2KVBackendGateTests,EngineV2ProductionWiring*,SchedulerPrefill*,ThroughputSweepTests,ModelBenchmarkReportTests,ModelPrefixBenchmarkDiagnosticsTests,ModelCheckpointStorageSpecificationTests,LaunchAgentEnvironmentTests,SegmentedProductionGrantTests,ServingPerformanceProfileTests,ServingConstructionPolicyTests,FlintResponseFormat*,FlintAnswerStop*,StreamedToolCall*,ToolStream*. Only hardware- or model-gated live tests skip.parseStreamChunk,encodeToolCallsForHash, production wiring)gemmaChunkOverrideCoversMediaBlockfails with 4 issues, one per raised case (256/0, 512/0, 1119/0, 256/600).gemmaUndersizedChunkHoldsMediaBlockcrashes withPagedSequenceKV.swift:496: Precondition failed: windowed update of 300 tokens exceeds maxPrefillChunk 256. Source restored and rebuilt.ProductionPromptParityTests,NemotronTemplateParityLiveTests(unpinned,PROMPT_PARITY_REQUIREDunset)f77b384c:swift build --build-tests -j 8;run-nested-suite.sh MLXLMServerTests --no-parallel;run-nested-suite.sh BidirectionalMediaChunkCeiling --no-parallelpython3 -m unittest discover -s gptoss_profile/testssummary.pyreverted, the new test fails withKeyError: 'prefillChunkTokens'.scripts/docs-check.sh;DOCS_IMPACT_BASE=origin/master python3 scripts/docs-impact-check.py;python3 scripts/changelog.py check/preview191 file(s) OK; coverage OK (37 changed files);45 valid fragment(s), and the rewritten fragment rendersswift build --build-tests -j 8, then the focused run overEngineV2PrefillGeometry,SchedulerPrefill,EngineV2KVBackendGateTests,LaunchAgentEnvironmentTests,EngineV2ProductionWiring,FlintResponseFormat,FlintAnswerStop,parseStreamChunkandencodeToolCallsForHashgemmaStepBudgetOverrideCoversMediaBlockfails.gemmaUndersizedStepBudgetAdmitsMediaBlockcatches.spanTooLong(blockTokens: 300, maxBatchedTokensPerStep: 256). Source restored, rebuilt, and the focused run re-passed.docs-check: 191 file(s) OK; docs-impact coverage OK (37 files);changelog: 45 valid fragment(s)git merge-tree --write-treeagainstorigin/masterand #1549 (5deb03903) at8a9d48aecgit verify-commiton every new first-parent commitFirst-round validation, on the M5 Ultra at SDK
cef662176and an older base:EngineV2MTPProductionAdmissionTestspassed 8/8 (Gemma target, exclusive native GPU).make benchmark-wrapper-testpassed.Not run in either round:
make provider-testlane (CI runs it);Interface and migration effects
New keys.
DARKBLOOM_CBV2_PREFILL_CHUNKandDARKBLOOM_CBV2_STEP_TOKENSare documented indocs/reference/configuration.mdand forwarded byLaunchAgent.inferencePassthroughEnvKeys. On Gemma 4, explicit chunk or step overrides below a whole media block are raised to 1,120. GLM5Next, Nemotron Super local serving and calibrated Nemotron models replace or cap them with their own policies.New SDK field.
CBv2SchedulerConfig.bidirectionalMediaPrefillChunkCeilingdefaults to nil; SDK behavior is unchanged unless it is set.No contract changes. There is no wire, telemetry schema, KV quotation or activation-floor change.
Gemma 4 value changes:
soloStripeChunksdrops to 0.prefillChunkTokensMaxreaches 2,048 under decode company.prefill_chunk_size2048.Other families report the same values as on master.
Serving profiles.
ServingPerformanceProfiles.runtimeRevision(cbv2-first-content-v2, mirrored by the platform) is not bumped: both catalogs are empty, and profiles pin the provider version. A future reviewed Gemma profile must be measured under this geometry, and bumping the revision is a coordinated platform decision.Receipt schema 5.
SchedulerPrefillBenchmarkReportschema 5 adds optionalprefillChunkTokensandmaxBatchedTokensPerStep. WithsoloPrefillStripeTokens, they now come from the production build's scheduler (ProductionBuild.prefillGeometry). A run whose measured engines disagree fails. This is documented indocs/provider/cli-reference.md.Limitations
configuration.mdandinference.mdinvariant 9.cef662176. Engine cells and probes shared the GPU, so timings are paired comparisons.CBv2PackedPrefillTests.testGemma4AdapterAdvertisesAndHonorsPackedPrefillfails identically on a clean SDK pin on the M5 Ultra.MiMoV26NativeLoadTransactionTestsreportsfixtureRequiredwithout MiMo fixtures.Refactor pass
AGENTS.mdgate) on the prepared branches. It added two behavior-preserving commits (51e331abc,585890d0a) and one in the SDK. No logic, test assertion or public contract changed.Unit/Scheduling/.inference.mdinvariant 9 was clarified.configuration.mdnow says that a stripe equal to the chunk is disabled.gemma_contbatchschema comments were tightened.f77b384cdescends from master's889fe3ccthrough paper: restructure sections for cleaner information flow #332, feat(coordinator): predictive model warming with thermal hysteresis #331 and Add provider owner email notifications #333 only.makeSegmentedPagedBackendsizes from the same config.schedulerConfighanded toEngineV2.isGemma4now replaces the duplicated three-way Gemma type test, which the first round had kept for Keep Qwen streams decoding while a long prompt prefills #1534 hunk separation; Keep Qwen streams decoding while a long prompt prefills #1534 no longer touches that line.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.