Skip to content

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

Python

v1.3.1: TF_GLM_MULTI_LONE default 0 (#12, #13); CX7 address auto-detect (#9); xet blob copy (#15)

MiaAI-Lab475c7fd72599
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b99b2e7..6589697 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,15 +3,29 @@
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.1 (2026-10-01): mixed Docker image stores
+## v1.3.1 (2026-10-01): prompt cache in interactive sessions, setup fixes
Image unchanged: `v0.6.0-ae8d1c789b47`.
+### Changed
+- **`TF_GLM_MULTI_LONE` now defaults to 0** (#12, #13). With 1, a request decoding alone moved to the pool's first rows
+ for the one-stream graphs and evicted the other conversations' kept prompts there, so conversations taking turns
+ re-read their whole histories. Measured with three conversations taking turns (~4.5k tokens each, 6 warm turns):
+ 0% of the prompts came from the cache with 1, 98.1% with 0. The one-stream graphs gave +0.6-0.9% at 1 stream; `1`
+ still turns them on. Reported by @abhicnv007 and @kky42.
+
### Fixed
+- **#9, `prepare.sh` picked the LAN port when `WORKER` is a LAN address.** When the route to the worker leaves through
+ a port without RoCE and `FABRIC_PEER` is unset, the worker's CX7 address that a local CX7 port reaches directly is
+ now found and used (logged). Reported by @ttnghia.
+- **#15, the weight copy to the worker missed files downloaded with huggingface_hub's xet backend:** their blobs are
+ links into the cache root's `blobs/`, outside the copied folder. The copy now follows those links. Reported by
+ @huitseeker.
- **#8, `prepare.sh` failed on every run when the two Sparks use different Docker image stores** (containerd on one,
overlay2 on the other): it compared image `.Id`s, which is the manifest digest under containerd and the config
digest under overlay2, so the same image never matched. Images are now compared by content (their layers' diffIDs
- and runtime config), the same under both stores. Fix by @eleata, confirmed by @kafej.
+ and runtime config), the same under both stores. Fix by @eleata, confirmed by @kafej; also reported in #14 by
+ @huitseeker.
## v1.3 (2026-10-01): TensorFold v0.6.0, issue fixes #2 and #6, whole tool calls
diff --git a/README.md b/README.md
index 23412f8..29da158 100644
--- a/README.md
+++ b/README.md
@@ -298,7 +298,7 @@ sets a value wins: the environment, then `scripts/local.sh`, then `.env`, then t
| `TF_GLM_EXL3_LOADS` | `nc` | the decode expert kernel's trellis as 16-byte non-coherent loads a step ahead (`nc2` / `nc4`: 2 or 4 steps); `0`: TensorFold's 32-bit loads |
| `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` | `1` | with `PARALLEL` above 1, a request decoding alone runs on the one-stream graphs; `0`: on the batched ones |
+| `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 |
| `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 |
@@ -378,7 +378,7 @@ applied with `patch -p0` in filename order); `start.sh` rebuilds or re-pulls the
| Link | `0006-cuda-roce-allgather`, `0052-cuda-roce-startup` | the small all-gathers as one-shot RDMA writes over RoCE (`COMM=roce`; up to 512 KiB, `TF_ROCE_MAX_KB`: code at 4 streams +1.4%); until the engine is built, each eager gather first waits for the peer in an NCCL barrier, and the RoCE kernel builds during setup (`TF_ROCE_WAIT_S`, default 20 s; errors print the proxy's counters); an idle rank 1 waiting on a socket is TensorFold v0.6.0's (#132) | 11 us a 16 KiB gather against NCCL's 45, decode +6%; an idle server holds no GPU or CPU core; a first start whose ranks drift apart while building kernels no longer fails |
| Drafts | `0007-glm-copy-drafts`, `0032-glm-code-copy-drafts`, `0018-glm-noise-policies`, `0021-glm-dflash-policy-env`, `0025-glm-dflash2-ring` | copy (prompt-lookup) drafts ahead of DFlash2's (`COPY`, `COPY_CODE`); DFlash2 stop rules aware of the sampling noise (`DRAFT_POLICY`); kept prompt states' DFlash2 window with shared prefixes (the ring itself and `TF_GLM_MTP` are TensorFold v0.6.0's; the recipe sets `TF_GLM_MTP=auto`, so the MTP head is not loaded when DFlash2 drafts) | `COPY`: quote / edit replies 80.3 -> 84.4 tok/s; `COPY_CODE`: code 55.4 -> 56.2, edit 120 -> 125; `DRAFT_POLICY` over `fc5:0.3`: prose 47.2 -> 50.6 tok/s, code 51.7 -> 55.5; memory for the window |
| Drafts, tooling | `0011-glm-draft-sim` | records of DFlash2's drafts for an offline simulator of stop rules (`TF_GLM_DRAFT_DUMP`, off) | how the stop rules were tuned |
-| Concurrent requests | `0026-glm-multi-kda`, `0027-glm-multi-dflash2`, `0029-glm-multi-dsa`, `0030-glm-multi-stream-engine`, `0035-glm-multi-rounds`, `0040-glm-parallel-deadlocks`, `0041-glm-parallel-ring-base`, `0048-glm-timing-tokens`, `0049-glm-multi-prefill` | several streams over one shared pool of per-token caches, one batched verify window a round, both ranks kept in step; prompts that arrive together filled in one forward (`MULTI_PREFILL`: 4 prose requests at once 103.4 -> 108.8 tok/s, first token 590 -> 340 ms); a request alone on the one-stream graphs (`TF_GLM_MULTI_LONE`: +0.6-0.9%); the startup timings of verify windows on distinct tokens | 4 requests at once ([Performance](#performance)) |
+| Concurrent requests | `0026-glm-multi-kda`, `0027-glm-multi-dflash2`, `0029-glm-multi-dsa`, `0030-glm-multi-stream-engine`, `0035-glm-multi-rounds`, `0040-glm-parallel-deadlocks`, `0041-glm-parallel-ring-base`, `0048-glm-timing-tokens`, `0049-glm-multi-prefill` | several streams over one shared pool of per-token caches, one batched verify window a round, both ranks kept in step; prompts that arrive together filled in one forward (`MULTI_PREFILL`: 4 prose requests at once 103.4 -> 108.8 tok/s, first token 590 -> 340 ms); a request alone on the one-stream graphs (`TF_GLM_MULTI_LONE=1`, off by default since v1.3.1: +0.6-0.9%); the startup timings of verify windows on distinct tokens | 4 requests at once ([Performance](#performance)) |
| Sampling | `0034-cuda-nucleus-union` | a top_p draw from both ranks' candidates together, the same draw with fewer whole-shard reads (`TENSORFOLD_NUCLEUS_UNION=1`, off by default) | opt-in |
| Server | `0003-glm-vision`, `0050-glm-many-media`, `0036-glm-tool-calls`, `0051-glm-tool-history-recovery`, `0053-glm-whole-tool-calls`, `0037-cuda-tokenize`, `0023-server-effort-max`, `0044-cuda-context-errors`, `0045-cuda-metrics` | GLM's image and video processors and vision tower; up to 50 pictures and 4 clips a request in 96 MiB bodies; GLM tool calls for agent clients; a past tool call whose arguments are not a JSON object left out of the prompt with its result and logged, instead of HTTP 400 (agents replay history, so a 400 ended the conversation); each call sent whole once written, a call the reply ends inside never sent; `/tokenize` and `/detokenize`; `reasoning_effort: "max"`; the `param` field and GLM's own refusals on TensorFold v0.6.0's `context_length_exceeded` errors, and `/health`'s figures in its Prometheus `/metrics` | the API features above |
diff --git a/scripts/config.sh b/scripts/config.sh
index 65c1728..796c44f 100644
--- a/scripts/config.sh
+++ b/scripts/config.sh
@@ -146,9 +146,11 @@ export TF_GLM_KDA_CHUNKED="$KDA_CHUNKED"
COPY_CODE="${COPY_CODE:-1}"
_w=0; [[ "$COPY_CODE" == 1 ]] && _w=16
export TF_GLM_WIDE_GRAPHS="$_w" TF_GLM_COPY_REPLY_MATCH="$_w"
-# --parallel: a request alone runs on the one-stream graphs (patch 0035; 1, default) instead of the batched ones (0):
-# +0.6-0.9% at 1 stream (two boots each); replies served together still equal the same requests served alone. Exact.
-export TF_GLM_MULTI_LONE="${TF_GLM_MULTI_LONE:-1}"
+# --parallel: a request alone runs on the one-stream graphs (patch 0035; 1) instead of the batched ones (0, default):
+# +0.6-0.9% at 1 stream, but to use them the stream moves to the pool's first rows and evicts the other conversations'
+# 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}"
# 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
diff --git a/scripts/nodes.sh b/scripts/nodes.sh
index 0bcdd23..24265fa 100644
--- a/scripts/nodes.sh
+++ b/scripts/nodes.sh
@@ -87,10 +87,29 @@ worker_link_info() { worker "$(declare -f link_info); link_info $1"; }
# HEAD_ADDR / HEAD_DEV / HEAD_HCA / HEAD_GID and WORKER_ADDR / WORKER_DEV / WORKER_HCA / WORKER_GID: the link the two
# ranks talk over (NCCL and the rendezvous). FABRIC_PEER overrides the worker's link address when WORKER is reached
# over another network.
+# cx7_peer: the worker's address on a CX7 port that one of this node's CX7 ports reaches directly (same subnet, no
+# gateway), for a WORKER given by its LAN address (issue #9). Empty when there is none.
+cx7_peer() {
+ local a route dev
+ for a in $(worker 'for d in /sys/class/net/*; do [ -d "$d/device/infiniband" ] && ip -o -4 addr show dev "${d##*/}"; done' 2>/dev/null |
+ awk '{print $4}' | cut -d/ -f1); do
+ route=$(ip -o -4 route get "$a" 2>/dev/null) || continue
+ [[ "$route" == *" via "* ]] && continue
+ dev=$(sed -n 's/.* dev \([^ ]*\).*/\1/p' <<<"$route")
+ [[ -d /sys/class/net/$dev/device/infiniband ]] && { echo "$a"; return 0; }
+ done
+ return 1
+}
detect_link() {
- local peer=${FABRIC_PEER:-${WORKER#*@}}
+ local peer=${FABRIC_PEER:-${WORKER#*@}} cx7
read -r HEAD_ADDR HEAD_DEV HEAD_HCA HEAD_GID <<<"$(link_info "$peer")" || true
[[ -n "${HEAD_ADDR:-}" ]] || die "no route from this node to $peer"
+ # WORKER given by a LAN address (the route goes out a port without RoCE): use the worker's CX7 address instead
+ if [[ -z "${FABRIC_PEER:-}" && "${HEAD_HCA:--}" == "-" ]] && cx7=$(cx7_peer); then
+ log "$peer is reached over $HEAD_DEV, not a CX7 port: using the worker's CX7 address $cx7 for the link (FABRIC_PEER)"
+ peer=$cx7
+ read -r HEAD_ADDR HEAD_DEV HEAD_HCA HEAD_GID <<<"$(link_info "$peer")" || true
+ fi
read -r WORKER_ADDR WORKER_DEV WORKER_HCA WORKER_GID <<<"$(worker_link_info "$HEAD_ADDR")" || true
[[ -n "${WORKER_ADDR:-}" ]] || die "the worker has no route back to $HEAD_ADDR"
# both CX7 ports when both are cabled and addressed: a prompt chunk's all-gather is ~1.8x faster on two rails
diff --git a/scripts/prepare.sh b/scripts/prepare.sh
index 00fba4f..37b6a16 100755
--- a/scripts/prepare.sh
+++ b/scripts/prepare.sh
@@ -194,7 +194,8 @@ for id in "${models[@]}"; do
worker "mkdir -p '$wdir/refs' '$wdir/snapshots'"
# the blobs this revision uses, then its snapshot links and refs/main (the cache layout huggingface_hub keeps)
(cd "$dir" && find "snapshots/$rev" -type l -printf '%l\n' | sed 's#^\(\.\./\)*##' | sort -u) > "$STATE_DIR/blobs"
- rsync -a --partial --files-from="$STATE_DIR/blobs" "$dir/" "$WORKER:$wdir/" \
+ # -L: a blob may itself be a link into the cache root's blobs/ (huggingface_hub's xet backend, issue #15)
+ rsync -a -L --partial --files-from="$STATE_DIR/blobs" "$dir/" "$WORKER:$wdir/" \
-e "ssh -o BatchMode=yes" ${RSYNC_OPTS:-}
rsync -a "$dir/snapshots/$rev" "$WORKER:$wdir/snapshots/" -e "ssh -o BatchMode=yes"
# refs/main as the head has it (with a pin: only when the worker has none)