Skip to content

perf(glm): faster long-context decode — SDK pin for bounded paged reads and decode/MTP command buffers (folds into #1592) - #1598

Merged
jonathan308 merged 3 commits into
release/provider-0.10.2-featuresfrom
perf/glm-long-context-decode
Oct 24, 2026
Merged

jonathan308 merged 3 commits into
release/provider-0.10.2-featuresfrom
perf/glm-long-context-decode

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Folds into #1592 (release/provider-0.10.2-features): this branch is #1592's head cc7a611f3 plus two commits, so the PR targets #1592's branch (a stacked child, per the linear-stack rule) and its diff is only those commits. SDK side: mlx-swift-lm #362 (Layr-Labs/mlx-swift-lm#362) (same commits on the #356 fold branch perf/glm-long-context-decode @ 5fba64c0).

Summary

Re-pins libs/mlx-swift-lm to 5fba64c0 so GLM-5.3-Flash's paged long-context decode stops paying one full-history launch per 64 MiB KV segment, and GLM plain decode gets op-count-only command buffers. Docs (docs/architecture/inference.md) and a changelog fragment (glm-long-context-decode.md).

 GLM decode step (per DSA layer, per row; S ≈ history / 2,048 segments)
-  zeros(history × 257) + S metadata launches over the whole history
-  per query: S selection launches
+  ceil(S / 17) metadata launches over only the bound segments' pages (no fill)
+  per query: ceil(S / 17) selection launches
 plain decode step (3+ rows)
-  MLX default command buffers (commit every 50 ops or 50 M input elements)
+  100 ops per command buffer, no input bound

Before / after flow:

flowchart TB
  A[decode step] --> B{paged DSA read}
  B -->|before| C["S launches × full history<br/>(+ zero fill)"]
  B -->|after| D["ceil(S/17) launches × own pages"]
  A --> E{plain decode?}
  E -->|before| F[MLX default command buffers]
  E -->|after| G[100 ops / no input bound]
Loading

Evidence

M5 Ultra 256 GB (#1, native GLM path), c=1, adaptive MTP, T=1.0 / top_p 0.95, reasoning on, production
262,144-token selection, one cold request per cell. Before = #1592 head cc7a611f3 (SDK efd38585); after =
the same provider with this SDK head.

prompt (tokens) before tok/s after tok/s change TTFT before → after
1K (1,283) 80.5 86.0 +7 % 0.68 → 0.68 s
8K (8,764) 61.2 71.7 +17 % 5.28 → 5.08 s
32K (34,474) 36.1 61.7 +71 % 17.7 → 16.2 s
64K (68,926) 20.2 48.7 +141 % 36.3 → 33.1 s

MTP acceptance 0.79–0.90 in every cell. Concurrency (short prompts, 256 tokens; plain-decode scope only, before the
MTP-round commit): c=3 aggregate 84.1 / 86.4 → 92.2 / 91.9 tok/s (+8 %), 8K-prompt c=3 aggregate 59.3 → 78.3.
The MTP-round scope alone (same build, switch): 80.2 / 66.8 / 57.1 → 82.4 / 71.4 / 62.3 tok/s at 1K / 8K / 32K.

Kernel profile (M3 Ultra, the SDK's kernel sources before/after at GLM-5.3 geometry, 12 DSA layers per step,
reads_equal = bit-identical bytes at every size):

history segments per layer metadata reads, ms/step: before → after 4 queries' selection reads: before → after
1K 1 0.69 → 0.69 2.53 → 2.07
8K 4 2.44 → 1.16 4.72 → 2.26
32K 16 21.2 → 3.34 15.6 → 3.41
64K 32 76.2 → 6.29 29.5 → 5.80

Exactness:

  • M5, serial-target MTP profile, greedy, 128 tokens, fixed 1K / 8K / 32K prompts: completions byte-identical before
    and after.
  • SDK (M3, xcodebuild test-without-building): Test run with 82 tests in 4 suites passed — GLM5NextCBv2Tests
    (deviceTableMetadataReadsMatchHostRecords with two-page segments, growth and a copy-on-write fork;
    deviceTableMetadataEngineMatchesContiguousTarget; latentHistoryReadMatchesSelectedReadsBitwise;
    latentHistoryPagedEngineMatchesContiguousEngine), GLM5NextKernelSpecializationTests (single binding equals the
    former kernel bitwise; new boundSelectedLatentReadMatchesPerSegmentReads for 1/3/4/5/9/17 segments; templates carry
    no history length), GLM5NextMTPTests (new nativeResourcesDeclarePlainDecodeCommandBufferLimits).

Not in this PR (measured, documented for 0.10.3): paged split-K is within noise after these fixes (69.5 / 58.1 / 42.9
vs 66.8 / 57.1 / 44.3 at 8K / 32K / 64K) and is not bit-exact, so it stays off. The next long-context cost is MLX
allocator churn: history-sized read outputs grow every step, miss MLX's buffer cache and pay a residency-set commit
(25 % of the engine thread at 64K after this PR).

Merge Danger

Door: two-way (a gitlink bump; outputs bit-identical; no protocol, catalog, pricing or checkpoint-identity change).

Blast Radius: GLM-5.3-Flash serving speed only.

Refactor pass: done, docs-only change (8bd2d66f7): inference.md said every paged read launches once per 64 MiB segment; the pinned SDK binds up to 17 segments per launch (PagedSegmentDispatchPlan.maximumBindings), as the changelog fragment already said. The paragraph was rewrapped. docs-check, docs-impact and changelog check pass. The pin and fragment were reviewed, unchanged. On the combined debug build of #1592 d85f7e71a + #1593 + #1595 (2994a65a8) + #1598 with SDK 4d962e39 + 5d3bf208 + 5fba64c0 merged; M3, isolated state, usage journal unchanged: GLM5NextProtectedFactoryTests + GLM5NextProviderLoopTests 13/2 and GLM5NextLogprobsTests 2/1 pass.

…buffers

Re-pins libs/mlx-swift-lm to ed573083 (perf/glm-long-context-decode on
efd38585):
- paged GLM history and selection reads bind up to 17 KV segments per
  launch and copy only each segment's pages, with no zero fill (exact
  copies);
- plain GLM decode steps take op-count-only command buffers (100 ops, no
  input bound), as Nemotron Super and Flint do.

Docs: the GLM paged-read and command-buffer behaviour in
docs/architecture/inference.md. Changelog fragment glm-long-context-decode.
…unds

Re-pins libs/mlx-swift-lm to 5fba64c0 (perf/glm-long-context-decode): GLM
MTP rounds whose rows are all decode or verification rows take the same
op-count-only command buffers as plain decode; rounds that carry a prompt
chunk keep MLX's defaults. Docs and the changelog fragment state the scope
and the measured M5 Ultra speeds.
@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 7:31pm UTC
d-inference-console-ui-dev Ready Ready Preview Oct 24, 2026 7:31pm UTC
d-inference-landing Ready Ready Preview Oct 24, 2026 7:31pm UTC
darkbloom-status Ready Ready Preview Oct 24, 2026 7:31pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 24, 2026 7:31pm UTC

Request Review

Refactor pass. The pinned SDK (ed573083 onward) binds up to
PagedSegmentDispatchPlan.maximumBindings (17) segments per paged read
launch; inference.md still said one launch per 64 MiB segment. Also
rewraps the paragraph. Docs only.
@jonathan308
jonathan308 merged commit f45964e into release/provider-0.10.2-features Oct 24, 2026
5 checks passed
jonathan308 added a commit that referenced this pull request Oct 24, 2026
…0.2 features

GLM long-context decode: the SDK's bounded paged reads and decode
command buffers, and the command-buffer scope for MTP verification
rounds (with SDK #362). Folded into #1592 per the parent. The
libs/mlx-swift-lm gitlink keeps HEAD's here; the final pin follows SDK
main FINAL.

# Conflicts:
#	libs/mlx-swift-lm
jonathan308 added a commit that referenced this pull request Oct 24, 2026
…49a23)

libs/mlx-swift-lm moves to f7449a23, the head of SDK branch
release/sdk-0.10.2-final. That branch is SDK main a1fbe922 (#356
merged) plus signed --no-ff merges of the SDK PRs that 0.10.2 ships:

- mlx-swift-lm#360 (44ad2b71): the FP8 eager-bound first-token stall fix;
- mlx-swift-lm#357 (74400370): Super speculates for sampled and
  controlled requests;
- mlx-swift-lm#359 (9c8810af): decode-only steps priced in the
  first-token projection;
- mlx-swift-lm#362 (880eadd6): GLM long-context paged decode.

SDK main fast-forwards to that branch once each PR's CI is green, so
this pin lands on main with no re-pin. mlx-swift (eedca444) and mlx
(ff4bb35b) are unchanged: the set moves no mlx-swift pin. The folded
provider PRs pinned their own SDK commits (#1593 4d962e39, #1595
5d3bf208, #1598 5fba64c0); each of those changes is in this set.
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-console-ui-dev — 8bd2d66f Deployed Oct 24, 2026 by vercel[bot]
Preview – d-inference — 8bd2d66f Deployed Oct 24, 2026 by vercel[bot]
Preview – d-inference-landing — 8bd2d66f Deployed Oct 24, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 8bd2d66f Deployed Oct 24, 2026 by vercel[bot]
Preview – darkbloom-status — 8bd2d66f 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