Skip to content

GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold

Python

Merge pull request #96 from BadAd84/patch-0084-display-kv-dispram

MiaAI-Lab28139b09af51
diff --cc CHANGELOG.md
index 5c46b02,ec40e30..b921372
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -5,28 -5,18 +5,40 @@@ Every change to this recipe, newest fir
## Unreleased
+- **Long-context decode** (patch `0085-glm-select-split-loop`): the DSA indexer's split top-k selection
+ (`select_split`, in `0029`'s segmented decode windows) ran its last pass as one `CP x 256` tile per chunk program,
+ masked to the chunks before it. `CP` comes from the selection scratch, which `verify.py` sizes for the whole KV
+ pool (5,791,744 rows at `PARALLEL=4` on three Sparks: 512 chunks a row), not the row's context, so every program
+ loaded and summed the full table: on rank 0 at 226k, 5.3 ms a launch and 92% of the growth of one request's decode
+ round from 35k (nsys: the selection 9.3 -> 56.9 ms of a round's GPU time, everything else +4.3). The pass now sums
+ only the earlier chunks' histograms, 16 at a time (`SPLIT_BLK`). The whole selection call, scoring included, at 16
+ rows: 0.96 -> 0.10 ms at 35k, 5.79 -> 0.28 at 226k, 15.68 -> 0.64 at 590k, 27.87 -> 1.08 at 1.04M; four requests x
+ 8 rows at 590k 32.46 -> 1.27 (11 layers a round). Integer sums in another order: the tokens and counts are
+ identical (`tools/select_split_check.py`: 149 checks against the kernel before the patch and a torch oracle).
+ Live on three Sparks (`PARALLEL=4`), one request: decode at 35k / 226k / 590k 182.6 / 111.2 / 66.2 ->
+ 203.0 / 191.0 / 184.4 tok/s, replies byte-identical.
+- **Long-context cold prefill** (patch `0086-glm-prompt-scores-loop`): what grows with context in a cold prefill is
+ the indexer's prompt scoring and selection (nsys on rank 0, two cold prompts of 35k and 226k tokens: the whole
+ prefill 585 -> 687 us of kernel time a prompt token, `_scores` 16.3 -> 103.6 of it, `_select_rows` 3.0 ->
+ 25.6, everything else flat). `0009`'s `_scores` ran 4 rows and one 64-pool block a program and reloaded each
+ row's 8 KB of queries for every block; it now takes one row and 32 blocks a program (`SCORE_LOOP`), the row's
+ queries and head weights loaded once, each block computed exactly as a 1-row program did. A 512-row block at
+ row positions 35k / 113k / 300k: 1.354 / 4.298 / 11.304 -> 0.867 / 2.766 / 7.250 ms (8 warps, or one dot over
+ all rows' heads, is faster still but changes the head sum's rounding). Every score bit and selection
+ identical (`tools/scores_loop_check.py`, 37 checks). Live on three Sparks: the same prompts cold, 35k 17.87 ->
+ 17.47 s, 226k 138.27 -> 126.60 s, replies byte-identical. `TF_GLM_SCORE_RB` is retired.
+ - **`DISPLAY_KV_BACKEND=dispram`** (patch `0084-glm-display-kv-dispram`; default `drm`, unchanged): `DISPLAY_KV_MIB` on
+ [kindling spark-os](https://github.com/kindlingai/kindling-spark-os). There `nvidia_drm` runs without modeset, so
+ `0072`'s DRM dumb buffer fails (`DRM_IOCTL_MODE_CREATE_DUMB`: ENOSYS) and the span never forms; kindling's
+ `dispramd` owns the reservation and lends it through its client's `map_glued` (ordinary device memory with the
+ reservation's slice right above it, one virtual range - the layout `0072`'s `map_span` builds). The backend takes
+ the span from there and everything carved from it is `0072`'s, unchanged. Fails closed like the DRM path: no client,
+ no daemon, or a slice shorter than the span stops the start. `start.sh` checks `/run/dispram/dispram.sock` and
+ `/opt/kindling/dispram/python` on the head and mounts both into every rank. Measured on three Sparks (TP=3,
+ `PARALLEL=4`, `KV_POOL_GIB=30`): 2032 MiB adds 317,440 pool tokens; `tools/display_kv_check.py`'s GPU check
+ passes 53/53 through the dispram span (display -> device copies 46.3 GiB/s); decode and prefill as without the span
+ (structured / prose / code 140.4 / 74.3 / 112.5 tok/s against 141.2 / 74.2 / 112.5; drafted replies equal serial
+ ones 7/7); an NVMe-backed restart and eviction test with the span on resumed byte-identical replies.
## v1.8 (2026-10-06): pictures read once, quoted markers, capacity refusals, and the take-over memory fix
diff --cc CREDITS.md
index 9ce9e81,cf73896..79dbe2d
--- a/CREDITS.md
+++ b/CREDITS.md
@@@ -118,12 -118,11 +118,17 @@@ checkpoint's ShapleyMcg attribution an
[johnwhited](https://github.com/johnwhited) (#48); the admission check and the abort-on-delivery-failure semantics
follow [vLLM](https://github.com/vllm-project/vllm) v1's `check_admission` and generate-abort behaviour
(Apache 2.0) as a reference.
+- `0084-anthropic-messages`: TensorFold v0.6.3's Anthropic Messages API (commits 8cca6e3 and ba18743, merged as
+ e9fade0, with ced6139's request framing) by [evilpsycho42](https://github.com/evilpsycho42) and
+ [ashhart](https://github.com/ashhart), backported to v0.6.0.
+- `0085-glm-select-split-loop` (the split selection's last pass over the earlier chunks only): by
+- `0086-glm-prompt-scores-loop` (the prompt scoring, one row and many pool blocks a program): by
+ [BadAd84](https://github.com/BadAd84).
+ - `0084-glm-display-kv-dispram` (`DISPLAY_KV_BACKEND=dispram`: `0072`'s display reservation on kindling spark-os): by
+ [BadAd84](https://github.com/BadAd84). It maps the span through `dispram`, the display-carveout lender of
+ [kindling spark-os](https://github.com/kindlingai/kindling-spark-os) by Matt Mastracci (Kindling AI). Nothing of
+ dispram ships here: the ranks import the host's client (`python/dispram.py`, GPL-3.0 with a bundling exception)
+ mounted read-only at run time and talk to `dispramd` (AGPL-3.0) over its socket.
- Every patch, except the parts credited above: by MiaAI-Lab, developed with
[Claude Code](https://claude.com/claude-code), under the Apache License 2.0; the TensorFold code the patches modify or
quote as context stays under TensorFold's licenses (Apache 2.0, and MIT for code written before v0.6.0; see
diff --cc README.md
index ab1d932,12dd033..d4bfc47
--- a/README.md
+++ b/README.md
@@@ -571,8 -567,8 +577,9 @@@ applied with `patch -p0` in filename or
| Weights | `0002-glm-dense-fp8`, `0005-glm-dense-q4` | the checkpoint's BF16 dense weights in FP8, or 4-bit with MSE-searched ranges (`DENSE`) | q4 over fp8: prose 38.9 -> 44.4 tok/s, code 44.2 -> 48.7, prefill ~1,090 -> ~1,260 tok/s |
| KV cache | `0038-glm-kv-fp8` | the DSA latent cache and the indexer's pooled keys as FP8 rows (`KV=fp8`) | the 1M window with 4 requests fits |
| KV pool | `0072-glm-display-kv` | the first DSA latent planes in a span ending in the GPU's display reservation, which `MemAvailable` does not count; the pool's row copies of those planes by a kernel (a memcpy may not cross the span's two registrations) (`DISPLAY_KV_MIB`, by ezoushen) | 1792 MiB: ~277k more tokens at `PARALLEL=8`; the same bits, decode and prefill |
+ | KV pool, kindling | `0084-glm-display-kv-dispram` | `0072`'s span with its reservation half from kindling spark-os's `dispramd` instead of a DRM dumb buffer, which kindling's `nvidia_drm` (no modeset) cannot make; the rest of `0072` runs unchanged (`DISPLAY_KV_BACKEND=dispram`) | 2032 MiB: +317,440 tokens at `PARALLEL=4` on three Sparks; the display check 53/53 |
| Prompt | `0001-glm-exl3-prompt-experts`, `0004-glm-prompt-kernels`, `0009-glm-prefill-kernels`, `0020-glm-prompt-experts-order`, `0024-glm-prompt-select-rows`, `0028-glm-lean-prompt-scratch` | EXL3 expert kernels that keep a prompt chunk's rows in L2, launched in a better order; each row's input rotated once; dense attention only where the sparse pass needs it; token selection in blocks of 512 rows; smaller prompt scratch | faster prefill, less memory at 1M |
+| Prompt, indexer | `0086-glm-prompt-scores-loop` | a prompt chunk's indexer scoring (`0009`'s `_scores`) takes one row and 32 pool blocks a program (`SCORE_LOOP`), the row's queries loaded once, instead of 4 rows and one block (`TF_GLM_SCORE_RB`, retired), which reloaded every row's queries for each 64-pool block | the scoring 36% faster at long context (the part of a cold prefill that grows with it); cold prefill at 226k 138.3 -> 126.6 s; the same bits |
| Prompt, two Sparks | `0010-glm-hc-split`, `0033-glm-prefill-overlap2`, `0017-glm-overlap-priority`, `0022-glm-overlap-normal-priority`, `0064-glm-split-connect-early` | hyper-connection glue split by rows between the Sparks, exchanges overlapped with the next rows' work (`SPLIT`); the split's send/receive connection opened before the weights and the cache pool (issue #36) | 50k prefill ~1,270 -> ~1,730 tok/s with 0009 and 0020; decode rounds pay ~1.5% |
| Prompt, KDA | `0012-glm-kda-chunked`, `0014-glm-kda-chunked-gb10`, `0039-glm-kda-chunked-kernel` | the linear-attention layers' prompt chunks in chunked (WY) form, one CUDA kernel (`KDA_CHUNKED`) | 50k prefill 29.3 -> 26.4 s, 149k 91.1 -> 84.5 s (one start each) |
| Prompt reuse | `0008-glm-prompt-grid`, `0015-glm-shared-prefix`, `0042-glm-prompt-replay`, `0054-glm-image-prompt-reuse`, `0060-glm-keep-thinking`, `0063-glm-kept-cap-superseded-first`, `0071-glm-shared-prefix-copy`, `0077-glm-kept-cap-shared-by-recency`, `0078-glm-take-over-decide-then-copy` | prompt chunks and kept states on a token grid; a shared system prompt's state reused (copied out of the conversation that wrote it, which keeps its own state, by ezoushen, #43); an identical prompt resumes from its kept end state; prompts with pictures resume too, their kept states told apart by each picture's content (by abhicnv007, issue #11); earlier turns' reasoning kept in the prompt (`TF_GLM_CLEAR_THINKING`, by kky42, #23); past the kept-state cap a conversation's superseded states go first (by Alexbob0, #32), and shared-prefix states by recency only, so a new agent run still finds its system prompt (diagnosed and the fix proposed by meleesciony, #75); a fresh conversation after a long one clones only the kept states that stay, not every one first (reserved +14.8 -> +1.4 GiB after 256k, 21 turns; upstream #421) | [Performance](#performance) |