diff --git a/changelog.d/glm-long-context-decode.md b/changelog.d/glm-long-context-decode.md new file mode 100644 index 0000000000..19b7c9efd5 --- /dev/null +++ b/changelog.d/glm-long-context-decode.md @@ -0,0 +1,8 @@ +### GLM-5.3-Flash decodes faster at long context + +GLM's paged attention reads (index metadata, latent history and each query's selected latents) now bind up to 17 +memory segments per GPU launch and copy only the pages each segment holds, instead of one full-history launch per +segment after a zero fill. Decode steps and MTP verification rounds also submit GPU work in larger command buffers, +as Nemotron Super already does for plain decode. On an M5 Ultra, one request now decodes at about 73, 62 and 48 +tokens per second after 8K-, 32K- and 64K-token prompts, up from about 63, 36 and 19. Outputs are unchanged: every +read copies the same bytes. diff --git a/docs/architecture/inference.md b/docs/architecture/inference.md index 55526cf3fb..5be9c12738 100644 --- a/docs/architecture/inference.md +++ b/docs/architecture/inference.md @@ -800,7 +800,16 @@ engine prices one worst-case step at setup and stays inactive when it exceeds the post-load envelope (about 56.8 GB of admission on a 256 GiB host, shared with KV). Decode and MTP verification rows (at most 8 sparse queries) read one selection row per query, retained until the step fence (about 46 MB per query -across 11 DSA layers). A longer row whose selection rows would read at least +across 11 DSA layers). Each paged read launch binds up to 17 of the 64 MiB +segments that hold the row's pages (`PagedSegmentDispatchPlan.maximumBindings`): +index metadata and latent-history reads cover only those segments' pages, one +threadgroup per page, with no zero fill, and a selection read copies each row +with one SIMD-group (`GLM5NextPagedTransfers`). Plain decode steps (every row +one token) and MTP rounds whose rows are all decode or verification rows (at +most 8 tokens) commit a Metal command buffer every 100 operations with no +input-size bound, as Nemotron Super and Flint do for plain decode +(`GLM5NextDecodeCommandBuffers`); prefill chunks keep MLX's defaults. A longer +row whose selection rows would read at least its history instead reads its whole latent plane once per layer through the page table and runs the contiguous arithmetic over it (`GLM5NextPagedPayload.latentHistory`, `GLM5NextPagedModelBinding.readsLatentHistory`), diff --git a/libs/mlx-swift-lm b/libs/mlx-swift-lm index efd3858532..5fba64c00a 160000 --- a/libs/mlx-swift-lm +++ b/libs/mlx-swift-lm @@ -1 +1 @@ -Subproject commit efd38585321a9d401bb0ce8af965b2fbb6f91922 +Subproject commit 5fba64c00ae6e584308b75d701fda1087eb956b7