GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold
Python
Merge fix/issue-80: the drafter checks its candidate ids against the vocabulary (#80), as 0092
MiaAI-Lab08fe0f602046
diff --cc CHANGELOG.mdindex f6be3da,515fb07..08b7242--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -3,63 -3,6 +3,67 @@@Every change to this recipe, newest first. Each release names the image it serves: `scripts/prepare.sh` pulls`ghcr.io/miaai-lab/glm-5.3-flash-exl3-2x-dgx-sparks-tensorfold` by the digest pinned in `scripts/config.sh`.+## Unreleased+++- **The drafter checks its candidate ids** (patch `0092-glm-draft-candidates-checked`, issue #80): an id outside the++ vocabulary (a float's bits read as an id) is logged with its value and the rows are copied again once the device is++ idle; only a second bad read fails, as before. A mitigation: the root cause of #80 is not yet found, and the log line++ tells a late copy from a rank mismatch.+- **Anthropic Messages API** (patch `0084-anthropic-messages`, PR #90 by Eduardo Florencio, @eduffd): upstream TensorFold+ v0.6.3's `/v1/messages` (also `/messages`, with `/count_tokens`) by evilpsycho42 and ashhart, with Jordi Posthumus's+ request body reading, backported to v0.6.0; a tool_result's images ride the following user message (patch `0056`),+ capacity refusals answer `overloaded_error`. Claude Code and the Anthropic SDKs talk to the server directly. Live+ checks: `tools/anthropiccheck.py`.+- **`TF_GLM_LOOP_GUARD=1`** (patch `0091-glm-loop-guard`, off by default; issues #89, #94): a think block that collapsed+ into repeating itself (an exact cycle of up to 16 tokens held for 256, or one token taking half of the last 256) is+ closed with the thinking budget's close, per request, and the model answers from there; `usage.tensorfold.loop_guard`+ counts it. Paraphrase loops still need `--thinking-budget`. CPU test: `tools/test_loop_guard.py`.+- **The start's smoke test fails on one repeated character** (#76, #81, #86): a collapsed model that answers "!!!!" no+ longer passes as OK.+- **Expert decode launch order** (patch `0090-glm-expert-launch-order`, by Lukasz Raczylo, @lukaszraczylo, PR #95):+ `TF_GLM_EXL3_DEC_ORDER=1` (or `2`) maps the decode expert kernel's block grid so that the eight 128-column blocks of+ one k slice run together and read contiguous memory; the same bits for every value. Off by default (`0`, the old+ order). The author's run: one request +2.2%, four at once noisy. The patch's variable is its own: the PR's `TF_GLM_EXL3_ORDER` is+ patch `0020`'s prompt order (default on, any value but `0`), so `true` would have raised and `1` would have turned+ the new order on for existing users.+- **Hermes Agent** (`docs/hermes-agent.md`, `tools/hermes_benchmark.py`, `tests/test_hermes_benchmark.py`, by Steve+ Darlow, @kerpopule, PR #52): how to use the server as Hermes Agent's custom endpoint, and a stdlib harness that times+ synthetic requests against an idle server (any `--model` id; `/health` fields read as the server reports them).+- **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 `0087-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 fixImage: `v0.6.0-31557ed1cef6` (`sha256:cbb4b3c66273e2965dd40a7227e7a5243db333fe250113fb3987462ad4f12588`), 82 patches, for two and three Sparks (v1.7.1's plus `0078`-`0083`). Every change below was alsodiff --cc README.mdindex 3b8479f,5fda116..8699b89--- a/README.md+++ b/README.md@@@ -612,7 -585,7 +612,8 @@@ applied with `patch -p0` in filename or| Capacity status | `0081-tfcap-capacity-status` | every capacity refusal renders the same way: 429 with `Retry-After: 5` (was a bare 503 at two sites, a 400 on the generate path) (by johnwhited, #48) | a refused request's client can back off instead of stacking || Admission control | `0082-tfcap-admission-cap` | `TF_GLM_MAX_QUEUED` (unset: queue, as before; a number: past the lanes plus that many queued foreground requests, refuse) turns saturation into a refusal instead of an invisible queue (by johnwhited, #48) | with `TF_GLM_MAX_QUEUED=0`, the fifth request on four lanes: 429 at once with `Retry-After: 5`; unset, it queues as before || Delivery abort | `0083-tfcap-delivery-abort` | a stream whose delivery callback raises (broken pipe, reset, timeout) ends at once and frees its lane, instead of the exception escaping and the lane leaking until generation ends (by johnwhited, #48) | a client that dies mid-reply no longer holds a lane |-| Checked draft candidates | `0084-glm-draft-candidates-checked` | the drafter checks each block pass's candidate ids against the vocabulary; on an id outside it (issue #80: a float's bits read as an id) it logs the value, copies the rows again once the device is idle, and fails only if they are still bad | a rare drafter `IndexError` is retried (and its cause logged) instead of killing a rank |+| Anthropic Messages | `0084-anthropic-messages` | Anthropic's `/v1/messages` (also `/messages`, with `/count_tokens` suffixes), translated to the same chat completion the OpenAI route serves — text and image blocks, `tool_use` / `tool_result`, thinking, `stop_sequences`, `output_config` effort/JSON schema — with Anthropic SSE streaming and bodies capped at 32 MiB (upstream v0.6.3, by [evilpsycho42](https://github.com/evilpsycho42) and [ashhart](https://github.com/ashhart), request bodies by [Jordi Posthumus](https://github.com/JordiPosthumus); backported by [Eduardo Florencio](https://github.com/eduffd)) | Claude Code and the Anthropic SDKs work against the server directly, without a translating proxy |++| Checked draft candidates | `0092-glm-draft-candidates-checked` | the drafter checks each block pass's candidate ids against the vocabulary; on an id outside it (issue #80: a float's bits read as an id) it logs the value, copies the rows again once the device is idle, and fails only if they are still bad | a rare drafter `IndexError` is retried (and its cause logged) instead of killing a rank || Concurrent fill | `0062-glm-sliced-fill` | a new prompt's chunks run in layer slices (`FILL_BUDGET_MS`) with decode rounds between them, drafted as usual (`FILL_DRAFTS`), both ranks on the same layer boundaries; the chunk's buffers kept between slices, grouped fills, cache moves and cancellation mid-fill; whole forwards when nothing else decodes | with smooth streaming, the other replies' pauses during a 25k-token fill 630-690 ms -> 81-149 ms (table below) |Concurrent prompt fill and smooth streaming on two Sparks (`PARALLEL=4`, DFlash2, 1,024-row chunks): three 400-tokendiff --cc patches/0092-glm-draft-candidates-checked.patchindex 0000000,3aa1c56..3aa1c56mode 000000,100644..100644--- a/patches/0092-glm-draft-candidates-checked.patch+++ b/patches/0092-glm-draft-candidates-checked.patch