Skip to content

feat(provider): opt-in turn continuation prefills the next turn while the Mac is idle (off by default, stacked on #1954) - #1959

Draft
jonathan308 wants to merge 6 commits into
feat/turn-continuation-every-templatefrom
feat/turn-continuation-caller
Draft

jonathan308 wants to merge 6 commits into
feat/turn-continuation-every-templatefrom
feat/turn-continuation-caller

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Draft, stacked on #1954. Off by default. Don't merge. Head ad1126a7ad7b (refreshed 2026-11-14 onto the refreshed #1954 8b666d9a553e; previous head 9491f00111a5). The previous head 7b58ec236df9 ran over HTTP on Qwen3.5-9B on 2026-11-10. Its fix works: continuations now run on the shipped tier (the encrypted checkpoint store). The gain there is small. The same run found a defect: a continuation that has nothing to restore prefills the whole prompt, and its checkpoint write delays the next request by seconds. This head adds a guard that refuses such a continuation before any prefill. The guard passes its unit and toy-engine tests. It has not run on a real model, on a GPU or over HTTP.

Refresh, 2026-11-14 (head ad1126a7ad7b)

  • Freshness (read 2026-11-13 23:44 UTC, then 2026-11-14 01:18 and 02:13 UTC): dev moved three times during this refresh, from 65580bdc16b5 to de9b25ba5c66 (0.10.13 candidate (phase C: #2096 2088@001996379f 2100@2e241534b5 2098@d76366162a) into dev, for the DevNet build #2123) and then 58659fe3900f (0.10.13 candidate (phase D1) into dev, for the DevNet build #2134, the 0.10.13 candidate). Library DAR-327 Phase 3: instant provider reconnect (going_away) #396 is now 129acbcdc0b7, which merges library main f41a5f9af307; dev pins f41a5f9af307 itself. After these checks dev moved once more, to 6d61e2d08ace (0.10.13 candidate (phase D2) into dev, for the DevNet build #2136, read 04:18 UTC): 17 files, the same pins, and with this branch only "Last updated" doc lines in common; it merges without a conflict, so it is not merged in here.
  • Commits added (merges of the refreshed feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 branch, each SSH-signed, none forced):
    • ff11482b3a78: merge of 470c2e4f38c8.
    • a99f5bd996b3: merge of 6552890bd71f.
    • ad1126a7ad7b: merge of 8b666d9a553e.
  • Conflicts, all in the first merge, each resolved by keeping both sides:
    • EngineV2Bridge.init: dev's refusalProbe, nativePrefillEvidence, evidenceProbeOnACPower and terminalBeforeCheckpointPublication, then this PR's turnContinuationCells.
    • MultiModelBatchSchedulerEngine:
      • dev moved the withholdsGLMOutput declaration earlier in prepareCompletion, and the continuation block uses it there.
      • Each stream builder takes dev's rewriteHarmonyFinalHeaders, then turnContinuation.
      • On the engine's stop event, dev's token-limit note runs, then engineReportedStop is set.
      • The reply capture still sees what emit yields to the client.
    • IdleCalibrationCoordinatorTests: this PR's transfer test, then fix(provider): a request stops waiting for an idle calibration probe that never retires #1966's two tests and its admittedLease() helper.
    • One "Last updated" date.
  • fix(provider): a request stops waiting for an idle calibration probe that never retires #1966 renamed beginForeground() to admitForeground(). This PR's two test call sites now take the lease through admittedLease().
  • The second and third merges had no conflicts. In the code dev added since then:
    • EngineAdmissionPriority: a turn continuation keeps the library's own lowest priority, because submitContinuation builds its own request.
    • WholeMacServiceBudget overcommit and exclusive idle charges, and native reasoning budgets: these sit beside the continuation code.
  • Net diff against the refreshed feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954: 25 files, +1,697 / -24.
  • Checks on this head (Apple M3 Ultra; CPU builds; suites under this Mac's shared GPU lock as in the earlier runs):
    • Provider swift build --build-tests: passes.
    • Focused (TurnContinuation|TurnReplyCapture|EngineV2CanonicalGridTests|TemplateBoundaryRule): 55 tests in 10 suites passed.
    • Related: 249 tests in 20 suites passed.
    • Suites around the changed call sites (KVPoolSweepWiringTests|LocalPrefillProgressTests|UnboundedDeviceWorkTests|ModelCalibrationTests|ProviderCancelledPrefixCache|SSDHybridCheckpoint|SSDPrefixCache): 214 tests in 30 suites; 2 issues, both in the two cache-path tests that fail on this Mac in every run ("without the isolated root the cache root is the user caches folder" and "cacheDirectory lives under darkbloom/kv3, never under the legacy darkbloom/kv root"). They expect /darkbloom/kv3 under the user caches folder, which this session's home-folder layout does not give.
    • docs-impact-check 25 files OK; changelog.py check 2 fragments; git diff --check clean.
  • Untested interaction with fix(provider): a request stops waiting for an idle calibration probe that never retires #1966: a request now waits at most 30 s for the idle session it preempted to retire, and is then refused. A turn continuation is such a session. Its checkpoint write on the encrypted store held an arriving request for seconds in the HTTP run. No run has measured whether that wait can reach 30 s.
  • Not rerun on this head: the HTTP runs (they are on 594a944f0f69, 7b58ec236df9 and earlier) and the repository's two-reviewer quality gate.

Summary

#1954 adds an opt-in prefill grid, so a slot keeps state at fixed positions that a later prompt can reuse. A follow-up still has to prefill the reply it follows, because that reply was generated, not prefilled, and its end is not a kept position.

This PR adds the caller that fills that gap. With DARKBLOOM_CBV2_TURN_CONTINUATION=1 and the grid on, after a text reply ends the provider works out the tokens every next turn of that conversation must start with, and prefills them while the Mac is idle. The next request of the conversation then finds state past the reply.

  • It runs only while the Mac is idle. Any arriving request cancels it; the request then waits until the cancelled work has retired (see Costs). It stops by itself after 60 seconds.
  • The work is skipped, never queued, when a request, a pending submission or a calibration session holds the slot.
  • On the complete-checkpoint store it only extends what its turn left there. When the prefix tiers restore less than the last grid position of that turn's prompt, the hidden request is refused before any prefill.
  • The prediction is never a correctness input. The engine reuses state only where a later prompt's tokens match.
  • With the key unset nothing changes: no cells are built and no hook is attached.

What the HTTP runs showed (2026-11-10, Qwen3.5-9B, M3 Ultra 256 GB, one stream, grid 512):

  • Previous head 594a944f0f69, shipped tier. A continuation started on exactly the turns whose reply crossed a 512-token boundary: 13 of 54 turns per run. All 26 over two runs ended within 1 ms and prefilled nothing.
  • Cause. The continuation runs as the provider's idle session. Its hidden request restores from the store, the store reports that transfer as device work, and device work cancels the idle session. The continuation cancelled itself.
  • Fix in 7b58ec236df9. A prefix-store transfer no longer ends a continuation session. An arriving request, a model load, a cache clear and every other device activity still end it. A calibration session behaves as before.
  • Head 7b58ec236df9, shipped tier (two launches of one binary, caller on and caller off, 108 turns, 0 failures). 13 continuations started, on the same 13 turns. 4 completed after 2.3 to 2.9 s of idle work, the next request ended the other 9, and none ended itself.
    • Follow-up time to first token at 6 s pauses: median 1.120 s with the caller, 1.143 s without (n 20). The one follow-up that came after a completed continuation: 0.830 s against 1.368 s (1.64 times sooner, 512 more tokens reused). The other 17 paired follow-ups: 1.115 s against 1.117 s.
    • At 0.3 s pauses the next request ended 7 continuations 215 to 246 ms in, during their restore. Those requests were not delayed: 1.473 s against 1.494 s (n 6).
    • Defect found there. Where the turn's own request left no checkpoint (in the run: requests that do not send presence_penalty), the continuation prefilled the whole prompt from token 0 (10,753 and 11,777 tokens, about 12 s of GPU) and wrote 585 and 627 MB. The next request arrived during the write and waited for it. In one of the two cases it reached the first token 4.75 s later than with the caller off (13.469 s against 8.721 s). In the other it waited about 6 s, then restored what the continuation had written, and was sooner (6.976 s against 11.164 s).
  • Guard in this head 9491f00111a5. The hidden request is refused before any prefill when the store and the resident tier restore less than the last grid position its turn's prompt should have left. Both cases above are refused by that rule. So is the later reuse in the second case: where the turn's own requests write no checkpoint, no continuation starts and none writes one. Tested on the toy engine only (see Test plan); not run over HTTP.
  • Resident bank (two test-only switches, in no shipped build and not in this PR; measured on the previous head). A continuation started after every turn: 27 of 42 completed and the next request ended the other 15. Follow-ups reached the first token 1.37 times sooner at 6 s pauses (n 18) and 1.31 times sooner at 0.3 s pauses (n 9).

Before

flowchart LR
    A[Turn 1 prompt] --> B[Prefill, state kept on the grid]
    B --> C[Reply generated]
    C --> D[Mac idle]
    D --> E[Turn 2 arrives]
    E --> F[Restore the last grid position of turn 1]
    F --> G[Prefill the reply and the new message]:::bad
    classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1d
Loading

After

flowchart LR
    A[Turn 1 prompt] --> B[Prefill, state kept on the grid]
    B --> C[Reply generated]
    C --> D[Idle: prefill prompt + reply to the next kept position]:::good
    D --> E[Turn 2 arrives, cancels any work still running]
    E --> F[Restore a position past the reply]:::good
    F --> G[Prefill the new message only]:::good
    classDef good fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Code flow: MultiModelBatchSchedulerEngine.makeEventStream builds a TurnContinuationSource for a request the continuation may follow and feeds the stream's events to a TurnReplyCapture. After the terminal frame is sent and the model pin released, TurnContinuationSource.start renders the conversation twice with the reply appended and two different one-letter user messages, and keeps the tokens both renders share, less the last. EngineV2Bridge.continueTurn cuts that prefix at the last position the slot's tiers keep (TurnContinuationCells.plan, which also gives the restore floor: the last grid position the turn's own request should have left on the store), waits for the source request to retire, and starts a hidden one-token request through IdleCalibrationCoordinator.startIfIdle. It starts the session with toleratesPrefixStoreTransfers: true, so the request's own store restore and checkpoint write do not cancel it. Before submission EngineV2Bridge.submitTokenized compares the floor with what the prefix tiers restore for the request, and refuses it when they restore less: nothing is reserved or prefilled, and a staged checkpoint is given back unconsumed. Otherwise the bridge hands the request to EngineV2.submitContinuation, which admits it only while the engine has no other stream.

Linked issue

None.

Test plan

  • Build, local, CPU: swift build --build-tests --package-path provider-swift on the head's tree. Build complete.

  • Focused suites, CPU, isolated state files: swift test --package-path provider-swift --skip-build --no-parallel --filter 'TurnContinuation|TurnReplyCapture|EngineV2CanonicalGridTests|TemplateBoundaryRule': 55 tests in 10 suites pass. 42 of them are new, in six suites:

    • Turn continuation cells (12): where the prefix is cut for a slot with the resident bank and for a slot with only the complete-checkpoint store; skipped when the turn already reached that position; a prediction that leaves the prompt early is dropped; no grid, no continuation; the store plan carries the last position its turn left, and the bank plan asks nothing of the store.
    • Turn continuation reply capture (7): the reply is the content a client keeps, without reasoning, for streamed, complete and native-channel replies; a tool call or an empty answer gives none.
    • Turn continuation source (4): the shared prefix stops before the token that can merge with the user's text; a failed render submits nothing. These use an injected launch, so they do not depend on timing.
    • Turn continuation stream hook (11): one start after the pin release for a reply the engine stopped; none for a tool call, a token-limit cut, a stop sequence, a missing or error terminal, an empty reply, or no source.
    • Turn continuation on a bridge (5, one test with two cases): a real EngineV2 with a two-layer toy hybrid model (random weights, 128-token grid, resident bank). See the next bullet.
    • Turn continuation on the complete-checkpoint store (3): the same toy engine on paged storage with the encrypted checkpoint store as its only prefix tier (256-token grid). See the bullet after next.
  • Bridge test, what it shows. On the toy engine: a build derives the cells from its grid and tier, and the key gates them; a continuation prefills the next kept position and the follow-up restores it, where the same turns in a second cache scope with no continuation do not; a continuation is skipped while a request holds the slot or when nothing new is left to keep; a request that arrives during a continuation gets the same reply as the same turns with no continuation and as a cold request, and the serving counters count the arrival alone. The arrival is pinned at two points only: right after the continuation is scheduled, and once the engine has admitted it. Other interleavings are not pinned.

  • Store test, what it shows. A 513-token turn leaves a checkpoint at 512. The continuation for a 900-token shared prefix restores it (512 tokens consumed from the store), writes the checkpoint at 768 and completes, with no canceller recorded. The follow-up restores 768. With the fix's call-site argument removed the same test fails (6 expectations): the log line reads ended, 769 tokens after a 513-token prompt in 0 ms, session cancelled by device work, nothing is restored or written, and the follow-up restores 512. That is the HTTP result on the toy engine. The store refuses writes on a volume under its low-disk floor, so this test needs DARKBLOOM_SSD_TEST_TMPDIR on a volume with free space when the default temp volume is nearly full (it was here).

  • Guard tests, what they show. Same toy engine and store. (1) On an empty store the continuation for a 513-token turn is refused: the engine admits nothing, no file is written, nothing is consumed and no canceller is recorded. After the turn's own request has left position 512, the same continuation runs and writes 768. (2) The store holds 512 and a 769-token turn should have left 768: the continuation is refused, the checkpoint it read is given back unconsumed, nothing is written, and the next request still restores 512. With the comparison replaced by restored < 0, the focused suites fail with 7 recorded issues, all in these two tests: the refused request is admitted and its checkpoints are written. With the guard back they pass again.

  • Related suites, same build (the feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 list plus IdleCalibration and ModelCalibrationPolicy): 235 tests in 20 suites pass. One is new: a prefix-store transfer ends a session unless the session tolerates it.

  • Suites around the changed call sites, previous head 7b58ec236df9, not rerun on this head (KVPoolSweepWiringTests|LocalPrefillProgressTests|UnboundedDeviceWorkTests|ModelCalibrationTests|ProviderCancelledPrefixCache|SSDHybridCheckpoint|SSDPrefixCache): 212 tests in 30 suites, 210 pass, 2 fail. The 2 assert the cache folder's path (SSDPrefixCacheFactoryTests.swift:103, SSDPrefixCacheTests.swift:2771: it must end darkbloom/kv3). The shell these ran in is a dev-channel sandbox whose folder is darkbloom-dev/kv3. This PR does not touch that path. The two were not rerun on the base head.

  • Skipped by their own gates (they need local model weights or a GPU profile): suite GLM5NextProtectedFactoryTests, and 11 tests: defaultServingSelectsPagedKVAndCompletePrefix, disabledSSDStillUsesOriginalProtectedProfile, glmNativeFenceFailureKeepsNewcomerAndShrunkSurvivor, malformedDecodeStepsRefuseTheBackend, managedSlotBindsEncryptedStoreAndRestoresPrefix(precision:), pinnedCheckpointIsDiscoveredWithItsRecordedLoadCharges, pinnedMetadataIsDiscoveredAsAnImageModel, prefixOptOutAndPagedVetoesNeverFallBackToContiguous, preparedFactoryRejectsForeignStoreAndTuple, rectangularVerifyRollbackReachesTheProviderJob, residentOptInKeepsCompletePrefixInsteadOfRefusing.

  • Repo checks: ./scripts/docs-check.sh (211 files OK); python3 scripts/docs-impact-check.py --base upstream/dev (35 changed files, coverage OK); python3 scripts/changelog.py check (69 valid fragments); git diff --check clean.

  • GPU, HTTP, previous head 594a944f0f69 (before the fix). darkbloom start --local --here --no-auth --model Qwen3.5-9B, paged KV, grid 512, M3 Ultra 256 GB, macOS 27.2. Sessions of 6 turns, prompts 8,297 to 11,900 tokens, temperature 0, streaming, thinking off, presence_penalty: 0. Seven launches, 318 turns, 0 failures.

    Follow-up time to first token, median 6 s pauses (n 20) 0.3 s pauses (n 15) Continuations
    Encrypted store, caller off 1.139 s 1.390 s none
    Encrypted store, caller on 1.139 s 1.391 s 13 per run, all ended within 1 ms
    Resident bank, caller off (test-only switches) 0.768 s 0.734 s none
    Resident bank, caller on (test-only switches) 0.560 s 0.609 s 42: 27 completed, 15 ended by the next request

    Paired by turn on the bank, caller off / caller on: 1.370 (p10 1.276, p90 1.446, n 18) at 6 s pauses; 1.313 (p10 1.077, n 9) at 0.3 s pauses. A continuation's log line reports a median 232 ms (179 to 290, n 42).

  • GPU, HTTP, previous head 7b58ec236df9 (before the guard). The same server command, sessions and seeds as the item above; encrypted store with a 40 GB cap on an external volume; one binary (sha256 4b16548cb942…) for both launches. Launch 1 caller on, launch 2 caller off: 54 turns each, 0 failures. Built without fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961.

    Part (caller on / caller off) Follow-up time to first token, median Continuations with the caller on Replies equal, on vs off
    6 s pauses, presence_penalty: 0, 4 sessions 1.120 s / 1.143 s (n 20) 2 started, 2 completed (2,282 and 2,895 ms) 19 of 21
    0.3 s pauses, presence_penalty: 0, 3 sessions 1.365 s / 1.420 s (n 15) 8 started: 7 ended by the next request after 215 to 246 ms, 1 completed (2,476 ms) 18 of 18
    4 s pauses, presence_penalty not sent, 2 sessions per turn below 3 started: 2 ended by the next request after 18.9 and 19.2 s, 1 completed (2,446 ms) 12 of 12
    • No continuation ended itself. On the previous head all 26 did.
    • The one follow-up after a completed continuation (6 s pauses): 0.830 s against 1.368 s, 11,264 tokens reused against 10,752. The 17 other paired follow-ups: 1.115 s against 1.117 s.
    • The 6 paired follow-ups that arrived during a continuation's restore (0.3 s pauses): 1.473 s against 1.494 s.
    • Penalty not sent, time to first token per turn in seconds, caller on / caller off. Session 0: 8.156 / 8.310, 8.943 / 9.043, 9.414 / 9.683, 10.094 / 10.376, 10.841 / 11.057, 11.666 / 11.886. Session 1: 13.469 / 8.721, 9.208 / 9.397, 9.867 / 10.082, 10.371 / 10.560, 6.976 / 11.164, 0.996 / 12.037. The first turn of session 1 waited behind the write of the continuation that followed session 0 (627 MB). The last two turns of session 1 restored checkpoints that continuations had written (10,752 and 11,264 tokens; the caller-off launch reused 0).
    • Caller off, this build against the previous head's build: ratio of time to first token 0.995 to 1.008.
    • The two replies that differ at 6 s pauses start in the caller-off launch; the caller-on launch equals the previous head's caller-on launch on 24 of 24. See "Replies".
  • Not run: this head's guard on a real model, on a GPU or over HTTP; the full provider suite; a request that arrives while a warm continuation writes its one checkpoint file; the write wait on the internal SSD (the store was on an external volume, about 87 MB/s); the idle GPU time spent; any other model, grid size or prompt size; more than one stream; a bitwise check of a request that arrives during a continuation or restores a continuation's checkpoint; anything on a build with fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961.

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

Documentation impact

  • docs/architecture/inference.md (new section "Turn continuation"), docs/architecture/hardware-support.md, docs/architecture/prefix-cache.md (store transfers and idle sessions), docs/reference/configuration.md (one row), docs/provider/cli-reference.md (one row).

Changelog

  • changelog.d/turn-continuation-prefills-the-next-turn.md; python3 scripts/changelog.py check passes.

Notes for reviewers

  • Off by default. EngineV2Config.makeBridge passes the cells only when the key is exactly 1. With no cells the scheduler builds no source and no capture, and the stream forwarder is the one feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 has.
  • Which replies start one. A serving request with the prefix cache on, an engine-reported stop, non-empty content and no tool call. None for: a token-limit cut, a matched stop sequence, a cancelled request, a response format or JSON answer, withheld GLM output, a native consumer lease, media, a GLM5Next slot with a native owner, or a slot whose only prefix tier is resident KV pages.
  • Where it helps in production today. A paged model has the complete-checkpoint store and no resident recurrent bank. There the continuation has work only when the reply crosses a grid multiple: 13 of 54 turns in the HTTP run. A continuation that is cancelled before its prefill ends, or times out, keeps nothing, because that store takes nothing from a cancelled request. Measured on 7b58ec236df9: the one follow-up after a completed continuation restored one more 512-token block and reached the first token 1.64 times sooner (0.830 s against 1.368 s); the median follow-up did not move (1.120 s against 1.143 s). The larger gain (1.3 to 1.4 times sooner to the first token) needs a resident bank on paged storage, which no shipped build enables.
  • One more way a continuation is skipped. It starts only while the service budget is idle. A store transfer still in flight at that moment (the source request's checkpoint write, say) makes it skip, not wait. In the HTTP run all 13 crossing turns per run did start one.
  • Qwen 3.5 / 3.6 card builds, [superseded by #1961] fix(provider): no default presence penalty on Qwen 3.5/3.6 #1946 and fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961. On Qwen3.5-9B, qwen3.5-35b-a3b and qwen3.6-35b-a3b-vl-mtp-mxfp8 a request that omits presence_penalty gets 1.5, runs no MTP and writes no prefix checkpoint. Measured on feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954's binary over HTTP on 2026-11-10: 180 of 180 follow-ups without the field reused 0 tokens. fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961 (draft, base dev, not in this stack; it supersedes [superseded by #1961] fix(provider): no default presence penalty on Qwen 3.5/3.6 #1946) removes that default on Qwen3.5-9B; by its title the two 35B builds keep 1.5. The hidden request here does not get the default: the bridge submits it through EngineV2.submitContinuation, which replaces its sampling with temperature 0 and no penalty. So on these builds the hidden request writes checkpoints where the turn's own request wrote none, after a full cold prefill. The HTTP run of 7b58ec236df9 measured that. On this head the guard refuses that hidden request, so on these builds a turn without the field starts no continuation. Nothing here ran on a build with fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961.
  • Costs.
    • A request that arrives during a continuation waits for the continuation's session to retire, and the session retires only after the hidden request's checkpoint write. Nothing bounds that wait. The guard below removes the cold case; the wait behind a warm continuation's write remains. Cancelling the hidden request does not stop its store write. Measured on the store tier: an arrival during a continuation's restore was not delayed (1.473 s against 1.494 s, n 6). An arrival during the write of a cold continuation (585 and 627 MB, 2 samples) waited about 4.8 and 6.1 s; one reached the first token 4.75 s later than with the caller off. A warm continuation writes one file (72.6 MB here); an arrival during that write was not sampled. The store was on an external volume that wrote about 87 MB/s; the internal SSD was not measured. On the resident bank (previous head) the next request ended 15 of 18 continuations at 0.3 s pauses, and on the pairs where it arrived mid-continuation it was still sooner to the first token than with the caller off (1.325, n 8).
    • The guard, and its limits. On 7b58ec236df9, when the turn's own request left no checkpoint, the hidden request prefilled the whole prompt: about 12 s of GPU for 11,000 tokens on this Mac, and a full set of checkpoint files. This head refuses the hidden request before any prefill unless the store or the resident tier restores at least the last grid position the turn's prompt should have left. What that leaves:
      • Where a model's default requests write no checkpoint, no continuation starts. The later reuse that the HTTP run saw after a cold continuation (6.976 s against 11.164 s, 0.996 s against 12.037 s) is given up there. mlx-swift-lm#398 (merged to library main at 17:45Z today, not in this pin) lets a cached request that cannot speculate, such as one under the card's default presence penalty, save prefix checkpoints. By reading, that removes the cause on these builds, and their continuations would start again. Not built or tested here.
      • The store keeps no position below its minimum (1,024 tokens by default), so a turn whose last grid position is below it starts none: 513 to 1,024 tokens at grid 512.
      • A turn shorter than one grid cell has floor 0. Its hidden request may still prefill from token 0, less than one cell plus the reply.
      • The floor can be met by a checkpoint an earlier turn left at that position; the rule does not ask who wrote it.
      • A refused continuation that found an older, shorter checkpoint has read it once before giving it back.
      • Not run on a real model or over HTTP: the two cold cases of the HTTP run were not repeated on this head.
    • The hidden request is not subject to the coordinator's novel-write gate (by reading). It carries no repeat hint, and the store admits a write when the hint is absent. Not measured: the local endpoint sends no hint.
    • Idle GPU time is spent after each eligible reply, whether or not a follow-up comes, up to 60 s per reply.
    • Two extra template renders per eligible reply, off the request path at utility priority.
    • The reply is rebuilt from stream events with the default reasoning split. A client that sends the reply back changed, sends reasoning_content back, or changes an earlier message gets no reuse.
    • The key is a DARKBLOOM_CBV2_* key: it enters the complete-checkpoint numerics fingerprint and turns off the reviewed serving and deadline profiles.
    • The grid's own costs from feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 apply: slower cold prefill (about 13 % over HTTP on Qwen3.5-9B at 10,000 tokens) and temperature-0 replies that differ from today's on some prompts (42 of 72 equal in that run).
  • Replies. Head 7b58ec236df9, store tier, caller on vs caller off: equal on 19 of 21 turns at 6 s pauses, 18 of 18 at 0.3 s and 12 of 12 with the penalty not sent. The two that differ start in the caller-off launch; the caller-on launch equals the previous head's caller-on launch on 24 of 24 and 18 of 18. On the bank (previous head), caller on vs caller off gave equal replies on 21 of 22 turns at 6 s pauses and 10 of 12 at 0.3 s. The same setting run twice also differs: on the store tier with the caller off, 21 of 22 and 15 of 16 were equal. Two turns (session 2 turn 3, and in that head's run session 0 turn 4) vary between identical launches at temperature 0, with and without the caller. That variation is not explained; it appears with reuse and MTP active and was not seen in feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954's HTTP run without them. One reply differed only in the launch where its request arrived during a continuation (one sample, on the bank). All of this compares reply text. A bitwise check of a request that arrives during a continuation, and of one that restores a continuation's checkpoint, is owed before this is turned on anywhere.
  • Security. No change to encryption, attestation, signing or transport. The hidden request reads and writes the prefix tiers under the cache scope of the request it follows and no other. It carries no seed, so its engine ID is random and a client cannot mint it. Its one log line has the model ID, the outcome, two token counts and a duration: no token IDs, no text. When the session was cancelled the line also names the canceller (a fixed label such as device work). The hidden request is left out of the prefix-cache savings counter and the reuse telemetry, and calibration takes no measurement from it.
  • Freshness (checked 2026-11-10 18:26Z): base branch feat/turn-continuation-every-template at 1a2a346a8dd1 (feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 head); dev at 2474f3dcce8c; library pin unchanged from feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954 (6db4a4001f, mlx-swift-lm#396). Library main moved to ef028fbe41f3 at 17:45Z (mlx-swift-lm#398, see Costs). The pinned branch does not have it. A trial merge of the pinned branch with that main has no conflict; the merged library was not built or tested, and no measurement here includes it. fix(provider): Qwen3.5-9B: no default presence penalty and exact MTP acceptance; the 35B Qwen builds keep 1.5 #1961 at ca8697d851c5 (draft): a trial merge of it with this head has no conflict; the merged tree was not built or tested. Recorded exception carried from feat(provider): 0.10.12 — an opt-in prefill grid that reads message boundaries from each chat template (off by default) #1954: the pin is the library PR branch, to be moved to main once DAR-327 Phase 3: instant provider reconnect (going_away) #396 merges; that branch is behind library main by stats: leaderboard earnings lack context (rolling window + early-ramp vs calculator) #367 and Detect boot policy in doctor #398.
  • Door: two-way. Blast radius: none with the key unset; with it set, one provider's idle time and the slots that have a grid.

Refactor Pass

Verdict: reviewed once by a second pass; eight findings applied, one left. The first HTTP run then found one more defect, fixed in 7b58ec236df9. The HTTP run of that head found another; this head adds a guard for it, tested on the toy engine only.

Applied:

  • A reply ended by a matched stop sequence started a continuation. It now starts none.

  • The log line said completed after a cancel. It now says completed only when the engine prefilled every token.

  • A cancelled continuation was described as keeping its work. The comment, doc and changelog now say the complete-checkpoint store keeps nothing from it.

  • The hidden request entered the prefix-cache savings counter and reuse telemetry. It is now left out of both.

  • The hidden request carried seed: 42, which gave it an engine ID a client's request could mint again. Removed.

  • The unit tests depended on timing and never reached the bridge. They now use an injected launch, and a bridge-level test on a real engine was added.

  • The changelog's condition for "starts none" was too narrow. Reworded.

  • The wait an arrival sees had no stated bound. The doc now says so under Costs.

  • Found by the first HTTP run: a continuation's own store restore ended its idle session, so on the store tier it never ran. A prefix-store transfer no longer ends a continuation session; a test on the store tier pins it.

  • Found by the HTTP run of 7b58ec236df9: a continuation that has nothing to restore prefilled the whole prompt, and the next request waited for its checkpoint write. The hidden request is now refused before any prefill when the prefix tiers restore less than its turn left; two tests on the store tier pin it and fail without the comparison.

Open:

  • The guard has not run on a real model or over HTTP.
  • A request that arrives while a warm continuation writes its one checkpoint file still waits for that write, with no bound (see Costs). Not sampled.
  • The hidden request is not subject to the coordinator's novel-write gate (see Costs).

Considered and left:

  • Skipping the start when the forwarding task is already cancelled (!Task.isCancelled in the hook). The stream's termination handler cancels that task on every normal end, so the check would drop ordinary continuations at random.

AI usage: written by Claude Fable 5 (Claude Code) at the owner's request. The 2026-11-14 refresh (the merges, their checks and the refresh section) was done by Claude Opus 5.5 (Claude Code). Not for merge until reviewed.

🤖 Generated with Claude Code

… the Mac is idle

With the prefill grid on, DARKBLOOM_CBV2_TURN_CONTINUATION=1 lets a slot
prefill the tokens every next turn of a conversation starts with, after a
text reply ends and only while the Mac is idle. Off by default.

- The stream forwarder rebuilds the reply a client keeps, renders the
  conversation twice with that reply and two different user messages, and
  keeps the tokens both renders share.
- The bridge cuts that prefix at the last position the slot's prefix tiers
  keep and submits a hidden one-token request through the idle-calibration
  coordinator. It is skipped, never queued; any arrival cancels it; it
  stops after 60 seconds.
- The hidden request uses the cache scope of the request it follows. It
  has no seed, logs counts and a duration only, and is left out of the
  prefix-cache savings counter, reuse telemetry and calibration.
- No continuation after a tool call, a token-limit cut, a matched stop
  sequence, a cancelled request, a response format, media, or on a slot
  without a grid and a resident bank or complete-checkpoint store.

Tests: 37 new unit tests, including a bridge-level test on a real engine
with a toy model. No run on a real model, a GPU or over HTTP yet.

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

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

Request Review

… prefix-store transfer

Measured over HTTP on Qwen3.5-9B at 594a944: on a slot whose prefix tier
is the encrypted complete-checkpoint store, 26 of 26 continuations ended
within 1 ms and prefilled nothing.

Cause: the continuation runs as the idle session of
IdleCalibrationCoordinator. Its hidden request restores from the store,
the store begins a WholeMacUnboundedActivity for that transfer, and
beginning one cancelled the idle session, which was the continuation.

- IdleCalibrationCoordinator.startIfIdle takes
  toleratesPrefixStoreTransfers, and cancel(prefixStoreTransfer:) leaves
  such a session running. The default is unchanged: a calibration session
  still ends on a store transfer.
- WholeMacServiceBudget.beginUnboundedActivity(prefixStoreTransfer:)
  passes the mark on. The activity still counts against the idle gate and
  still invalidates calibration evidence.
- The checkpoint store's restore staging and checkpoint write, and the
  SSD prefix cache's donate and stage, begin their activity as store
  transfers. Every other caller is unchanged.
- The continuation's log line names what cancelled an ended session.

Tests: one coordinator test, and a bridge test on a real engine with a
toy model, a paged backend and the encrypted store on the bridge's
budget. The continuation restores 512 tokens, prefills to 768, writes
that checkpoint and completes; the follow-up restores 768. Without the
call-site argument the same test fails: the continuation ends in 0 ms,
cancelled by device work. The fixed caller has not been run over HTTP on
a real model yet.

Docs: inference.md, hardware-support.md and prefix-cache.md state the
rule.

Co-Authored-By: Claude <noreply@anthropic.com>
…old less than its turn left

Measured over HTTP on Qwen3.5-9B at 7b58ec2: where the turn's own
request wrote no checkpoint (requests that did not send presence_penalty),
the hidden request prefilled the whole prompt from token 0 (10,753 and
11,777 tokens, about 12 s of GPU) and wrote 585 and 627 MB. A request
that arrived during the write waited for it; one reached its first token
4.75 s later than with the caller off (13.469 s against 8.721 s).

- TurnContinuationCells.plan replaces continuationTokens and returns a
  TurnContinuationPlan: the tokens, and restoreFloor, the last grid
  multiple the turn's own request should have left on the
  complete-checkpoint store. The floor is 0 on a slot with the resident
  bank.
- The hidden request's calibration cell carries the floor. Before
  submission, EngineV2Bridge.submitTokenized compares it with what the
  prefix tiers restore for the request (the longer of the store's staged
  checkpoint and the resident tier's match). When they restore less, the
  request is refused before any memory reservation or prefill, a staged
  checkpoint is given back unconsumed, and the log line says "skipped"
  with the two counts.

Limits: where a model's default request writes no checkpoint, no
continuation starts. A turn whose last grid multiple is below the store's
minimum checkpoint (1,024 tokens by default) starts none. A turn shorter
than one grid cell has floor 0 and may still prefill from token 0, less
than one cell. A refused continuation that found an older, shorter
checkpoint has read it once. The wait behind a warm continuation's one
checkpoint write, and the hidden request's bypass of the novel-write
gate, are unchanged.

Tests: two cell tests for the floor and two bridge tests on a real
engine with a toy model, a paged backend and the encrypted store: a
continuation on an empty store is refused and writes nothing, then runs
once its turn has left a checkpoint; a continuation whose turn should
have left 768 is refused when the store holds only 512, and the next
request still restores 512. Focused suites: 55 tests in 10 suites pass.
Related suites: 235 tests in 20 suites pass. With the comparison
replaced by "restored < 0" the two bridge tests fail with 7 recorded
issues (the refused request is admitted and writes its checkpoints);
with the guard back the focused suites pass again. Not run on a GPU
model or over HTTP.

Docs: inference.md, hardware-support.md, prefix-cache.md,
configuration.md and the changelog fragment state the rule.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 and others added 3 commits November 13, 2026 15:58
Brings in feat/turn-continuation-every-template at 470c2e4, which
merges dev 65580bd and pins mlx-swift-lm at f86ac6731042.
Conflicts, each resolved by keeping both sides:

- EngineV2Bridge.init: dev's refusalProbe, nativePrefillEvidence,
  evidenceProbeOnACPower and terminalBeforeCheckpointPublication, then
  this branch's turnContinuationCells.
- MultiModelBatchSchedulerEngine: dev moved the withholdsGLMOutput
  declaration earlier in prepareCompletion, so the continuation block
  keeps using it there. Each stream builder takes dev's
  rewriteHarmonyFinalHeaders, then turnContinuation. On the engine's
  stop event, dev's token-limit note runs, then engineReportedStop is set.
- IdleCalibrationCoordinatorTests: this branch's transfer test, then
  dev's two tests and its admittedLease() helper. #1966 renamed
  beginForeground() to admitForeground(), so this test and
  TurnContinuationBridgeTests take the lease through admittedLease().
- docs/architecture/hardware-support.md: the later "Last updated" date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in feat/turn-continuation-every-template at 6552890: the
mlx-swift-lm pin 129acbcdc0b7 (library main f41a5f9af307 merged in) and
dev de9b25b (#2123, the 0.10.13 candidate). No conflict. dev's new
EngineAdmissionPriority is set on ordinary bridge submissions; a turn
continuation still runs at the library's own lowest priority, because
EngineV2.submitContinuation builds its request with priority Int.min / 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in feat/turn-continuation-every-template at 8b666d9: dev
58659fe (#2134) and the mlx-swift-lm pin 129acbcdc0b7. No conflict.
dev's reservation changes in WholeMacServiceBudget (overcommit, exclusive
idle charges), native reasoning budgets in the bridge submission and the
MiMo route, and the bridge event task's admission priority sit beside this
branch's continuation code without touching it.

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

This branch was successfully deployed

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