GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold
Python
v1.3.2: TF_GLM_CACHE_ENTRIES 32 (#17); non-English note for DENSE=q4 (#18); kv_b docs
MiaAI-Lab1770e7425ffa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6589697..e55214b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,23 @@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`.+## v1.3.2 (2026-10-01): more kept prompts, a note on non-English prompts++Image unchanged: `v0.6.0-ae8d1c789b47`.++### Changed+- **`TF_GLM_CACHE_ENTRIES` 8 -> 32** (#17): the engine kept at most 8 prompt states and dropped the oldest past that,+ however much of the pool was free. An agent request keeps 1 to 3 (its own state plus shared-prefix states), so three+ or four alternating agent conversations pushed each other out. Each entry reserves ~45 MiB at start, ~1 GiB more in+ all. Reported, with measurements, by @sm373373. The setting is now documented.++### Docs+- **`DENSE=q4` and non-English prompts** (#18): on short French coding prompts `q4` often loses the end of turn and+ runs to `max_tokens` (12 of 48 replies, against 1 of 48 with `bf16` or `fp8`); the README says so and points to+ `DENSE=fp8`. A calibrated 4-bit for the dense weights, at `q4`'s speed, is being worked on. Reported, with+ measurements, by @Alexbob0.+- `DENSE=q4` keeps `kv_b` in BF16 (the docs said FP8).+## v1.3.1 (2026-10-01): prompt cache in interactive sessions, setup fixesImage unchanged: `v0.6.0-ae8d1c789b47`.diff --git a/README.md b/README.mdindex 29da158..dcaf512 100644--- a/README.md+++ b/README.md@@ -281,7 +281,7 @@ sets a value wins: the environment, then `scripts/local.sh`, then `.env`, then t| `KV` | `fp8` | `fp8` or `bf16` (exact, shorter window) DSA latent cache and indexer keys || `WORKER_WEIGHTS` | `copy` | `copy`: the worker keeps its own copy of the weights; `nfs`: it reads the head's over NFS ([Worker weights over NFS](#worker-weights-over-nfs)); with `NFS_PATH`, `NFS_SERVER`, `NFS_VOLUME` || `KV_POOL_GIB` / `MEMORY_RESERVE_GIB` | `12.5` / `14.5` | the shared pool beyond the window (kept prompts, more long conversations at once) grows into what is free at start minus the reserve, up to `KV_POOL_GIB` GiB a Spark; the reserve sets the lowest free memory on the head (~4.5-5 GiB); raise it when other work shares the Sparks |-| `DENSE` | `q4` | the checkpoint's BF16 weights (attention, shared experts, dense layers, head): `q4` (4-bit groups of 64, head and kv_b in FP8), `fp8` or `bf16` |+| `DENSE` | `q4` | the checkpoint's BF16 weights (attention, shared experts, dense layers, head): `q4` (4-bit groups of 64, the head in FP8, kv_b in BF16), `fp8` or `bf16`. **Non-English prompts:** `q4` can lose the end of turn on short French coding prompts (replies run to `max_tokens`, issue #18); `fp8` keeps it, at ~10% decode speed || `DRAFTER` | `dflash2` | `dflash2`: IncoAI's DFlash2 drafter, licensed [CC BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/), **non-commercial use only**; +5-10% decode. `mtp`: the checkpoint's own MTP head, one request at a time, which avoids that license (set it before the first `./start.sh` and DFlash2 is never downloaded) || `TF_GLM_MTP` | `auto` | the checkpoint's MTP head beside DFlash2: `auto` leaves it out while DFlash2 drafts every request; `1` (TensorFold v0.6.0's own default) loads it, 1.77 GiB a Spark, with `PARALLEL=1`. `DRAFTER=mtp` always loads it || `DRAFT_POLICY` | `fnc7:0.3` | how many DFlash2 drafts a round verifies: up to 7, until the drafts' chance under the request's own sampling noise drops below 0.3 |@@ -299,6 +299,7 @@ sets a value wins: the environment, then `scripts/local.sh`, then `.env`, then t| `TF_ROCE_MAX_KB` | `512` | the largest all-gather (KiB) sent over RoCE with `COMM=roce` (TensorFold's default: 256); 512 covers the 17-32-row verify windows of concurrent requests || `TF_ROCE_WAIT_S` | `20` | seconds a RoCE all-gather waits for the other Spark before it fails (1 to 3600); until the engine is built, each gather first meets the peer in an NCCL barrier, so a long first start (kernels compiling) does not run into it || `TF_GLM_MULTI_LONE` | `0` | `1`: with `PARALLEL` above 1, a request decoding alone runs on the one-stream graphs (+0.6-0.9%), but its move to the pool's first rows evicts other conversations' kept prompts there (issues #12, #13); `0`: on the batched ones |+| `TF_GLM_CACHE_ENTRIES` | `32` | kept prompt states at most (TensorFold's default is 8); the oldest goes past this count, however much of the pool is free. An agent request keeps 1 to 3 (issue #17); each costs ~45 MiB at start || `MULTI_PREFILL` | `1` | prompts that arrive together are filled in one forward (each with the bits it gets alone); `0`: one after another || `SERVED_NAME` / `PORT` / `HOST` | `GLM-5.3-Flash-EXL3` / `8888` / `0.0.0.0` | the model id in `/v1/models` and replies; where the API listens || `TENSORFOLD_GLM_IMAGE_TOKENS` / `_VIDEO_TOKENS` / `_VIDEO_FRAMES` | `2048` / `16384` / `128` | a picture's and a clip's token caps, and a clip's frames |diff --git a/scripts/config.sh b/scripts/config.shindex 796c44f..4d72089 100644--- a/scripts/config.sh+++ b/scripts/config.sh@@ -100,7 +100,7 @@ THINKING="${THINKING:-1}"# as Codex sets none). A request's own value wins; this one is cut to what the window has left, never refused.MAX_TOKENS="${MAX_TOKENS:-32768}"# The checkpoint's BF16 weights (attention, shared experts, dense layers, head: ~9.7 GiB a Spark):-# q4 (default): the projections as affine 4-bit groups of 64 with MSE-searched ranges, the head and kv_b in FP8+# q4 (default): the projections as affine 4-bit groups of 64 with MSE-searched ranges, the head in FP8 (kv_b stays BF16: TF_GLM_KVB)# (patches 0002, 0005). Over fp8 (DFlash2, one boot each): prose 38.9 -> 44.4 tok/s, code 44.2 -> 48.7, prefill# ~1,090 -> ~1,260 tok/s; GSM8K 98.0% and HumanEval 95.1% on both (bf16: 97.2 / 96.3). Lossy: replies differ.# fp8: FP8 e4m3 with a scale per row and 128 columns (patch 0002), half bf16's bytes: ~+33% decode over bf16.@@ -151,6 +151,11 @@ export TF_GLM_WIDE_GRAPHS="$_w" TF_GLM_COPY_REPLY_MATCH="$_w"# kept prompts there, so interactive sessions miss the prompt cache and re-read whole histories (issues #12, #13).# Off by default until that move keeps them. Exact either way.export TF_GLM_MULTI_LONE="${TF_GLM_MULTI_LONE:-0}"+# Kept prompt states (TensorFold's TF_GLM_CACHE_ENTRIES, 8 by default): the oldest is dropped past this count, however+# much of the pool is free. A drafted agent request keeps 1 to 3 (its own plus shared-prefix states), so 8 let three+# or four alternating conversations push each other out (issue #17). Each entry reserves its fixed state (~45 MiB) at+# start: 32 takes ~1 GiB more than 8.+export TF_GLM_CACHE_ENTRIES="${TF_GLM_CACHE_ENTRIES:-32}"# Waiting prompts filled together in one forward (patch 0049): shared work (expert weights, glue, projections) runs once# for every waiting prompt, attention per prompt on its own state, so each gets the bits it gets alone. sparkDash, prose at# 4 at once: 103.4 -> 108.8 tok/s, time to first token 590 -> 340 ms; structured at 3 / 4 at once: 175.2 -> 196.3 and