Repository navigation
provider(ssd-cache): queue up to six SSD prefix-cache writes - #1584
Conversation
Both SSD prefix-cache write queues refused new donations as write_queue_full at two jobs, so busy providers dropped prefixes they could otherwise have reused. Raise SSDPrefixCachePolicy.writeQueueMaxJobs from 2 to 6 and make the complete-checkpoint store use it instead of literals: its writer gate admits six unsettled jobs, the one being written included, and its pipeline buffer is as deep as that gate, so the gate is the only queue refusal. Previously the one-job buffer could refuse a job the gate had admitted after the writer settled one job and before it took the next. The memory bounds are unchanged. Attention-block jobs must still fit the queued-byte cap (1,280 MiB at the default stage cap), and the job being written still leaves both counts. A queued complete checkpoint holds only donor state that stays charged to the engine admission ledger and I/O scratch reserved before queueing. Because the engine delivers a donor's terminal after its checkpoints settle, a write backlog now delays stream end by up to five earlier writes per checkpoint instead of dropping it. Tests: the attention cache queues six donations behind a blocked writer and settles the seventh as write_queue_full; at the production limits the queued-byte cap still refuses a job while a job slot is free; the fleet demand test now fills the six-job bound; and queued complete writes keep their host reservations, so the process ledger refuses before the job bound. The SSD KV cache reference documents both queues, with a changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refactor-pass follow-up to the six-job SSD write queue. The complete-checkpoint pipeline buffer is as deep as the writer gate so that a job the gate admits after the writer settles one job, but before it dequeues the next, is buffered rather than dropped. No test held that window open: the six-job fleet test still passes with a buffer one shallower than the gate. Add one that blocks the first job's completion callback, which runs after settle frees its writing entry, and checks that the sixth admitted job is buffered and written. Share the queued-donation helper that the six-job and host-ledger tests each defined locally as SSDHybridCheckpointTestFixture.startDonation, which the new test also uses. Name the gate and the window in the pipeline comment, and note in the policy comment and the changelog that a donor's stream end and KV release wait for all of its checkpoints, so up to six waiting donors (was two) can hold KV memory at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Threat model review — advisoryReviewed head Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (1 batches); openai/gpt-6.1-sol: not needed by escalation policy No actionable findings in the reviewed text. This is not a security approval. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Scan completed. Coverage: 59/59 source units; cross-file integration complete. 0 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: 16 request(s), 775997 uncached + 0 cache-read + 0 cache-write input / 12324 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. |
…features Queue up to six SSD prefix-cache writes (SSDPrefixCachePolicy. writeQueueMaxJobs = 6, was 2) for both writers: attention blocks (SSDWriteBehind) and complete checkpoints (SSDHybridCheckpointStore, whose gate and writer buffer now both use the constant). Approved head 78c904a. Owner decision: one shared write-queue depth for every model. #1589's GLM-only depth is folded into #1584's constant: - SSDHybridCheckpointStore+Write.swift (conflict): the prepareWriteJob gate is #1584's writing.count < writeQueueMaxJobs (six unsettled jobs, the one being written included), not #1589's per-store writing.count <= config.writeQueueJobs. - SSDHybridCheckpointStore.swift (conflict): #1590's stage-cost initializer, then #1584's comment and writer buffer (capacity: writeQueueMaxJobs). #1589's Config.writeQueueJobs is removed. - SSDHybridCheckpointStoreFactory.swift / SSDPrefixCachePolicy.swift: #1589's GLM override (glm5NextCompleteCheckpointWriteQueueJobs = 8, completeCheckpointWriteQueueJobs(backendLayout:)) and its MLXLMCommon import are removed. - docs/reference/ssd-kv-cache.md (conflict): #1584's attention and complete-checkpoint queue rows; #1589's GLM-only row is dropped. - changelog.d/glm-capture-under-load.md: the eight-deep GLM queue bullet is dropped (ssd-write-queue-six-jobs.md states the shared depth). - Tests: #1589's SSDCheckpointWriteQueueTests (GLM 8 / others 1 and a three-deep store) is removed; #1584's fleet-priority and writer-buffer tests cover the shared bound. The fixture loses #1589's writeQueueJobs parameter, and GLM5NextProtectedFactoryTests now checks that the GLM store's writer buffer is the shared writeQueueMaxJobs. #1589's capture-boundary partition and GLM adopters' ordinary chunking are unchanged.
Conflicts were the LanguageModel.prepare(state:prefill:) port that #1596 and this branch's a790a86 both made (formatted differently) and #1584's write-queue lines, which this branch already carries with its documented resolution. Kept this branch's side for the conflicting hunks; master's other hunks apply (MLXLLM.Gemma4 qualification, ThroughputSweep async throws, #1596's changelog fragment). libs/mlx-swift-lm moves to the final 0.10.2 SDK set aee6ebb6, which contains master's 476cb7c0 and the previous pin bc4e5f57 (library source identical). libs/mlx-swift eedca444 and libs/mlx ff4bb35b match master.
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 27 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362), #1594); Provider diagnostics: refusal reasons and load memory (#1592, #1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 12 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed.
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 27 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); OpenRouter compatibility: GLM-5.3-Flash and MiMo-V2.6-Flash requests no longer refused (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx-swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift-lm#362), #1594); Provider diagnostics: refusal reasons and load memory (#1592, #1603); MLX stack (#1596); Desktop release workflow (#1580). Apply 14 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed.
Set ProviderCore.version to 0.10.2 and render the v0.10.2 changelog entry from the 20 fragments added since v0.10.1, ordered by theme behind an upgrade and rollout section: Nemotron 3.5 Super prefix caching (#1586, #1588); GLM-5.3-Flash prefix caching (#1587, #1589, #1590); 4-bit SSD checkpoints and the SSD prefix cache on every model (#1592 (mlx-swift-lm#363), #1584, #1592); Logprobs on Nemotron 3.5 Super and GLM-5.3-Flash (#1564); GLM-5.3-Flash OpenRouter request controls (#1585, #1592); Speed: MTP and throughput (#1592 (mlx-swift-lm#360), #1593 (mlx- swift-lm#357), #1595 (mlx-swift-lm#359), #1594, #1595, #1598 (mlx-swift- lm#362), #1594); Provider diagnostics (#1592); MLX stack (#1596); Desktop release workflow (#1580). Apply 12 corrections reviewed against the code. #1580 is already in the v0.10.1 tag but merged after the 0.10.1 preparation, so its fragment is rendered here. Mark v0.10.1 as published on 2026-10-24. Record in the provider release runbook the SDK pin check, the enablement order (darkbloom-platform#464 before any catalog logprobs change, the GLM allowlist tuple, then both models' logprobs after the rollout and Super's tuple after a signed restart check), the platform evidence and the published history. No tag, registration, upload, deployment or enablement is performed. Co-authored-by: Jonathan Spangler <5055076+jonathan308@users.noreply.github.com>
Summary
The provider's two SSD prefix-cache writers each held only 2 donations before dropping new ones as
write_queue_full. The public cache status (GET /v1/cache/status, totals since the coordinator's last restart) showed 53,283write_queue_fulldrops against 141,723 donations written. Each drop is a prefix that a later request has to recompute instead of restoring.This raises the limit to 6 jobs (
SSDPrefixCachePolicy.writeQueueMaxJobs = 6, was 2) for both writers:SSDWriteBehind, built inSSDPrefixCache.init).SSDHybridCheckpointStore). Its literal2and its 1-slot writer buffer now both use the same constant.The byte caps and memory-ledger charges are unchanged.
Linked issue
None. The repository owner asked for this after reviewing production cache-routing telemetry.
Test plan
swift build --build-tests(provider-swift).--no-parallel):SSDHybridCheckpointStoreTests,SSDCheckpointFleetWritePriorityTests,SSDSharedProcessCheckpointTests,SSDPrefixCacheTests,SSDPrefixCacheDonationGateTestsandSSDPrefixCacheTelemetryTests. Result: 136 tests in 18 suites passed, 0 failures.../scripts/run-nested-suite.sh stageDelta --no-parallelalso passed.Tests/ProviderCoreTests/KVCacheSSD/(both passes): 385 tests in 68 suites passed, plus the runner-isolatedSSDShorterNativeBlockRestoreTests,SSDNativeCheckpointOracleTestsandstageDelta. One env-gated skip (realDonationHashPreparation()), the same as the baseline.master, all five regression tests fail.writeQueueMaxJobs - 1, onlybufferAcceptsJobAdmittedDuringSettlementfails, which is the window it targets.scripts/run-provider-tests.sh, first pass. Every failure came from MiMo fixtures being absent (unsetMIMO_*). With the documented MiMo fixtures prepared, those classes ran 111 tests with 0 failures. Everything else passed, including the exclusive GPU test.make docs-check(196 files OK).make docs-impact-check BASE=origin/master(11 changed files, coverage OK).make changelog-checkandmake changelog-preview.Components touched
Protocol / interface changes
Documentation impact
docs/reference/ssd-kv-cache.mdnow has one row per write queue, with its limit, its memory bound and the stream-end effect.Changelog
changelog.d/ssd-write-queue-six-jobs.mdfragment and ranmake changelog-check.Notes for reviewers
Memory bounds. The job count was never the only memory bound, so neither path's worst-case memory grows without limit.
max(writeQueueMaxBytes, maxStageBytes + writeQueueSlackBytes), which is 1,280 MiB at the default stage cap.host_memory_unavailable; a new test covers this.Writer buffer capacity changed from 1 to
writeQueueMaxJobs. A buffered job keeps itswritingentry, so a buffer as deep as theprepareWriteJobgate never drops a job that gate admitted. The old 1-slot buffer could drop an admitted job in one window: after the writer had settled one job but before it dequeued the next. The refactor pass confirmed the reasoning againstBoundedSingleConsumerPipeline: the consumer dequeues before it awaitsconsume, andsettleis the only remover. The post-submitwrite_queue_fullbranch is now a defensive fallback;closeAndQueuestill exercises it with a 1-slot test pipeline.Trade-offs, in order of how much they matter:
write_rate_limitedandwrite_priority_limitedmay appear sooner.Follow-ups to consider after rollout:
write_queue_fullfalls in production telemetry.Before And After
Behavior
flowchart LR subgraph Before A1["request finishes; its prefix is donated"] --> Q1{"fewer than 2 jobs waiting?"} Q1 -- yes --> W1["written to SSD, so a later request restores it"] Q1 -- no --> X1["dropped as write_queue_full, so a later request recomputes the prompt"] end subgraph After A2["request finishes; its prefix is donated"] --> Q2{"fewer than 6 jobs waiting? (attention jobs also need byte-cap room)"} Q2 -- yes --> W2["written to SSD, so a later request restores it"] Q2 -- no --> X2["dropped as write_queue_full"] W2 -. "complete-checkpoint donor" .-> L2["stream end and KV release wait for its checkpoints: up to 5 writes ahead instead of 1"] endCode
flowchart TB subgraph Before P1["SSDPrefixCachePolicy.writeQueueMaxJobs = 2"] --> WB1["SSDPrefixCache.init: SSDWriteBehind maxJobs = 2, byte cap 1,280 MiB"] G1["SSDHybridCheckpointStore+Write prepareWriteJob: literal 2-job gate"] --> B1["SSDHybridCheckpointStore.init: BoundedSingleConsumerPipeline capacity 1"] end subgraph After P2["SSDPrefixCachePolicy.writeQueueMaxJobs = 6"] --> WB2["SSDPrefixCache.init: SSDWriteBehind maxJobs = 6, byte cap unchanged"] P2 --> G2["prepareWriteJob: gate uses writeQueueMaxJobs"] P2 --> B2["SSDHybridCheckpointStore.init: pipeline capacity writeQueueMaxJobs"] endRefactor Pass
A dedicated, independent refactor reviewer read the first version (
657406eaf) and added one signed commit (78c904a42). No source logic changed.bufferAcceptsJobAdmittedDuringSettlement. It holds the settle-to-dequeue window open and fails with awriteQueueMaxJobs - 1buffer. No earlier test covered that window.SSDHybridCheckpointTestFixture.startDonation; every assertion is unchanged.SSDPrefixCacheTests.swift(two callers, inside its suite), the docs rows, and the changelog format.After the refactor commit, the final validation in the test plan was rerun on
78c904a42: build, focused suites, isolatedstageDelta, docs and changelog checks.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.