Skip to content

perf(glm): store GLM-5.3-Flash SSD checkpoints at BF16 - #1587

Closed
jonathan308 wants to merge 4 commits into
masterfrom
feat/glm-bf16-ssd-checkpoints
Closed

jonathan308 wants to merge 4 commits into
masterfrom
feat/glm-bf16-ssd-checkpoints

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

GLM-5.3-Flash SSD checkpoints are now stored at half precision where the values are half precision. This bumps libs/mlx-swift-lm to Layr-Labs/mlx-swift-lm#353 (9abc8090) and adds docs and a changelog fragment. The latent keys, the [index keys | pool gates | validity] values row and the KDA convolution history are FP32 copies of BF16 activations, so they are written at BF16 and widened back to the same FP32 bits on restore. The accumulated KDA recurrent state stays FP32. The export refuses any value BF16 cannot hold exactly.

flowchart LR
    subgraph Before["Before (v1)"]
        D1[donation] --> W1["DBK3 all FP32<br/>30,720 tok = 1,242.8 MB"]
        W1 --> R1["restore: decrypt + copy<br/>stage 1.84 s"]
    end
    subgraph After["After (v2)"]
        D2[donation] --> N2{exact in BF16?}
        N2 -- no --> X2[no file]
        N2 -- yes --> W2["DBK3 BF16 roles + FP32 recurrent<br/>30,720 tok = 716.4 MB"]
        W2 --> R2["restore: decrypt + widen<br/>stage 1.38 s"]
    end
Loading

Every SSD invariant is untouched: encryption and authentication per segment, owner-only paths, volume identity, missing-disk refusal, daily write accounting (it is now charged fewer bytes) and bounded retirement. The provider code is unchanged; the store sees smaller, differently typed descriptors through the existing manifest.

Linked issue

None; follow-up from the GLM-5.3-Flash cache-routing qualification (store GLM SSD snapshots at half precision). Depends on Layr-Labs/mlx-swift-lm#353.

Test plan

  • A/B on an M5 Ultra: two dev builds of this tree, aabb9056… (SDK 6148b6da) and 0a98171c… (SDK 2c512cda, the same code before formatting). Each ran the real GLM-5.3-Flash weights and the production metallib 156f2624…, against the same loopback coordinator (real api.Server, registry and prompt sidecar, cache routing on) and the same prompts. Each build ran 2k/8k/32k sequences (2 uncached, warm hit, hit after sudo purge, q2 hit vs other-account miss) and a 6-donor concurrent burst.
  • SDK suites (release, testable imports): Swift Testing 33 tests in 8 suites; XCTest 41 executed, 0 failures, plus the native complete-prefix lane (DARKBLOOM_TEST_NATIVE_COMPLETE_PREFIX=1). See mlx-swift-lm#353.
  • ./scripts/docs-check.sh (196 files OK), python3 scripts/docs-impact-check.py --base 9034a5a0f (OK), python3 scripts/changelog.py check.
Measure Before (v1) After (v2)
Checkpoint at 2,048 tokens 228,459,212 B 187,126,608 B (-18.1 %)
Checkpoint at 8,192 tokens 445,826,843 B ~300,547,000 B (-32.6 %)
Checkpoint at 30,720 tokens 1,242,839,595 B 716,422,963 B (-42.4 %)
Bytes per token / fixed part 35,378.8 B / 156.0 MB 18,460.3 B / 149.3 MB
SSD bytes per donation, 8k / 32k (incl. the 2,048 anchor) 674.3 / 1,471.3 MB 487.7 / 903.5 MB
SSD bytes, identical workload (17 files) 6.42 GB 4.50 GB (-29.8 %)
Provider write time, 32k donation 367 ms 267 ms
Restore stage, median of 3 hits (2k / 8k / 32k) 1409 / 1606 / 1844 ms 1043 / 1147 / 1383 ms
Hit TTFT, median (2k / 8k / 32k) 1917 / 2233 / 4650 ms 1569 / 1883 / 3964 ms
Concurrent burst, donors captured 1 / 6 1 / 6 (unchanged; separate scheduler finding)
Restored vs uncached greedy output (q1, q2 × 2k/8k/32k) — identical in all 6 pairs
Largest staged checkpoint under the 7 GiB cap ~208k tokens full 262,144-token context (~5.0 GB)

Every v2 donation succeeded, so no element needed rounding. Cold TTFT also differed by ~0.4 s between the two processes, so stage time is the clean restore metric.

Second commit (f8a270ae4): the SDK's restore-time GLM validity check now strides through the validity column (1 element in 257) instead of testing every element. One 30,720-token checkpoint validates in 0.53 ms instead of 51.3 ms (M3 Ultra micro-benchmark); see mlx-swift-lm#353.

Components touched

  • provider-swift (Swift CLI)
  • native runtime / MLX
  • landing (Next.js)
  • enclave (Swift)
  • CI / provider release
  • docs

Protocol / interface changes

None on the wire. The checkpoint layout string becomes native-paged-glm5next-full-state-v2, which changes the SSD layout epoch and namespace. Receipts, usage and routing fields are unchanged.

Merge Danger

Door: two-way

