Skip to content

Raise CBv2 mixed-step prefill geometry for Gemma 4 - #1547

Merged
Gajesh2007 merged 19 commits into
masterfrom
ttft/mixed-prefill-chunk
Oct 22, 2026
Merged

Gajesh2007 merged 19 commits into
masterfrom
ttft/mixed-prefill-chunk

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Paired SDK PR Layr-Labs/mlx-swift-lm#331 is merged. libs/mlx-swift-lm moves from master's 889fe3cc to SDK main f77b384c, which contains #332, #331 and #333 in that order (e8dba33). See SDK pin and the tool-call delta type.

Raise CBv2 mixed-step prefill geometry for Gemma 4

Summary

  • Why. With one partial prefill, a busy engine prefills only its plain chunk beside decode rows, because the solo stripe disarms whenever an unpaused decode row exists. Production therefore fed every mixed step 512 prompt tokens.
  • Gemma 4. It now defaults to a 2,048-token plain chunk and a 4,096-token step budget (EngineV2Factory.prefillGeometry, usesWidePrefillChunk, isGemma4). CBv2SchedulerConfig's SDK defaults (512 / 2,048) are unchanged.
  • GPT-OSS and dense Qwen3.5/3.8 keep 512 / 2,048 and their stripes by default (0f92cac, after review).
    • Both reached the first token sooner under the wide geometry in the load test.
    • At eight concurrent 32k-token prompts, though, it lifted their KV-subtracted activation peaks further above their measured floors: GPT-OSS from 3.50 to 3.62 GiB against 3.5, and Qwen3.5-9B from 5.73 to 6.03 GiB against 5.5.
    • Floors are measured constants that move only with platform admission, so they stay unchanged.
    • DARKBLOOM_CBV2_PREFILL_CHUNK=2048 with DARKBLOOM_CBV2_STEP_TOKENS=4096 opts them in for measurement.
  • Gemma 4 media keeps 512. A paged span-bearing chunk attends in one unblocked call (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-in CBv2SchedulerConfig.bidirectionalMediaPrefillChunkCeiling. The provider sets it to 512 whenever the plain chunk is wider, so Gemma image and video requests chunk exactly as before.
  • Gemma 4 overrides always hold a whole media block.
    • A chunk override that leaves 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 only max(chunk, stripe) tokens.
    • A step budget below 1,120 is raised to 1,120 too (af702d9), because submit validation refuses a block longer than the step budget.
  • No pool-sizing change. Gemma's 2,048-token chunk replaces its former 2,048-token stripe, so 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.
  • Other families are unchanged. MoE Qwen, Qwen3-VL, Qwen4, MiMo, Nemotron 3.5 Lightning and Bonsai keep 512 / 2,048 (reasons below).
  • Rollback and opt-in keys. Rollback: 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 every DARKBLOOM_CBV2_* key, either one disqualifies reviewed profiles.
  • Benchmark receipts. Scheduler-prefill receipts (schema 5) record the geometry the production build actually handed the engine, after serving, calibration and GLM policy (872edea). scripts/gptoss_profile summaries carry those fields (e541cbd).
  • Report. Measurements are in 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:#111111
Loading

Before / 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:#111111
Loading

Legend:

  • red: previous production path
  • green: new policy
  • yellow: decision
  • orange: SDK scheduler
  • purple: paged pool sizing (unchanged for defaults)
  • grey: unchanged behavior
  • dashed orange outline: trade-off

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:

  • Poisson arrivals; lognormal prompts (median 4k, p90 16k, cap 32k tokens); 100-600 output tokens.
  • Unique prompt nonces (no prefix reuse) and an identical seeded schedule per arm; MTP auto, paged KV.
  • M5 Ultra: 0.3 req/s, 78 requests, width pinned at 8, builds paused. M3 Ultra: 0.1 req/s, 32 requests.
  • Arm A forced 2,048 / 4,096 through the environment on an otherwise unchanged build.
Mac Model TTFT p50 / p90 / p99 s, base → A Decode p50 (p10) tok/s, base → A
M5 Ultra Gemma 4 26B QAT 1.34 / 3.87 / 5.91 → 0.56 / 2.47 / 4.46 51.3 (25.7) → 58.8 (34.9)
M5 Ultra GPT-OSS 20B (opt-in) 1.56 / 6.14 / 9.03 → 1.19 / 4.57 / 7.53 51.5 (21.5) → 59.7 (26.6)
M5 Ultra Qwen3.5-9B (opt-in) 2.25 / 6.97 / 9.13 → 1.67 / 5.48 / 7.66 40.3 (19.0) → 49.5 (21.4)
M3 Ultra Gemma 4 26B QAT 5.15 / 10.62 / 16.94 → 4.15 / 8.96 / 14.51 46.1 (14.3) → 54.6 (16.4)
M3 Ultra GPT-OSS 20B (opt-in) 7.36 / 15.9 / 23.0 → 6.76 / 13.84 / 20.9 52.7 → 55.8
M3 Ultra Qwen3.5-9B (opt-in; width 4, overloaded) 18.33 / 33.59 / 38.32 → 18.04 / 31.12 / 35.66 36.3 → 40.7
  • Every M5 Ultra arm completed 78/78, and aggregate output was unchanged and arrival-bound (~118 tok/s).
  • Solo cold prefill is unchanged: Gemma's 2,048-token chunk equals its former stripe. An M3 Ultra 2,048 / 4,096 / 8,192 stripe sweep differs by under 2%.
  • Mechanism: on the M5 Ultra, Gemma gather_qmm runs 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.

Model Last first token s, 512 → 2,048 Decode p50 tok/s ITL p50 / p90 / p99 / max ms, 512 → 2,048
Gemma 4 26B QAT 12.13 → 7.90 34.2 → 40.0 20 / 91 / 113 / 198 → 19 / 21 / 256 / 495
GPT-OSS 20B (opt-in) 14.01 → 10.33 30.0 → 35.3 23 / 99 / 131 / 232 → 21 / 22 / 327 / 682
Qwen3.5-9B (opt-in) 15.06 → 12.50 33.0 → 36.4 19 / 111 / 136 / 244 → 18 / 19 / 401 / 779

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 through EngineV2Factory.makeProductionBuild, submitted 8 rows and polled the segmented pool's committed bytes every 2 ms. It used two estimates of the activation term:

  • the MLX peak above pre-cell active bytes, minus the KV committed at the sample that saw the peak;
  • the largest sampled active-minus-KV.

The table shows the larger. No MTP drafter was attached.

Model (floor GiB) Prompt 512 / 2,048 (prod. stripe) 2,048 / 4,096 2,048 / 2,048
Gemma 4 26B QAT (5.5), default 8k 1.62 2.00 —
Gemma 4 26B QAT (5.5), default 32k 2.44 3.73 3.15
GPT-OSS 20B (3.5), opt-in 8k 2.37 2.49 —
GPT-OSS 20B (3.5), opt-in 32k 3.50 3.62 3.49
Qwen3.5-9B (5.5 default), opt-in 8k 4.04 4.07 —
Qwen3.5-9B (5.5 default), opt-in 32k 5.73 6.03 5.63
MoE Qwen3.5-35B-A3B (5.5 default), excluded 8k 2.85 4.72 —
MoE Qwen3.5-35B-A3B (5.5 default), excluded 32k 4.12 6.26 4.65

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:

  • Gemma 4 stays well inside its floor: 3.73 of 5.5 at 8 × 32k, leaving at least 1.77 GiB. It is the only family that widens by default.
  • GPT-OSS sat exactly at its 3.5 GiB floor at 8 × 32k under the previous geometry (3.50). The wide geometry would end 0.12 GiB above it.
  • Qwen3.5-9B was already 0.23 GiB above the 5.5 GiB default under its existing 4,096-token solo stripe; the wide geometry would add 0.3 GiB.
  • No existing margin absorbs that. UnifiedMemoryCap.liveKVHeadroomBytes grants 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.
  • The 4,096 budget, where a finishing prompt and its successor share a step, is what adds the increment over 2,048 / 2,048. A 2,048 budget was rejected for three reasons:
    • Beside decode rows every chunk would become 2,048 minus the decode tokens.
    • Dense Qwen range ends (under the opt-in) would then never land on the 256-token recurrent-checkpoint grid (CBv2RecurrentCheckpointGeometry.isRecurrentBoundary).
    • Contiguous GPT-OSS uniform-cap capture would disarm.

Gemma 4 media (paged, one 280-token image 768 tokens before the end, solo)

Prompt 512 / 2,048 2,048 / 4,096 without ceiling (pre-SDK-change build) This PR (ceiling 512)
8,192 chunk 512, 1.097 GiB chunk 2,048, 1.857 GiB chunk 512, 1.097 GiB
32,768 chunk 512, 2.124 GiB chunk 2,048, 3.967 GiB chunk 512, 2.124 GiB

Consumer audit

Consumer Finding Status
Paged pool sizing (makeSegmentedPagedBackend, maxPrefillChunk = max(chunk, stripe)) Gemma 4 stays at 2,048 (its chunk now equals the former stripe). GPT-OSS (2,048 stripe) and dense Qwen (4,096 stripe) are untouched. Windowed rings, segment/KV charges and load quotations are byte-identical. unchanged, tested
Windowed-ring write bound (PagedSequenceKV.write precondition) Per-row chunks stay ≤ 2,048; the 4,096 budget only lets two rows share a step. A block-bearing Gemma chunk is ≤ max(512, block). Gemma4Processor delimits every image and frame with boi/eoi, giving blocks of at most 1,120 tokens (280 in the catalog), and they never coalesce. Overrides that leave max(chunk, stripe) below 1,120 are raised to 1,120 (e19f138). Submit validation (CBv2MultimodalPlan.validate) bounds blocks only by the step budget; this is inference.md invariant 9. safe; override path guarded and tested
MoE expert GEMM rows (gather_qmm) A 4,096-token step on top-8 Gemma is 32,768 sorted rows. The pinned MLX row-tile backport (MLX core 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. safe
Prefill workspace / step-owned attention / grouped prefill (EngineV2.init, gatheredAttention) Only MiMo native paths size envelopes from the step budget, and MiMo keeps 512 / 2,048. unchanged
UnifiedMemoryCap activation reserve Gemma reaches 3.73 GiB of 5.5 at 8 × 32k. GPT-OSS and dense Qwen keep master's geometry, so their peaks are unchanged. Vision: Gemma media keeps 512 (probe). MTP rounds add ≤ 8 × (1+k) decode tokens per step, and the MTP-auto load arms exercised them end to end. covered for Gemma; GPT-OSS/Qwen not widened
Solo stripe arming (SchedulerV2.plan) Gemma's 2,048 stripe becomes a plain chunk with identical solo chunking. Lost: the stripe's one-time shrink-to-512 retry on KV reservation failure. That retry is inert on segmented paged, which reserves the full sequence at the first chunk. On contiguous KV, a 2,048 chunk may preempt or wait where 512 fit. Contiguous KV is the auto default for Gemma 4 artifacts other than the catalog's paged gemma-4-26b-qat-4bit, and applies whenever paging is disabled. The changelog states this (8a9d48a). Gemma soloStripeChunks counts drop to 0. GPT-OSS and dense Qwen stripes are unchanged. equivalent on paged; contiguous trade-off disclosed
mixedStepPrefillTokenCap (MixedPrefillPolicy) Still unset by default. Explicit caps (Gemma floor 128) still bound prompt work beside decode after chunk sizing. unchanged
Deadline projection (FirstTokenDeadlineAdmissionV2, prefillDeadlineProjectionSupported) Projection reads the same config and mirrors chunk, stripe and budget. Block-bearing rows are never projected (multimodalWork), so the media ceiling needs no mirror. Support still requires a partial cap of 1. consistent
Recurrent checkpoints / demanded ranges (CBv2RecurrentCheckpointGeometry, demandedCheckpointRange) No recurrent-checkpoint family widens by default: dense Qwen, Nemotron and Bonsai keep 512 and their stripes. Gemma paged historical capture is stride-based and chunk-independent. Under the opt-in, dense Qwen range ends beside decode rows move to every 2,048 tokens. preserved
Complete-checkpoint chunk validation (validateContiguousCheckpointChunk) Gemma's window becomes [2048, max(2048, stripe)]. Older manifests were already invalidated by build identity. consistent
Multimodal block validation / snapping (CBv2MultimodalPlan.validate, snappedChunkTokens) Blocks must fit the step budget: 4,096 by default, and never below 1,120 on Gemma 4, even under overrides (af702d9). Snap-over is unchanged, and the stripe never arms for block-bearing rows. unchanged; override path guarded
MTP budgets (stepTokens > maxBatchedTokensPerStep, CBv2MTPAllocationLimits) Decode-row widths never approach 4,096, and bounded drafter limits apply only to MiMo. EngineV2MTPProductionAdmissionTests (Gemma target, bounded test drafter) passed 8/8 on the native lane in the first round. unchanged
Serving / deadline profiles (ServingPerformanceProfiles, DeadlineRuntimeConfiguration) Both reviewed catalogs are empty. Deadline identity pins prefill_chunk_size and the stripe; the budget follows them when there is no override. Profiles pin the provider version, and any DARKBLOOM_CBV2_* override fails closed. invalidates cleanly
Hybrid prefix lookup (maximumChunkSize) max(chunk, stripe) is unchanged. unchanged
Benchmarks, fixtures and tooling Scheduler-prefill receipts (schema 5) record the geometry of the built engine and fail on a mismatch (872edea). scripts/gemma_contbatch accepts schema 5, and scripts/gptoss_profile summaries 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. updated
Step watchdog (30 s) Gemma's largest step doubles to 4,096 tokens at prompt boundaries; dense Qwen's 4,096 stripe already reached that size. Not measured on slow Macs at long context. limitation

Smaller Macs

There is no RAM gate:

  • The activation floors are the same constants on every Mac, and KV grants, rings and load quotations do not change.
  • Gemma's measured peak at 8 × 32k leaves 1.77 GiB of its floor, and a 16-24 GB Mac's KV budget cannot hold 8 × 32k anyway.
  • The 4,096-token steps involved already ran on every Mac through dense Qwen's solo stripe.
  • The non-NAX M3 Ultra improved in every measured Gemma cell.
  • The rollback keys apply per machine.

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

Interaction with #1534 and sibling branches

  • Keep Qwen streams decoding while a long prompt prefills #1534 (draft). It runs four decode-only steps between Qwen 3.5-family prompt chunks. By default the two PRs now affect different families: Keep Qwen streams decoding while a long prompt prefills #1534 changes Qwen and this PR changes Gemma 4.
    • They compose under the Qwen opt-in. With 2,048-token chunks the interleave costs four decode steps per 2,048 prompt tokens instead of per 512, and its decode-only steps reduce how many decode tokens wait behind a prompt chunk.
    • Keep Qwen streams decoding while a long prompt prefills #1534 now adds one constant and a Qwen branch at the end of productionSchedulerConfig, and no longer moves the SDK pin.
    • This round did not re-run merge-tree against it (its branch is not fetched locally).
  • Sibling branches. Merge order decides who resolves these ordering-only conflicts:
    • ttft/deadline-admission-estimators: docs/architecture/hardware-support.md, LaunchAgentRestartTests.swift
    • ttft/serving-stalls: LaunchAgentRestartTests.swift
    • ttft/startup-shape-warmup: docs/reports/README.md

Review follow-ups

Fixed in this round (all review threads answered and resolved):

Item Commit
Build fix: re-pin to SDK main f77b384c (#333 test fix) and adapt the provider to OpenAIToolCallDelta (type-only, byte-identical to #1549) e8dba33
Semantic conflict from the master merge: #1535's SchedulerPrefillPromptTests built schema-4 receipts without this PR's fields. The fixture now fills them, and a real schema-4 payload still decodes. 4402b3a
Codex P1, activation floors: the wide default is narrowed to Gemma 4 (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. 0f92cac
Codex P2, media block: Gemma 4 overrides below a whole media block are raised to 1,120. Covered by a geometry test and a real-engine test, both mutation-checked. e19f138
Codex P2, receipt: ProductionBuild.prefillGeometry comes from the built scheduler config; the benchmark records it and fails on a mismatch. 872edea
Codex P2, profile summaries: gptoss_profile summaries carry prefillChunkTokens and maxBatchedTokensPerStep. e541cbd
Codex P2, prefix-cache.md duplicate text: already fixed by c9b9707. The file now matches master, because no recurrent family widens by default. c9b9707, 0f92cac
Independent review cleanup: both Flint test helpers aligned to #1549, so only completed deltas count and the merge with #1549 is clean. f95ff5e
Codex P2 (on f95ff5e), step budget vs media block: a Gemma 4 step budget below 1,120 is raised to 1,120, so a stripe-covered block is no longer refused as spanTooLong. Covered by a geometry test and a real-engine test, both mutation-checked. af702d9
Codex P2 (on f95ff5e), override exceptions: inference.md and configuration.md name GLM5Next, Nemotron Super local serving and calibrated Nemotron as families whose policy replaces or caps the overrides. 8a9d48a
Codex P2 (on f95ff5e), changelog: the fragment now says solo prefill chunking is unchanged, and discloses the contiguous-KV loss of the stripe's shrink-to-512 retry. 8a9d48a

Follow-ups (deferred):

Validation

This round ran on the M3 Ultra, on the pushed tree with SDK f77b384c and master 8f6958689 merged. On f95ff5ee4, 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 head 8a9d48aec.

Check Outcome
swift build --build-tests -j 8 in provider-swift/ (staged test mlx.metallib via scripts/stage-test-metallib.sh), re-run after each change First build failed only on the merged SchedulerPrefillPromptTests.swift:95 (fixed in 4402b3a); every later build completed with no new warnings
swift test --skip-build --no-parallel --filter over the touched suites, with isolated DARKBLOOM_STATE_FILE / DARKBLOOM_LOADED_MODELS_FILE (the implementer's run) Pass: 340 tests in 33 suites plus 9 in 2. Suites: all 27 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.
Independent reviewer's run on the final tree (Flint, prefill geometry, scheduler-prefill, KV gate, LaunchAgent, parseStreamChunk, encodeToolCallsForHash, production wiring) Pass: 242 tests in 23 suites plus 9 in 2
Mutation check: Gemma media-block guard removed gemmaChunkOverrideCoversMediaBlock fails with 4 issues, one per raised case (256/0, 512/0, 1119/0, 256/600). gemmaUndersizedChunkHoldsMediaBlock crashes with PagedSequenceKV.swift:496: Precondition failed: windowed update of 300 tokens exceeds maxPrefillChunk 256. Source restored and rebuilt.
ProductionPromptParityTests, NemotronTemplateParityLiveTests (unpinned, PROMPT_PARITY_REQUIRED unset) Pass. The artifact-pinned CI lane needs CDN fixtures and was not run locally.
SDK at f77b384c: swift build --build-tests -j 8; run-nested-suite.sh MLXLMServerTests --no-parallel; run-nested-suite.sh BidirectionalMediaChunkCeiling --no-parallel Pass: 317 swift-testing tests in 47 suites plus 14 XCTest, 0 failures; ceiling suite 6 tests in 2 suites
python3 -m unittest discover -s gptoss_profile/tests Pass, 34 tests. With summary.py reverted, the new test fails with KeyError: 'prefillChunkTokens'.
scripts/docs-check.sh; DOCS_IMPACT_BASE=origin/master python3 scripts/docs-impact-check.py; python3 scripts/changelog.py check / preview 191 file(s) OK; coverage OK (37 changed files); 45 valid fragment(s), and the rewritten fragment renders
Follow-up push (af702d9, 8a9d48a): swift build --build-tests -j 8, then the focused run over EngineV2PrefillGeometry, SchedulerPrefill, EngineV2KVBackendGateTests, LaunchAgentEnvironmentTests, EngineV2ProductionWiring, FlintResponseFormat, FlintAnswerStop, parseStreamChunk and encodeToolCallsForHash Build complete. Pass: 244 tests in 23 suites (the 242 above plus the 2 new budget tests) plus 9 in 2
Mutation check: Gemma step-budget clamp removed gemmaStepBudgetOverrideCoversMediaBlock fails. gemmaUndersizedStepBudgetAdmitsMediaBlock catches .spanTooLong(blockTokens: 300, maxBatchedTokensPerStep: 256). Source restored, rebuilt, and the focused run re-passed.
Docs checks after the follow-up docs-check: 191 file(s) OK; docs-impact coverage OK (37 files); changelog: 45 valid fragment(s)
git merge-tree --write-tree against origin/master and #1549 (5deb03903) at 8a9d48aec Clean. Sibling conflicts are listed above.
git verify-commit on every new first-parent commit All 10 (44b1a3e through 8a9d48a) carry a Good ED25519 signature

First-round validation, on the M5 Ultra at SDK cef662176 and an older base:

  • The 32-selector focused run passed: 364 tests in 38 suites plus 5.
  • EngineV2MTPProductionAdmissionTests passed 8/8 (Gemma target, exclusive native GPU).
  • make benchmark-wrapper-test passed.
  • Mutation checks covered the ceiling assignment, the LaunchAgent keys, the decision runner pin and the SDK call sites.
  • MiMo fixture suites were gated.

Not run in either round:

  • the full make provider-test lane (CI runs it);
  • env-gated real-model live suites;
  • physical 16-24 GB Macs;
  • a load test of this exact branch build (the lead's arm A applied the same geometry through the environment);
  • a re-measurement on the final SDK pin (Follow-ups).

Interface and migration effects

  • New keys. DARKBLOOM_CBV2_PREFILL_CHUNK and DARKBLOOM_CBV2_STEP_TOKENS are documented in docs/reference/configuration.md and forwarded by LaunchAgent.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.bidirectionalMediaPrefillChunkCeiling defaults 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:

    • soloStripeChunks drops to 0.
    • prefillChunkTokensMax reaches 2,048 under decode company.
    • Deadline identities report prefill_chunk_size 2048.
    • Observed prefill rates rise under load.

    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. SchedulerPrefillBenchmarkReport schema 5 adds optional prefillChunkTokens and maxBatchedTokensPerStep. With soloPrefillStripeTokens, they now come from the production build's scheduler (ProductionBuild.prefillGeometry). A run whose measured engines disagree fails. This is documented in docs/provider/cli-reference.md.

Limitations

  • Inter-token tails. A decode token that shares a step with Gemma prompt work waits for a 2,048-token chunk, and p99 ITL was 2-3x higher in the engine cells. At 32k-token prompts a decoding stream gets ~1.5-2.6 tok/s while its neighbour prefills. Per-stream decode p50/p10 still rose in every load cell. Keep Qwen streams decoding while a long prompt prefills #1534's interleave is the complementary control.
  • Gemma 4 only by default. GPT-OSS and dense Qwen wait on the floor re-measurement (Follow-ups). MoE Qwen showed the largest activation increase. MoE Qwen, Qwen3-VL, Qwen4 and MiMo need their own measurements. Nemotron Lightning and Bonsai need a demanded-checkpoint split that does not depend on an armed stripe.
  • Untested Gemma variants. Other Gemma 4 sizes and the 8-bit variants inherit the geometry by family; the catalog serves only 26B-A4B artifacts.
  • Undersized overrides. A Gemma 4 chunk override below 1,120 (for example 256 with the stripe off) serves text in 1,120-token chunks rather than the requested size, and a step budget below 1,120 runs at 1,120. This is documented in configuration.md and inference.md invariant 9.
  • Contiguous Gemma 4 under KV pressure. A solo prompt whose 2,048-token chunk cannot reserve KV waits or is preempted instead of retrying at 512, as the former stripe did. This is in the changelog. Segmented paged KV is unaffected.
  • Ragged successors under the Qwen opt-in. Rarely, a finishing row's last chunk comes within the step's decode tokens of a full 2,048-token chunk. The successor admitted beside it then starts with a shorter first chunk, its later range ends miss the 256-token grid, and that dense Qwen donor usually leaves no recurrent checkpoint.
  • Probe conditions. Memory probes ran without MTP drafters, with eight rows and prompts up to 32k tokens, on one M5 Ultra, at SDK cef662176. Engine cells and probes shared the GPU, so timings are paired comparisons.
  • Pre-existing failures. Seen while validating the first round, and unrelated to this PR:
    • SDK CBv2PackedPrefillTests.testGemma4AdapterAdvertisesAndHonorsPackedPrefill fails identically on a clean SDK pin on the M5 Ultra.
    • MiMoV26NativeLoadTransactionTests reports fixtureRequired without MiMo fixtures.

Refactor pass

🤖 Generated with Claude Code


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

Gajesh2007 and others added 4 commits October 21, 2026 17:41
…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>
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project eigen-homepages-darkbloom with the following error:

Resource is limited - try again in 60 minutes (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project darkbloom-status with the following error:

Resource is limited - try again in 1 hour (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project d-inference-console-ui-dev with the following error:

Resource is limited - try again in 60 minutes (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project d-inference with the following error:

Resource is limited - try again in 60 minutes (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project d-inference-landing with the following error:

Resource is limited - try again in 60 minutes (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T21:57:23.695893Z 7806655 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 7806655a7c92 against base b02d39e5aac3.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Bedrock request allowance reached; no fallback around the limit

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: BEDROCK_CALL_LIMIT

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

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 22, 2026 9:53pm UTC
d-inference-console-ui-dev Ready Ready Preview Oct 22, 2026 9:53pm UTC
d-inference-landing Ready Ready Preview Oct 22, 2026 9:53pm UTC
darkbloom-status Ready Ready Preview Oct 22, 2026 9:53pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 22, 2026 9:53pm UTC

Request Review

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

Deployment failed for project darkbloom-status with the following error:

Resource is limited - try again in 60 minutes (more than 1800, code: "api-deployments-enterprise-per-hour").

Learn More: https://vercel.com/docs/limits#rate-limit-examples

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread docs/architecture/prefix-cache.md Resolved
Gajesh2007 and others added 2 commits October 21, 2026 18:08
Refresh for review: master gained GLM-5.3-Flash serving (#1516) and Flint
(#1535) and pins SDK main 889fe3cc, which already contains this change's SDK
side where it has one. Keep master's submodule pins and both sides of the
conflicting code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Gajesh2007 and others added 7 commits October 21, 2026 22:26
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>
@Gajesh2007 Gajesh2007 changed the title Raise CBv2 mixed-step prefill geometry for GPT-OSS, dense Qwen and Gemma 4 Raise CBv2 mixed-step prefill geometry for Gemma 4 Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread docs/architecture/inference.md Resolved
Comment thread changelog.d/mixed-step-prefill-chunk.md Resolved
Gajesh2007 and others added 2 commits October 22, 2026 01:38
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>
jonathan308
jonathan308 previously approved these changes Oct 22, 2026
Gajesh2007 and others added 2 commits October 22, 2026 14:44
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>
@Gajesh2007
Gajesh2007 merged commit b09a332 into master Oct 22, 2026
22 checks passed

This branch was successfully deployed

5 active deployments
Preview – d-inference-console-ui-dev — 7806655a Deployed Oct 22, 2026 by vercel[bot]
Preview – d-inference — 7806655a Deployed Oct 22, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 7806655a Deployed Oct 22, 2026 by vercel[bot]
Preview – d-inference-landing — 7806655a Deployed Oct 22, 2026 by vercel[bot]
Preview – darkbloom-status — 7806655a Deployed Oct 22, 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