Repository navigation
perf(glm): capture GLM prefix checkpoints beside decoding requests - #1589
Closed
jonathan308 wants to merge 4 commits into
Closed
jonathan308 wants to merge 4 commits into
jonathan308 wants to merge 4 commits into
Conversation
GLM-5.3-Flash captures a complete checkpoint only at a prefill range end on the 256-token grid, and its prefill chunk shares one 2,048-token step budget with the decode rows of other requests. Beside a decoding request every range was 2,044-2,047 tokens, so a donor served with company captured nothing, with no counter: one of six donors in the qualification burst was cached. Bump libs/mlx-swift-lm 184b5a93 -> 2231b8fc (Layr-Labs/mlx-swift-lm#355): an opt-in scheduler partition ends a cacheable donor's range on its demanded boundaries (fork target, deepest aligned boundary below the prompt end), and GLM adopters resume under ordinary chunking instead of waiting for a donor-sized chunk and cold-restarting after three waits. The protected GLM engine with its GLM store enables the partition at the store floor (EngineV2Factory.demandedCaptureBoundaryMinimumTokens). With every donor capturing, donors that finish together overflowed the store's single write slot: on an M5 Ultra two donors finishing in the same millisecond lost both of one donor's files as write_queue_full. A GLM store now holds eight donations behind its writer (SSDPrefixCachePolicy.completeCheckpointWriteQueueJobs, set through SSDHybridCheckpointStore.Config.writeQueueJobs); other layouts keep one. A queued donation pins only its donor's pages and KDA copies, which stay charged to the admission ledger until the write settles. M5 Ultra #1, real weights: six concurrent 8k donors 6/6 captured and written (was 1/6); a 32,682-token prompt publishes 32,512 instead of 30,720 (hit TTFT 3.1-3.7 s, was 3.96 s); a hit beside two decoding requests restores with no preemption. Tests: SSDCheckpointWriteQueueTests (depth by layout; four donations queue behind a blocked writer and a fifth settles write_queue_full), the partition stays GLM-only (Nemotron policy suite), and the GLM protected factory asserts the partition floor and the queue depth.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
7 of 11 tasks
The two donors whose finishing lost both of one donor's files to the single write slot finished within 27 ms of each other, not in the same millisecond (M5 Ultra burst, harness wire log).
The GLM capture paragraph of prefix-cache.md named two SDK files by bare file name, which docs-check cannot verify. Cite them by repository path with their symbols (completeCheckpointLookup, demandedCaptureBoundaryRange), as the neighbouring paragraphs and docs rule 4 do. No content change.
…-swift-lm#355 libs/mlx-swift-lm moves 2231b8fc -> 723dbdaa. The refactor pass moves CBv2DemandedCaptureBoundaryTests into the SDK's unit tests and documents the capture-boundary partition's precedence and grid; no library behavior changes.
jonathan308
added a commit
that referenced
this pull request
Oct 24, 2026
…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.
Collaborator
Author
|
Superseded by #1592; consolidated per owner request |
6 of 10 tasks
jonathan308
added a commit
that referenced
this pull request
Oct 25, 2026
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.
jonathan308
added a commit
that referenced
this pull request
Oct 25, 2026
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.
Gajesh2007
pushed a commit
that referenced
this pull request
Oct 25, 2026
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>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GLM-5.3-Flash now caches a repeated prompt that is prefilled while other requests decode. Before, such a donor captured no checkpoint and nothing counted it (one of six donors in the qualification's concurrent burst). GLM captures only at prefill range ends on the 256-token grid, and its prefill chunk shares one 2,048-token step budget with the decode rows of other requests, so with company every range was 2,044–2,047 tokens and never ended on the grid.
libs/mlx-swift-lm184b5a93→2231b8fc(perf(cbv2): capture GLM checkpoints beside decoding requests mlx-swift-lm#355): an opt-in scheduler partition ends a cacheable donor's range on its demanded boundaries, and GLM adopters resume under ordinary chunking.EngineV2Factory.demandedCaptureBoundaryMinimumTokens).SSDPrefixCachePolicy.completeCheckpointWriteQueueJobs, set throughSSDHybridCheckpointStore.Config.writeQueueJobs). Once every donor captures, donors that finish together overflowed the single slot: two donors finishing within 27 ms lost both of one donor's files aswrite_queue_full. Other layouts keep one.The same cut lowers GLM's reuse granularity from 2,048 to 256 tokens (qualification F5).
Before
flowchart TB subgraph Before["Before: six GLM donors sent together"] direction TB b1(["6 repeated 8k prompts"]):::req --> b2["one 2,048 step budget;<br/>decode rows shorten each prefill range to 2,044–2,047"]:::flow b2 --> b3["5 of 6: no range end on the 256 grid<br/>no checkpoint, no counter"]:::bad b2 --> b4["1 of 6 prefilled alone: captured"]:::good b4 --> b5{"SSD store: 1 queued write"}:::check b5 -- "two donors finish together" --> b6["write_queue_full: files dropped"]:::bad b5 -- "alone" --> b7["written; next sighting hits"]:::good end classDef req fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef flow fill:#f3f4f6,stroke:#4b5563,color:#111827 classDef check fill:#fef3c7,stroke:#b45309,color:#78350f classDef good fill:#dcfce7,stroke:#15803d,color:#14532d classDef bad fill:#fee2e2,stroke:#b91c1c,color:#7f1d1dAfter
flowchart TB subgraph After["After: six GLM donors sent together"] direction TB a1(["6 repeated 8k prompts"]):::req --> a2["EngineV2Factory: GLM engine + GLM store →<br/>demandedCaptureBoundaryMinimumTokens = store floor"]:::flow a2 --> a3["each donor ends a range on 8,192<br/>(whatever chunk company left it)"]:::good a3 --> a4["6 of 6 captured"]:::good a4 --> a5{"GLM store: 8 queued writes<br/>(other layouts: 1)"}:::check a5 --> a6["6 of 6 written; ready receipts;<br/>every next sighting hits"]:::good end classDef req fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef flow fill:#f3f4f6,stroke:#4b5563,color:#111827 classDef check fill:#fef3c7,stroke:#b45309,color:#78350f classDef good fill:#dcfce7,stroke:#15803d,color:#14532dLinked issue
None; follow-up from the GLM-5.3-Flash cache qualification (findings F4, F5).
Stacking: based on #1587's head after its refactor pass,
b2d77d6ef(git merge origin/feat/glm-bf16-ssd-checkpoints: already up to date).libs/mlx-swift-lmpoints at2231b8fc= Layr-Labs/mlx-swift-lm#355, one commit on #353's refactored head184b5a93, so the pin contains both. Merge order: #353 → #355, #1587 → this PR. No code file overlaps #1587 or #353; three docs files that #1587's refactor also edited (prefix-cache.md,inference.md,ssd-kv-cache.md) change here in different sections.Evidence
M5 Ultra #1, real GLM-5.3-Flash weights, dev builds of this branch's code against a loopback coordinator with cache routing (isolated provider state; the signed install stayed stopped). "Before" is the qualification of #1587.
write_queue_full, twice)Correctness was judged on state, not text: per-tensor SHA-256 of the written checkpoints and per-layer diffs of their plaintext. Solo donors of one prompt write bit-identical checkpoints across runs and scopes. A donor prefilled beside decoding requests differs from the solo reference from its first partial four-token KDA group on (relative L2 ~0.1 in the deepest layers), and first-token logprobs of three partitions spread over ~0.1 nat while each partition repeats exactly. GLM's cold prefill already depends on the partition its company produces, as the MoE Qwen's does; a checkpoint is bit-exactly what its donor computed. Tables are in Layr-Labs/mlx-swift-lm#355.
The
write_queue_fulldrops: in the single-slot runs the donor that prefilled alone (two files) and another donor finished within 27 ms; the other donor's job still sat in the one-slot buffer when the solo donor's two jobs arrived, so both were refused (prefix_cache_donation_outcomes: donated 8, write_queue_full 2).donation_drops_totaldoes not count these, which is why the qualification saw zero drops.Test plan
156f2624…, isolated state files):swift test --skip-build --no-parallel --filter 'SSD|PrefixCache|Checkpoint|GLM5Next|Demanded|EngineV2Factory', skipping the runner's isolated suites. Swift Testing: 750 tests in 150 suites passed. XCTest: 6 executed, 1 skipped, 1 failure inMiMoV26DiscoveryLoadFootprintTests, which needsMIMO_V26_SERIAL_LOAD_FIXTURES(MiMo fixture recipe not prepared; unrelated).DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1,GLM5NextProtectedFactoryTests|GLM5NextEncryptedCheckpointTests|SSDCheckpointWriteQueueTests: 11 tests in 3 suites passed (tiny synthetic GLM through the real protected factory with the partition on, and the encrypted GLM store).SSDCheckpointWriteQueueTests: four donations finishing together queue behind a blocked writer and a fifth settleswrite_queue_full; it times out against the old two-in-flight gate. The existing two-writer test (SSDCheckpointFleetWritePriorityTests) still passes for the default depth../scripts/docs-check.sh(196 OK),python3 scripts/docs-impact-check.py --base origin/feat/glm-bf16-ssd-checkpoints(OK),python3 scripts/changelog.py check(3 valid).591f03fa…=40a1fd544+ perf(glm): price measured restore time in complete-checkpoint ready receipts #1590's estimator;5f326a737only rewords a comment): six concurrent 8k donors 6/6 captured and written;prefix_cache_donation_outcomesdonated 8 (six 8,192 files + two 2,048), skipped_novel 12 (first sightings), nowrite_queue_full; all six checks hit at 8,192 (stage 885–1,022 ms, TTFT 1.43–1.59 s). Production files on DGInf: Decentralized private AI inference platform #1 were restored and match the pre-run snapshot.Components touched
Protocol / interface changes
Documentation impact
docs/architecture/prefix-cache.md(GLM capture partition, partition dependence),docs/architecture/inference.md(GLM scheduler),docs/reference/ssd-kv-cache.md(complete-checkpoint write queue),changelog.d/glm-capture-under-load.md.Merge Danger
Door: two-way. Reverting restores the old geometry and queue; the checkpoint format and namespace are unchanged.
Blast Radius: GLM-SSD-cache. Only the protected GLM engine with a GLM store sets the partition, and only GLM stores get the deeper queue. A queued GLM donation keeps its donor's pages and KDA copies charged to the admission ledger until its write settles, so a burst of finishing donors can hold their KV for up to about eight writes (~0.15–0.3 s each) before the pages return; the bridge's slot gate counts only active requests, so new requests wait in engine admission for that time rather than being refused.
Limitations
logprobsandreasoning_effort: nonewere cut but never donated in these runs. Probably no MTP assistant state for the capture on those rows; not investigated.Refactor pass
Done, in two signed commits. The provider code, the tests and the changelog fragment are unchanged.
3e0b8a08a(docs): the GLM capture paragraph ofprefix-cache.mdnamed two SDK files by bare file name, whichdocs-checkcannot verify. It now cites them by path with their symbols:libs/mlx-swift-lm/Libraries/MLXLMCommon/ContinuousBatchingV2/Prefix/EngineV2+CompleteCheckpoint.swift(completeCheckpointLookup) and…/Prefix/DemandedShortCheckpointRange.swift, as the neighbouring paragraphs and docs rule 4 do.0c3b31d85(pin):libs/mlx-swift-lmmoves2231b8fc→723dbdaa, the refactor pass of perf(cbv2): capture GLM checkpoints beside decoding requests mlx-swift-lm#355. That pass movesCBv2DemandedCaptureBoundaryTestsinto the SDK's unit tests and adds two doc comments. No library code changes. This supersedes the2231b8fccited above.Reviewed and left as is:
EngineV2Factory.demandedCaptureBoundaryMinimumTokensis next to the other demanded-checkpoint policies.SSDHybridCheckpointStore.Config.writeQueueJobssets both the pipeline capacity and the in-flight gate. At the default depth of 1,writing.count <= writeQueueJobsis the same check as the old< 2.SSDPrefixCachePolicy.completeCheckpointWriteQueueJobsis the only one of its kind in this stack.Validation on
0c3b31d85:CFFIXED_USER_HOMEpointed at a temp dir.~/.darkbloom/usage-history.jsonwas byte-identical before and after.swift test --skip-build --no-parallel --filter 'SSD|PrefixCache|Checkpoint|GLM5Next|Demanded|EngineV2Factory|Receipt', skipping the runner's fresh-process suites:Receiptterm also selects two MiMo XCTest cases (MiMoV26NativeLoadTransactionTests,MiMoV26ServingLoadTests). They failed withfixtureRequiredbecause the MiMo fixture recipe was not prepared, which is unrelated to this PR, as withMiMoV26DiscoveryLoadFootprintTests. The XCTest rerun skipped them.SSDShorterNativeBlockRestoreTests(2),SSDNativeCheckpointOracleTests(2) andstageDelta(1) passed.DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1,GLM5NextProtectedFactoryTests|GLM5NextEncryptedCheckpointTests|GLM5NextProviderLoopTests|SSDCheckpointWriteQueueTests: 16 tests in 4 suites passed../scripts/docs-check.sh(196 OK),python3 scripts/docs-impact-check.py --base origin/feat/glm-bf16-ssd-checkpoints(OK),python3 scripts/changelog.py check(3 valid) andpython3 scripts/test-docs-impact-check.py(OK).