Providers start a fresh GLM namespace after upgrading, so warm GLM checkpoints are lost once; the cache is regenerable. A rollback ignores v2 files the same way, and whole-root maintenance expires the stale namespace by TTL.

Blast Radius: GLM-SSD-cache

Only GLM's codec records a half wire dtype. Other models' manifests keep storage == nil, so the FP32/native wire is byte-identical to before.

Refactor pass

Done, in two signed commits. The provider code and the changelog fragment are unchanged.

  • 6e076fe30 docs: the SSD reference owns the GLM v2 format. prefix-cache.md and inference.md now name the identifiers and link to it instead of restating its values (BF16, "roughly halves", the FP32 recurrent state), following docs rule 7. The reference cites CBv2CheckpointHalfPrecision by symbol and lists only the current v2 sizes. The v1 comparison remains in the changelog fragment and in this PR's evidence.
  • b2d77d6ef pin: libs/mlx-swift-lm moves 9abc8090 → 184b5a93, the refactor pass of feat(glm5next): write GLM complete checkpoints at their BF16 activation dtype mlx-swift-lm#353. It preserves behavior and the format, and supersedes the 9abc8090 cited above.

Validation on b2d77d6ef:

  • Provider debug test build with the bumped SDK (M3 Ultra, staged metallib, isolated state files):
    • GLM checkpoint and SSD prefix-cache selection: 309 tests in 53 suites passed. It covers GLM5NextEncryptedCheckpointTests (real tiny GLM through the encrypted store, with and without MTP), SSDHybridCheckpoint*, SSDCheckpoint*, SSDPrefixCache*, SSDCompleteCheckpointStageCapTests, CompletePrefixCacheCapabilityTests and PrefixCache*. Opt-in live and benchmark cases skip by design.
    • With DARKBLOOM_TEST_GLM5_PROTECTED_FACTORY=1, GLM5NextProtectedFactoryTests|GLM5NextProviderLoopTests: 11 tests in 2 suites passed.
  • Real model on M5 Ultra DGInf: Decentralized private AI inference platform #1, dev build of this tree: every output and byte count is identical to the pre-refactor v2 build. Details are in feat(glm5next): write GLM complete checkpoints at their BF16 activation dtype mlx-swift-lm#353.
  • ./scripts/docs-check.sh (196 OK), python3 scripts/docs-impact-check.py --base origin/master (OK), python3 scripts/changelog.py check (2 valid) and python3 scripts/test-docs-impact-check.py (OK).

Bump mlx-swift-lm to 39a12e1d (Layr-Labs/mlx-swift-lm#353): GLM complete
checkpoints write the latent keys, the index/gate/validity values row and
the KDA convolution history at their BF16 activation dtype and widen them
back to the identical FP32 bits on restore; the FP32 KDA recurrent state is
unchanged and any value BF16 cannot hold refuses the donation. The layout
becomes native-paged-glm5next-full-state-v2 (new namespace; v1 files expire
through the whole-root TTL sweep).

Measured on an M5 Ultra against the v0.10.1 build: checkpoints at
2,048 / 8,192 / 30,720 tokens shrink 18 / 33 / 42 %, bytes per token 48 %,
SSD bytes for an identical workload 30 %, and restore stage 25-29 %.
Document the v2 layout and sizes in the SSD reference and prefix-cache
architecture pages.
@vercel

vercel Bot commented Oct 24, 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 24, 2026 9:11am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 24, 2026 9:11am UTC
d-inference-landing Ready Ready Preview Oct 24, 2026 9:11am UTC
darkbloom-status Ready Ready Preview Oct 24, 2026 9:11am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 24, 2026 9:11am UTC

Request Review

Bump mlx-swift-lm to 9abc8090 (Layr-Labs/mlx-swift-lm#353): the restore-time
validity check strides through the values row's validity column instead
of testing every element (one 30,720-token checkpoint: 51.3 ms -> 0.53 ms
on an M3 Ultra).
Refactor pass. The SSD reference owns the GLM full-state v2 format; the
prefix-cache and inference explanations now name the identifiers and link
to it instead of restating its values (BF16, the payload ratio, the FP32
recurrent state). The reference cites the helper by its symbol and
tabulates the current v2 checkpoint sizes; the retired v1 comparison stays
in the changelog fragment and the PR evidence.
…-swift-lm#353

Bumps libs/mlx-swift-lm 9abc8090 -> 184b5a93: the paged export walk is
shared by the native and narrowing branches, a wire dtype equal to the
page dtype is the native layout, the import sink drops its force unwraps,
and the half-precision tests are split into unit and kernel suites. The
checkpoint format and every GLM checkpoint byte are unchanged.
@jonathan308

Copy link
Copy Markdown
Collaborator Author

Superseded by #1592; consolidated per owner request

jonathan308 added a commit that referenced this pull request Oct 24, 2026
…otron 3.5 Super (601a97d) into provider 0.10.2 features

GLM-5.3-Flash and Nemotron 3.5 Super now default to the 4-bit balanced SSD checkpoint profile; #1587's BF16 layout remains the native fallback. Resolves the libs/mlx-swift-lm pin to the 0.10.2 SDK set bc4e5f57 (main + #360 + #357 + #359 + #362 + #363).
@jonathan308 jonathan308 mentioned this pull request Oct 24, 2026
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

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