GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold
Python
v1.7: ABLIT=1 serves the gated Ablit weights; HF_TOKEN required, checked before setup and download
MiaAI-Labcf040ae11e35
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6afed27..aee9412 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,19 @@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.7 (2026-10-05): the Ablit weights (`ABLIT=1`, gated: needs `HF_TOKEN`)++Image: `v0.6.0-c4cab25d2d36` (`sha256:b47c19d66633f27cbe37da13fbc580363f466c08b9529feab1eecb1a4b904bf1`), 75 patches, for two and three Sparks (unchanged from v1.6).++### Added+- **`ABLIT=1` serves the Ablit weights**,+ [Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit](https://huggingface.co/Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit)+ (pinned at `57edefd2`), instead of the published checkpoint; set it in `scripts/local.sh` (now in `local.sh.example`) or `.env`.+ The repository is gated: `start.sh`, `start-tp3.sh` and `prepare.sh` stop when `HF_TOKEN` is not set and say how to+ get one and accept the terms on the model's page, and `prepare.sh` checks that the token reaches the gated files+ before the image and the download (README: Ablit weights), without putting the token on a command line. `HF_TOKEN`+ set in `scripts/local.sh` is now exported to the download.+## v1.6 (2026-10-05): agent sessions keep their history (beside sub-agents and under a full pool), queued requests whose client left are dropped, no raw `<|assistant|>` in replies, the display reservation in the pool, a longer RoCE wait, SPLIT retried at startImage: `v0.6.0-c4cab25d2d36` (`sha256:b47c19d66633f27cbe37da13fbc580363f466c08b9529feab1eecb1a4b904bf1`), 75 patches, for two and three Sparks.diff --git a/README.md b/README.mdindex 30527f5..8fa4c64 100644--- a/README.md+++ b/README.md@@ -112,7 +112,7 @@ Details on the [model card](https://huggingface.co/Mia-AiLab/GLM-5.3-Flash-EXL3-and checks the worker for what the copy must send. With `WORKER_WEIGHTS=nfs` the worker needs only the image([Worker weights over NFS](#worker-weights-over-nfs)).- Optional: the `hf` CLI on the head (faster download) and a Hugging Face token (`~/.cache/huggingface/token` or- `HF_TOKEN`).+ `HF_TOKEN`). `HF_TOKEN` is required for the gated Ablit weights (`ABLIT=1`, [Ablit weights](#ablit-weights)).## Quick start@@ -308,6 +308,30 @@ checks that the worker sees every file of both snapshots as the head has them, iexported path as the worker mounts it (default: the head's `HF_CACHE`; `/` for an NFSv4 export with `fsid=0`), and`NFS_SERVER` the head's address (default: its address on the link).+## Ablit weights++`ABLIT=1` serves+[Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit](https://huggingface.co/Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit)+instead of the published checkpoint: the same checkpoint, abliterated, at the revision pinned in `scripts/config.sh`.+Everything else (drafts, the window, NFS, 3 Sparks) works the same. The repository is gated:++1. Open [its page on Hugging Face](https://huggingface.co/Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit), log in and+ agree to its terms.+2. With the same account, create a token with read access at <https://huggingface.co/settings/tokens>.+3. Set both in `scripts/local.sh` (or `.env`, unless `scripts/local.sh` sets `ABLIT` too: it wins), and run `./start.sh restart` (`./start-tp3.sh restart` on 3 Sparks):++ ```bash+ ABLIT=1+ HF_TOKEN=hf_...+ ```++Without `HF_TOKEN`, `start.sh`, `start-tp3.sh` and `prepare.sh` stop at once and say what to do. Before the image+and the download, `prepare.sh` also checks that the token reaches the gated files: a `401` means Hugging Face does not+accept the token, a `403` that its account has not agreed to the terms yet (or that a fine-grained token lacks read+access to public gated repositories). The first start downloads the Ablit checkpoint (~176 GB, beside the+published one in the cache) and, with `WORKER_WEIGHTS=copy`, copies it to the worker. `ABLIT=0` goes back to the+published checkpoint, which stays in the cache.+## 3 Sparks (experimental)`./start-tp3.sh` runs the same recipe as tensor parallel over three Sparks (`TP=3` with `./start.sh`'s options;@@ -415,6 +439,7 @@ sets a value wins: the environment, then `scripts/local.sh`, then `.env`, then t| `KV_POOL_GIB` / `MEMORY_RESERVE_GIB` | `12.5` (`32` at `TP=3`) / `14.5`, plus ~0.95 a request past 4 and ~0.04 a window row past 32 (`19.6` at 8 requests and 64 rows) | 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 under a 1M-token prompt); it grows with `PARALLEL` because more requests at once take more than the startup estimate counts; raise it when other work shares the Sparks || `DISPLAY_KV_MIB` | `0` (off) | MiB of the GPU's display reservation added to the shared pool on every rank (patch 0072, `PARALLEL` above 1; a multiple of 16 up to 2032, 1792 measured): pool tokens without host memory, on top of `KV_POOL_GIB`; needs `/dev/dri/card0`; headless Sparks only (refused while a display is connected) || `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 |+| `ABLIT` | `0` | `1`: serve the gated [Ablit weights](https://huggingface.co/Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit) instead of the published checkpoint; needs `HF_TOKEN` and the terms accepted on the model's page ([Ablit weights](#ablit-weights)) || `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 || `TF_GLM_ASSISTANT_ENDS` | `1` | `<\|assistant\|>` ends a reply, like `<\|user\|>` and `<\|observation\|>` (patch 0075, issue #60); `0`: only the checkpoint's own end tokens |@@ -599,7 +624,7 @@ with [sparkDash](https://github.com/MiaAI-Lab/sparkDash) ([Performance](#performstart.sh set up (first run) and start both ranksstart-tp3.sh the same on three Sparks (experimental, patches 0066-0068)stop.sh stop them-scripts/ config.sh (all settings), local.sh.example (this setup's WORKER), prepare.sh (image + checkpoint on+scripts/ config.sh (all settings), local.sh.example (this setup's WORKER, ABLIT), prepare.sh (image + checkpoint onboth Sparks), nodes.sh (ssh and the RoCE links), publish-image.sh (push the image to GHCR),banner.sh (start.sh's banner)patches/ patches baked into the imagediff --git a/scripts/config.sh b/scripts/config.shindex ad5bc52..7e64984 100644--- a/scripts/config.sh+++ b/scripts/config.sh@@ -47,13 +47,22 @@ fiMASTER_ADDR="${MASTER_ADDR:-$_ma}"SOCKET_IFNAME="${SOCKET_IFNAME:-}"-MODEL_ID="${MODEL_ID:-Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold}" # EXL3 routed experts (4 bpw), BF16 elsewhere+# ABLIT=1 serves the Ablit weights, Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit (the same checkpoint,+# abliterated; README "Ablit weights"), instead of the published checkpoint; 0 (default) the published one. The Ablit+# repository is gated: HF_TOKEN must be set (a Hugging Face access token whose account accepted the terms on the+# model's page), or prepare.sh, start.sh and start-tp3.sh stop and say so. Switching downloads the other checkpoint+# (~176 GB).+ABLIT="${ABLIT:-0}"+ABLIT_ID="Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit"+_id="Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold"; [[ "$ABLIT" == 1 ]] && _id=$ABLIT_ID+MODEL_ID="${MODEL_ID:-$_id}" # EXL3 routed experts (4 bpw), BF16 elsewhere# The checkpoint's revision (a Hugging Face commit sha; DFLASH2_REVISION below is DFlash2's): the one this recipe was# measured with. prepare.sh downloads exactly it, start.sh serves that snapshot from the local cache (no network), and-# a new upstream commit changes nothing here until the pin does. Empty: the Hub's main when first downloaded. The pin-# belongs to the checkpoint above; another MODEL_ID gets no pin unless you set one.+# a new upstream commit changes nothing here until the pin does. Empty: the Hub's main when first downloaded. The pins+# belong to the checkpoints above; another MODEL_ID gets no pin unless you set one.case "$MODEL_ID" inMia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold) _rev=078455ffe6472f9a52fbc1139f58b9db2881b25c ;;+ Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit) _rev=57edefd2f5d9b371c8345883304d5af68b52fa24 ;;*) _rev="" ;;esacMODEL_REVISION="${MODEL_REVISION-$_rev}"@@ -298,6 +307,18 @@ log() { printf '%s[%s]%s %s\n' "$(_c 1 '1;36')" "$(basename "$0")" "$(_c 1 0)"warn() { printf '%s[%s] WARN:%s %s\n' "$(_c 2 '1;33')" "$(basename "$0")" "$(_c 2 0)" "$*" >&2; }die() { printf '%s[%s] ERROR:%s %s\n' "$(_c 2 '1;31')" "$(basename "$0")" "$(_c 2 0)" "$*" >&2; exit 1; }+# HF_TOKEN from scripts/local.sh reaches the hf CLI and the download container only when exported+[[ -z "${HF_TOKEN:-}" ]] || export HF_TOKEN+# need_hf_token: stop before anything else when the checkpoint is the gated Ablit one (ABLIT=1) and HF_TOKEN is not set+need_hf_token() {+ [[ "$ABLIT" =~ ^[01]$ ]] || die "ABLIT is 0 or 1, not $ABLIT"+ [[ "$MODEL_ID" == "$ABLIT_ID" && -z "${HF_TOKEN:-}" ]] || return 0+ die "The Ablit weights ($ABLIT_ID, ABLIT=1) are gated on Hugging Face.+ 1. Open https://huggingface.co/$ABLIT_ID, log in and agree to its terms.+ 2. Create a token with read access at https://huggingface.co/settings/tokens (the same account).+ 3. Set HF_TOKEN=hf_... in scripts/local.sh, in .env or in the environment, and run this again.+ Or set ABLIT=0 to serve the published checkpoint."+}model_cache_dir() { local id=${1:-$MODEL_ID}; echo "$HF_CACHE/hub/models--${id//\//--}"; }# model_revision <id>: the pinned revision of MODEL_ID or DFLASH2_ID (empty: none, the cache's refs/main counts)model_revision() { if [[ "$1" == "$MODEL_ID" ]]; then echo "$MODEL_REVISION"; elif [[ "$1" == "$DFLASH2_ID" ]]; then echo "$DFLASH2_REVISION"; fi; }diff --git a/scripts/local.sh.example b/scripts/local.sh.exampleindex 02236cb..b612c7d 100644--- a/scripts/local.sh.example+++ b/scripts/local.sh.example@@ -5,3 +5,5 @@ [email protected] # ssh target of the second Spark (key-based: ssh-# [email protected] # rank 2# WORKER_WEIGHTS2=nfs # per worker: copy or nfs (default: WORKER_WEIGHTS)# WORKER_HF_CACHE2=/models/hf # per worker: its Hugging Face cache when it is not its HF_HOME+# ABLIT=1 # the gated Ablit weights instead (README "Ablit weights"); needs HF_TOKEN below+# HF_TOKEN=hf_... # a Hugging Face read token whose account agreed to the Ablit model's termsdiff --git a/scripts/prepare.sh b/scripts/prepare.shindex fe0d364..f3e5891 100755--- a/scripts/prepare.sh+++ b/scripts/prepare.sh@@ -1,6 +1,7 @@#!/usr/bin/env bash-# Prepare both Sparks to serve Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold with TensorFold (two ranks; with TP=3,-# both workers the same way, each per its own WORKER_WEIGHTS / WORKER_WEIGHTS2):+# Prepare both Sparks to serve Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold (with ABLIT=1, the gated+# Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold-Ablit, which needs HF_TOKEN) with TensorFold (two ranks; with TP=3, both+# workers the same way, each per its own WORKER_WEIGHTS / WORKER_WEIGHTS2):# 1. preflight checks: docker and the GPU on both nodes, key-based ssh to the worker, the RoCE link, disk space# 2. the image on the head: TensorFold plus patches/*.patch on NVIDIA's PyTorch container, pulled prebuilt from# $GHCR_IMAGE when a matching tag is reachable (PULL=0 skips that), else built locally@@ -25,6 +26,7 @@ for arg in "$@"; do*) die "unknown argument: $arg" ;;esacdone+need_hf_token # ABLIT=1 (gated weights) without HF_TOKEN: say so before anything else# ---------------------------------------------------------------- 1. preflightmkdir -p "$KERNEL_CACHE" "$STATE_DIR" "$HF_CACHE/hub"@@ -32,6 +34,26 @@ exec 9>"$STATE_DIR/prepare.lock"flock -n 9 || die "another prepare.sh is already running (it holds the download locks); wait for it or stop it: pgrep -af prepare.sh"SPARKS="both Sparks"; (( TP == 2 )) || SPARKS="all $TP Sparks"log "Preflight checks on $SPARKS"+# The gated Ablit weights (ABLIT=1): HF_TOKEN must reach their files, which takes the token's account having accepted+# the terms on the model's page. Asked for one small file before the image work, so a refusal says why at once instead+# of failing the download later. The header goes to curl on stdin, keeping the token out of the process list. No+# answer from the Hub (offline): left to the download, which falls back on a snapshot already here.+if [[ "$MODEL_ID" == "$ABLIT_ID" ]]; then+ _url="https://huggingface.co/$MODEL_ID/resolve/${MODEL_REVISION:-main}/config.json"+ code=$(printf 'Authorization: Bearer %s\n' "$HF_TOKEN" |+ curl -s -o /dev/null -w '%{http_code}' --max-time 20 -H @- "$_url" || true)+ case "$code" in+ 2??|3??) log "HF_TOKEN reaches the gated $MODEL_ID" ;;+ 401) die "Hugging Face does not accept HF_TOKEN (401): $MODEL_ID is gated; create a token with read access at+ https://huggingface.co/settings/tokens and set HF_TOKEN=hf_... in scripts/local.sh, .env or the environment" ;;+ 403) die "HF_TOKEN may not read $MODEL_ID yet (403): it is gated; open https://huggingface.co/$MODEL_ID, log in+ with the token's account and agree to its terms (a fine-grained token also needs read access to public gated+ repositories), then run this again" ;;+ 404) die "Hugging Face has no $MODEL_ID @ ${MODEL_REVISION:-main} (404): check MODEL_REVISION" ;;+ 000) warn "could not reach Hugging Face to check HF_TOKEN against the gated $MODEL_ID; trying the download" ;;+ *) warn "Hugging Face answered HTTP $code when checking HF_TOKEN against the gated $MODEL_ID; trying the download" ;;+ esac+ficommand -v docker >/dev/null || die "docker is not installed"command -v rsync >/dev/null || die "rsync is not installed on this node (sudo apt install rsync)"docker info >/dev/null 2>&1 || die "cannot talk to the docker daemon (is your user in the docker group?)"diff --git a/start.sh b/start.shindex 573aab1..abb4428 100755--- a/start.sh+++ b/start.sh@@ -23,13 +23,15 @@# MEMORY_RESERVE_GIB, MAX_TOKENS, THINKING, VISION, VISION_URLS, COMM, SERVED_NAME, HOST, PORT# nodes WORKER, FABRIC_PEER, WORKER_HF_CACHE, MASTER_PORT, NCCL_RAILS (1: one RoCE device), NCCL_CHANNELS,# NCCL_DEBUG; TP (2), WORKER2, FABRIC_PEER2, WORKER_HF_CACHE2, MASTER_ADDR, SOCKET_IFNAME (3 Sparks)-# files MODEL_ID, MODEL_REVISION, DFLASH2_ID, DFLASH2_REVISION, HF_CACHE (default: HF_HOME), KERNEL_CACHE,+# files ABLIT (1: the gated Ablit weights, needs HF_TOKEN), MODEL_ID, MODEL_REVISION, DFLASH2_ID, DFLASH2_REVISION,+# HF_CACHE (default: HF_HOME), KERNEL_CACHE,# WORKER_WEIGHTS (copy | nfs: rank 1 reads the head's HF_CACHE over NFS), NFS_PATH, NFS_SERVER, NFS_VOLUME,# WORKER_WEIGHTS2, NFS_SERVER2,# STATE_DIR, HF_HUB_OFFLINE=0 (let TensorFold reach the Hub; default serves from the local cache only)# image IMAGE, TF_VERSION, TF_REPO, BASE_IMAGE, GHCR_IMAGE, IMAGE_TAG / IMAGE_DIGEST (the pinned published# image), CONTAINER_NAME-# setup PREPARE (auto | 1 | 0), PULL, MIN_FREE_GB, IMAGE_FREE_GB, RSYNC_OPTS, HF_TOKEN (prepare.sh's downloads);+# setup PREPARE (auto | 1 | 0), PULL, MIN_FREE_GB, IMAGE_FREE_GB, RSYNC_OPTS, HF_TOKEN (prepare.sh's downloads;+# required with ABLIT=1);# FOREGROUND=1 (stay attached to rank 0's log, exit with its code); WAIT_TIMEOUT (seconds, default 1800);# DRY_RUN=1 (print the docker commands, change nothing);# STOP_TIMEOUT (stop.sh); LOG_DIR, LOG_KEEP (saved server logs)@@ -51,6 +53,7 @@ case "${1:-}" inhelp) usage; exit 0 ;;esacfor arg in "$@"; do [[ "$arg" == -h || "$arg" == --help ]] && { usage; exit 0; }; done+need_hf_token # ABLIT=1 (gated weights) without HF_TOKEN: say so before anything else# The serve arguments both ranks share: scripts/config.sh's defaults first, then the command line's (argparse keeps# the last value). --drafter goes in front after the setup step, which knows DFlash2's snapshot.