Skip to content

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

Python

v1.2: KV pool 12.5 GiB, WORKER_WEIGHTS=nfs, no EXL3 "experimental" note, bench.py removed

MiaAI-Labf5afcf33d6a2
diff --git a/.github/ISSUE_TEMPLATE/2_improvement.md b/.github/ISSUE_TEMPLATE/2_improvement.md
index 297f5c8..b44a90d 100644
--- a/.github/ISSUE_TEMPLATE/2_improvement.md
+++ b/.github/ISSUE_TEMPLATE/2_improvement.md
@@ -25,9 +25,8 @@ assignees: ""
* a default in scripts/config.sh that is wrong for most people
* a memory setting that is too conservative or does not fit
* a patch that no longer applies to a newer TensorFold release
- * startup time (weights load in ~6 min on each Spark; the first start also
+ * startup time (weights load in 2 to 6 min on each Spark; the first start also
compiles kernels)
- * a benchmark in tools/ that measures the wrong thing
-->
## Proposed change
@@ -47,7 +46,7 @@ assignees: ""
* prefill tok/s and time to first token at several prompt sizes, and decode
tok/s for prose, code and edit replies at 1 to 4 concurrent requests,
- measured with tools/bench.py or sparkDash (https://github.com/MiaAI-Lab/sparkDash)
+ measured with sparkDash (https://github.com/MiaAI-Lab/sparkDash)
* rank 0's startup estimate from
`docker logs glm53-flash-tf | grep "startup estimate"`
* needle retrieval (tools/needle.py) PASS/FAIL
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index add112d..ed79842 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -39,7 +39,8 @@
site-packages)
* an actual launch on two Sparks, plus
`docker logs glm53-flash-tf 2>&1 | grep -E "startup estimate|serving"`
- * `tools/bench.py`, `tools/needle.py`, `tools/toolcheck.py` against the running server
+ * `tools/needle.py` and `tools/toolcheck.py` against the running server, and
+ sparkDash (https://github.com/MiaAI-Lab/sparkDash) for speed
* if behavior changed, the measured numbers with the new settings, stating
which configuration they came from (see README "Performance")
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a3316f..de9c827 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,36 @@
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.2 (2026-10-01): bigger KV pool, worker weights over NFS
+
+Image unchanged: `v0.5.0-cb7c56f7f921` (`sha256:6ee3c6e0430040b69ddcb0c96c7fbbcb94a5bed47d48a8ba092626369ae533b9`),
+53 patches.
+
+### Added
+- `WORKER_WEIGHTS=nfs`: the worker keeps no copy of the checkpoint and DFlash2 (~166 GiB less disk on it). Rank 1
+ reads the head's Hugging Face cache read-only over NFS, through a docker volume that `prepare.sh` creates on the
+ worker (no sudo there), after checking the worker sees every file of both snapshots as the head has them. The head
+ exports its cache once (README: Worker weights over NFS). Settings `NFS_PATH`, `NFS_SERVER`, `NFS_VOLUME`. The
+ default stays `copy`. Measured: both ranks live in ~2.2 minutes, as with a local copy.
+
+### Changed
+- `KV_POOL_GIB` 11 -> **12.5**: the shared KV pool is **2,852,864 tokens** at the measured start (was 2,684,928),
+ ~2.1-2.9M depending on what is free at start. Lowest free memory under a 1M-token prompt: 4.7 GiB on the head,
+ 8.8 GiB on the worker (was 6.3 / 10.8); idle 7.8 / 10.8 GiB.
+- `prepare.sh` and `start.sh` no longer show TensorFold's "EXL3 support is experimental" note: this recipe serves
+ the EXL3 checkpoint on purpose, and its replies are checked exact.
+
+### Removed
+- `tools/bench.py`. The recipe's performance numbers come from
+ [sparkDash](https://github.com/MiaAI-Lab/sparkDash), measured through the OpenAI API from another machine, so a
+ second benchmark in the repo only gave numbers that did not match the published ones. Its shared helpers (the
+ server URL, error messages, random prose) moved to `tools/client.py`; `tools/needle.py` and `tools/toolcheck.py`
+ stay as correctness checks.
+
+### Unchanged
+- Replies: the exactness checks (reference shas, drafted == serial 6/6, concurrency 22/22, images and videos, tool
+ calls) equal v1.1's, and the 1M-token needle is found (981,841 tokens, 967 s).
+
## v1.1 (2026-10-01): up to 50 images and 4 videos a request
Image `v0.5.0-cb7c56f7f921` (`sha256:6ee3c6e0430040b69ddcb0c96c7fbbcb94a5bed47d48a8ba092626369ae533b9`), 53 patches.
diff --git a/README.md b/README.md
index 6ca1c8e..4c60663 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ vision, tool calling, `/tokenize` and `/metrics`.
- Drafter: [`incoai/GLM-5.3-Flash-DFlash2`](https://huggingface.co/incoai/GLM-5.3-Flash-DFlash2), or the checkpoint's
own MTP head (`DRAFTER`, see [Configuration](#configuration))
- API model id: `GLM-5.3-Flash-EXL3`
-- Context: **1,048,576 tokens** a request; the 4 requests share an FP8 KV pool of about **2.7M tokens** (2,684,928 at the measured start)
+- Context: **1,048,576 tokens** a request; the 4 requests share an FP8 KV pool of about **2.9M tokens** (2,852,864 at the measured start)
- Tool calling, structured outputs (xgrammar), `/tokenize`, and `reasoning_effort` `low` / `high` / `max`
- One command on the first Spark: `./start.sh` sets up both Sparks and starts both ranks; `./stop.sh` stops them
@@ -86,7 +86,8 @@ of 11 sent in a burst).
- **Disk, on each Spark:** ~205 GB: ~176 GB (164 GiB) for the checkpoint and ~2.3 GB for DFlash2 under
`~/.cache/huggingface`, ~25 GB for the image under Docker's root. `prepare.sh` wants 180 GB free for the download
(`MIN_FREE_GB`) and 35 GB under Docker's root (`IMAGE_FREE_GB`; the sum when they share a filesystem), and checks the
- worker before the copy.
+ worker before the copy. 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`).
@@ -221,13 +222,13 @@ caches from **one shared pool**:
| Requests at once (`PARALLEL`) | 4 |
| Window per request (`CONTEXT`, the model's native maximum) | 1,048,576 tokens |
| KV precision (`KV`) | FP8 (e4m3 rows with a power-of-two scale each: half of bf16's bytes) |
-| **Shared pool** (what is free at start minus `MEMORY_RESERVE_GIB` 14.5, at most `KV_POOL_GIB` 11 GiB a Spark beyond the window) | **2,684,928 tokens** at the measured start (~2.1-2.7M depending on free memory) |
+| **Shared pool** (what is free at start minus `MEMORY_RESERVE_GIB` 14.5, at most `KV_POOL_GIB` 12.5 GiB a Spark beyond the window) | **2,852,864 tokens** at the measured start (~2.1-2.9M depending on free memory) |
| Rank 0's startup estimate | 88.09 GiB |
-| Free memory (`MemAvailable`) at idle | 8.2 GiB on rank 0, 11.8 GiB on rank 1 |
-| Lowest free memory under a 1M-token prompt | 6.3 GiB on rank 0, 10.8 GiB on rank 1 |
+| Free memory (`MemAvailable`) at idle | 7.8 GiB on rank 0, 10.8 GiB on rank 1 |
+| Lowest free memory under a 1M-token prompt | 4.7 GiB on rank 0, 8.8 GiB on rank 1 |
Any one request can grow to the full window, and the four together share the pool: e.g. one 1M-token conversation
-next to one more of 1M, or next to three of ~450k. A request the pool cannot place yet waits until others finish (kept prompt states give way
+next to one more of 1M, or next to three of ~600k. A request the pool cannot place yet waits until others finish (kept prompt states give way
first); `/health` shows `pool_tokens`, `pool_free_tokens` and the streams decoding, filling and paused.
TensorFold's budget on each Spark is `MemAvailable` at start minus a host reserve (`MEMORY_RESERVE_GIB`, 14.5 GiB here;
@@ -243,6 +244,27 @@ Other settings' windows:
| `KV=bf16 DRAFTER=mtp` | 524,288 | one request at a time |
| `CONTEXT=0` | the largest that fits | no memory is left to keep other conversations' prompts |
+## Worker weights over NFS
+
+By default the worker keeps its own copy of the checkpoint and DFlash2 (~166 GiB, copied over the link by
+`prepare.sh`). With `WORKER_WEIGHTS=nfs` it keeps none: rank 1 reads the head's Hugging Face cache over NFS, read-only.
+Loading is as fast as from the worker's own disk (both ranks were live in ~2.2 minutes).
+
+1. On the head, export the cache to the worker once (this needs root; the worker needs nothing installed):
+
+ ```bash
+ sudo apt install nfs-kernel-server
+ echo "$HOME/.cache/huggingface <worker CX7 address>(ro,no_subtree_check)" | sudo tee -a /etc/exports
+ sudo exportfs -ra
+ ```
+
+2. Put `WORKER_WEIGHTS=nfs` in `scripts/local.sh` or `.env`, and run `./start.sh restart`.
+
+`prepare.sh` then creates a read-only docker NFS volume on the worker (`NFS_VOLUME`, default `glm53-hf`, no sudo) and
+checks that the worker sees every file of both snapshots as the head has them, instead of copying. `NFS_PATH` is the
+exported 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).
+
## Configuration
Every setting lives in [`scripts/config.sh`](scripts/config.sh). Set one for a single run from the environment
@@ -257,7 +279,8 @@ sets a value wins: the environment, then `scripts/local.sh`, then `.env`, then t
| `PARALLEL` | `4` (`1` with `DRAFTER=mtp`) | requests decoded together, 1 to 4 (above 1 needs `DRAFTER=dflash2`) |
| `CONTEXT` | `1048576` | prompt + reply window per request (with `KV=fp8`; other defaults in [KV pool and memory](#kv-pool-and-memory)); `0`: the largest that fits |
| `KV` | `fp8` | `fp8` or `bf16` (exact, shorter window) DSA latent cache and indexer keys |
-| `KV_POOL_GIB` / `MEMORY_RESERVE_GIB` | `11` / `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-6.3 GiB); raise it when other work shares the Sparks |
+| `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` |
| `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) |
| `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 |
@@ -361,12 +384,12 @@ move the same bits. Three defaults are not exact against the checkpoint in bf16,
close to the serial kernel but not its bits.
`DENSE=bf16 KV=bf16 KDA_CHUNKED=0` serves the checkpoint as it is, with a shorter window ([KV pool and memory](#kv-pool-and-memory)).
-The scripts in `tools/` talk to the running server (`API_URL`, default `http://127.0.0.1:8888`; or just `PORT`),
-from the head or another machine (`API_URL=http://<head-address>:8888 tools/bench.py`):
+The checks in `tools/` talk to the running server (`API_URL`, default `http://127.0.0.1:8888`; or just `PORT`),
+from the head or another machine (`API_URL=http://<head-address>:8888 tools/needle.py`). Performance is measured
+with [sparkDash](https://github.com/MiaAI-Lab/sparkDash) ([Performance](#performance)).
| Script | What it does |
| --- | --- |
-| `tools/bench.py [label]` | prefill at ~0.8k / 3.3k / 13k / 52k tokens (fresh random prompts) and a short decode check |
| `tools/needle.py [label] [size]` | hides a passphrase in a ~195k-token prompt (the prompt comes out at ~0.8 x `size` tokens) and checks the model returns it |
| `tools/toolcheck.py` | makes a tool call with an array parameter and checks it comes back as a JSON array |
@@ -379,7 +402,7 @@ scripts/ config.sh (all settings), local.sh.example (this setup's WORKER),
both Sparks), nodes.sh (ssh and the RoCE link), publish-image.sh (push the image to GHCR),
banner.sh (start.sh's banner)
patches/ patches baked into the image
-tools/ benchmark and checks
+tools/ checks against the running server (needle, tool calls)
CHANGELOG.md what changed in each release
CREDITS.md who and what this builds on
LICENSE Apache License 2.0
diff --git a/scripts/config.sh b/scripts/config.sh
index 2f0b1cc..e2e2636 100644
--- a/scripts/config.sh
+++ b/scripts/config.sh
@@ -76,7 +76,7 @@ if [[ "$DRAFTER" == dflash2 ]]; then _par=4; else _par=1; fi
PARALLEL="${PARALLEL:-$_par}"
# The DSA latent cache and the indexer's pooled keys (patch 0041): fp8 (default) holds them as e4m3 rows with a
# power-of-two scale each, half bf16's bytes: the 1M-token window with 4 streams fits (rank 0: 88.09 GiB estimated,
-# pool 2,684,928 tokens at the measured start). Lossy: GSM8K 98.0%, HumanEval 97.6%, 1M needle found; drafted replies still equal serial
+# pool 2,852,864 tokens at the measured start). Lossy: GSM8K 98.0%, HumanEval 97.6%, 1M needle found; drafted replies still equal serial
# ones. bf16: the exact cache (~196k tokens with DFlash2).
KV="${KV:-fp8}"
export TF_GLM_KV="$KV"
@@ -165,17 +165,25 @@ export TF_GLM_SHARED_PREFIX="$SHARED_PREFIX"
# into the memory left at start. TensorFold sizes it from MemAvailable at start minus MEMORY_RESERVE_GIB
# (TENSORFOLD_MEMORY_RESERVE_GIB), capped at KV_POOL_GIB (its TF_GLM_CACHE_GIB). The server uses about 10 GiB more than
# its own estimate at its peak (a 1M-token prompt), so the reserve sets the lowest free memory on the head: 14.5 leaves
-# about 4.5 GiB there, and the pool comes out at ~2.1-2.7M tokens depending on what is free at start. TensorFold's own
+# about 4.5 GiB there, and the pool comes out at ~2.1-2.9M tokens depending on what is free at start. TensorFold's own
# defaults (a tenth of RAM, ~12.2; 3 GiB: pool 1,411,072 tokens) leave ~14 GiB. Raise the reserve if other work
# shares the Sparks' memory.
MEMORY_RESERVE_GIB="${MEMORY_RESERVE_GIB:-14.5}"
export TENSORFOLD_MEMORY_RESERVE_GIB="$MEMORY_RESERVE_GIB"
-KV_POOL_GIB="${KV_POOL_GIB:-11}"
+KV_POOL_GIB="${KV_POOL_GIB:-12.5}"
export TF_GLM_CACHE_GIB="$KV_POOL_GIB"
export TENSORFOLD_NO_UPDATE_CHECK="${TENSORFOLD_NO_UPDATE_CHECK:-1}"
HF_CACHE="${HF_CACHE:-${HF_HOME:-$HOME/.cache/huggingface}}"
+# Where rank 1 reads the checkpoint and DFlash2: copy (default) keeps a copy in the worker's own Hugging Face cache
+# (prepare.sh copies ~166 GiB over the link); nfs reads the head's HF_CACHE over NFS instead (no copy, no disk on the
+# worker), through a read-only docker volume NFS_VOLUME on the worker that prepare.sh creates (no sudo there). The head
+# must export NFS_PATH (default: HF_CACHE) to the worker; NFS_SERVER defaults to the head's address on the link.
+WORKER_WEIGHTS="${WORKER_WEIGHTS:-copy}"
+NFS_PATH="${NFS_PATH:-$HF_CACHE}"
+NFS_SERVER="${NFS_SERVER:-}"
+NFS_VOLUME="${NFS_VOLUME:-glm53-hf}"
KERNEL_CACHE="${KERNEL_CACHE:-$HOME/.cache/tensorfold-glm53}" # compiled CUDA kernels (written by the containers)
STATE_DIR="${STATE_DIR:-$HOME/.local/state/glm53-tensorfold}" # this recipe's locks and setup marker
# Free disk prepare.sh asks for before it downloads or copies: the checkpoint (~176 GB) under HF_CACHE (on the worker,
@@ -205,5 +213,5 @@ prepared_state() {
hash=$(image_hash)
label=$(docker image inspect -f '{{.Id}}' "$IMAGE" 2>/dev/null || echo missing)
wlabel=$(worker docker image inspect -f '{{.Id}}' "$IMAGE" 2>/dev/null || echo missing)
- echo "model=$MODEL_ID@$MODEL_REVISION drafter=$DRAFTER@$DFLASH2_REVISION image=$label worker=$wlabel patches=$hash worker_host=$WORKER"
+ echo "model=$MODEL_ID@$MODEL_REVISION drafter=$DRAFTER@$DFLASH2_REVISION image=$label worker=$wlabel patches=$hash worker_host=$WORKER weights=$WORKER_WEIGHTS"
}
diff --git a/scripts/nodes.sh b/scripts/nodes.sh
index 59d93a5..37ddb4a 100644
--- a/scripts/nodes.sh
+++ b/scripts/nodes.sh
@@ -8,6 +8,22 @@ worker() { ssh -o BatchMode=yes -o ConnectTimeout=10 -o ServerAliveInterval=15 "
# into it and start.sh mounts it into rank 1.
worker_hf_cache() { worker 'echo "${HF_HOME:-$HOME/.cache/huggingface}"'; }
+# WORKER_WEIGHTS=nfs: rank 1 mounts the head's HF_CACHE read-only through the docker volume NFS_VOLUME on the worker.
+# ensure_nfs_volume creates it (or checks the one there names the same export); worker_nfs <cmd...> runs a command in
+# a throwaway container with the volume at /hf.
+ensure_nfs_volume() {
+ local server="${NFS_SERVER:-$HEAD_ADDR}" have
+ have=$(worker "docker volume inspect -f '{{index .Options \"device\"}} {{index .Options \"o\"}}' '$NFS_VOLUME'" 2>/dev/null || true)
+ if [[ -z "$have" ]]; then
+ worker "docker volume create --driver local --opt type=nfs --opt device=':$NFS_PATH' \
+ --opt o='addr=$server,nfsvers=4.2,ro,nconnect=8,rsize=1048576,wsize=1048576,hard,timeo=600' '$NFS_VOLUME'" >/dev/null ||
+ die "could not create the docker volume $NFS_VOLUME on the worker"
+ elif [[ "${have%% *}" != ":$NFS_PATH" || "$have" != *"addr=$server,"* ]]; then
+ die "the worker's docker volume $NFS_VOLUME is ${have%% *} from ${have#* }, not :$NFS_PATH from $server: remove it there (docker volume rm $NFS_VOLUME) or set NFS_VOLUME / NFS_PATH"
+ fi
+}
+worker_nfs() { worker "docker run --rm --entrypoint '$1' -v '$NFS_VOLUME:/hf:ro' '$IMAGE' $(printf '%q ' "${@:2}")"; }
+
need_worker() {
[[ -n "${WORKER:-}" ]] || die "WORKER is not set: put WORKER=user@<worker address> in scripts/local.sh (see scripts/local.sh.example)"
worker true 2>/dev/null || die "cannot ssh to $WORKER without a password: set up key-based ssh (ssh-copy-id $WORKER)"
diff --git a/scripts/prepare.sh b/scripts/prepare.sh
index 3f399bf..45bf83c 100755
--- a/scripts/prepare.sh
+++ b/scripts/prepare.sh
@@ -43,7 +43,7 @@ worker 'command -v rsync >/dev/null' || die "rsync is not installed on the worke
detect_link
log "Link: head $HEAD_ADDR ($HEAD_DEV, $HEAD_HCA, GID $HEAD_GID) <-> worker $WORKER_ADDR ($WORKER_DEV, $WORKER_HCA, GID $WORKER_GID)"
WORKER_HF=$(worker_hf_cache)
-worker "mkdir -p '$WORKER_HF/hub' && test -w '$WORKER_HF/hub'" ||
+[[ "$WORKER_WEIGHTS" == nfs ]] || worker "mkdir -p '$WORKER_HF/hub' && test -w '$WORKER_HF/hub'" ||
die "the worker's $WORKER_HF/hub is not writable (left root-owned by a container? fix its ownership there)"
PATCHES_HASH=$(image_hash)
@@ -158,11 +158,26 @@ done
# ---------------------------------------------------------------- 5. verify (head)
# before the copy: the worker gets only a checkpoint TensorFold reads
log "Verifying checkpoint with tensorfold info"
-docker run --rm --entrypoint tensorfold -e HF_HUB_OFFLINE=1 -v "$HF_CACHE":/root/.cache/huggingface "$IMAGE" \
- info "/root/.cache/huggingface/hub/models--${MODEL_ID//\//--}/snapshots/$(snapshot_rev "$MODEL_ID")"
+# (without its "EXL3 support is experimental" note: this recipe serves the EXL3 checkpoint on purpose)
+info=$(docker run --rm --entrypoint tensorfold -e HF_HUB_OFFLINE=1 -v "$HF_CACHE":/root/.cache/huggingface "$IMAGE" \
+ info "/root/.cache/huggingface/hub/models--${MODEL_ID//\//--}/snapshots/$(snapshot_rev "$MODEL_ID")" 2>&1) ||
+ die "tensorfold info cannot read the checkpoint: $info"
+printf '%s\n' "$info" | grep -v "EXL3 support is experimental" || true
# ---------------------------------------------------------------- 6. the same files on the worker
+if [[ "$WORKER_WEIGHTS" == nfs ]]; then # no copy: rank 1 reads the head's cache over NFS
+ ensure_nfs_volume
+ for id in "${models[@]}"; do
+ dir=$(model_cache_dir "$id"); rev=$(snapshot_rev "$id")
+ manifest=$(cd "$dir/snapshots/$rev" && find -L . -type f -printf '%P %s\n' | sort)
+ have=$(worker_nfs find -L "/hf/hub/${dir##*/}/snapshots/$rev" -type f -printf '%P %s\n' 2>/dev/null | sort || true)
+ [[ "$have" == "$manifest" ]] ||
+ die "the worker does not see $id @ ${rev:0:8} over NFS ($NFS_VOLUME: :$NFS_PATH from ${NFS_SERVER:-$HEAD_ADDR}); is HF_CACHE exported to it? (README: Worker weights over NFS)"
+ log "Worker reads $id @ ${rev:0:8} from the head over NFS ($NFS_VOLUME)"
+ done
+fi
for id in "${models[@]}"; do
+ [[ "$WORKER_WEIGHTS" == nfs ]] && break
dir=$(model_cache_dir "$id"); rev=$(snapshot_rev "$id")
# every file of the snapshot, with its size (links followed), as the head has it
manifest=$(cd "$dir/snapshots/$rev" && find -L . -type f -printf '%P %s\n' | sort)
diff --git a/start.sh b/start.sh
index ef3a11a..6d3acd3 100755
--- a/start.sh
+++ b/start.sh
@@ -21,6 +21,7 @@
# SHARED_PREFIX, MULTI_PREFILL, KV_POOL_GIB, MEMORY_RESERVE_GIB, THINKING, VISION, VISION_URLS, COMM, SERVED_NAME, HOST, PORT
# nodes WORKER, FABRIC_PEER, MASTER_PORT, NCCL_RAILS (1: one CX7 port), NCCL_CHANNELS, NCCL_DEBUG
# files 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,
# 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
@@ -55,6 +56,7 @@ SERVE_ARGS=(--context "$CONTEXT" --parallel "$PARALLEL")
[[ "$PARALLEL" =~ ^[1-4]$ ]] || die "PARALLEL is 1 to 4, not $PARALLEL"
[[ "$DRAFTER" == dflash2 || "$PARALLEL" == 1 ]] || die "PARALLEL=$PARALLEL needs DRAFTER=dflash2 (mtp serves one request at a time: PARALLEL=1)"
for v in SPLIT SHARED_PREFIX KDA_CHUNKED COPY_CODE MULTI_PREFILL; do [[ "${!v}" =~ ^[01]$ ]] || die "$v is 0 or 1, not ${!v}"; done
+[[ "$WORKER_WEIGHTS" == copy || "$WORKER_WEIGHTS" == nfs ]] || die "WORKER_WEIGHTS is copy or nfs, not $WORKER_WEIGHTS"
[[ "$KV_POOL_GIB" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "KV_POOL_GIB is a number of GiB, not $KV_POOL_GIB"
[[ "$MEMORY_RESERVE_GIB" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "MEMORY_RESERVE_GIB is a number of GiB, not $MEMORY_RESERVE_GIB"
[[ "$COPY_MAX" =~ ^([1-9]|1[0-5])$ ]] || die "COPY_MAX is 1 to 15, not $COPY_MAX"
@@ -133,13 +135,20 @@ worker docker image inspect "$IMAGE" >/dev/null 2>&1 || die "image $IMAGE missin
# ranks read them offline, whatever the Hub's main is now. The worker's cache is its own HF_HOME (prepare.sh copies
# into the same place).
WORKER_HF=$(worker_hf_cache)
+WORKER_MOUNT="$WORKER_HF:/root/.cache/huggingface" # rank 1's cache: its own copy, or the head's (nfs)
+[[ "$WORKER_WEIGHTS" == nfs ]] && WORKER_MOUNT="$NFS_VOLUME:/root/.cache/huggingface:ro"
snapshot() { # <repo id>: its snapshot path in the container, checked on both Sparks
local id=$1 rev sub
rev=$(snapshot_rev "$id")
[[ -n "$rev" ]] || die "$id not in $HF_CACHE: $why download it"
sub="hub/models--${id//\//--}/snapshots/$rev"
[[ -f "$HF_CACHE/$sub/config.json" ]] || die "$id @ ${rev:0:8} not in $HF_CACHE: $why download it"
- worker "test -f '$WORKER_HF/$sub/config.json'" || die "$id @ ${rev:0:8} not on the worker ($WORKER_HF): $why copy it there"
+ if [[ "$WORKER_WEIGHTS" == nfs ]]; then
+ worker_nfs test -f "/hf/$sub/config.json" ||
+ die "the worker does not see $id @ ${rev:0:8} over NFS ($NFS_VOLUME): $why set it up"
+ else
+ worker "test -f '$WORKER_HF/$sub/config.json'" || die "$id @ ${rev:0:8} not on the worker ($WORKER_HF): $why copy it there"
+ fi
echo "/root/.cache/huggingface/$sub"
}
MODEL_ARG=$(snapshot "$MODEL_ID")
@@ -208,7 +217,7 @@ launch() {
log "Rank 0 here: ${rank0[*]}"
worker_cmd=(docker run -d --name "$CONTAINER_NAME" "${RUN_ARGS[@]}" "${ENV_ARGS[@]}"
$(nccl_env "$WORKER_DEV" "$WORKER_HCAS" "$WORKER_GID")
- -v "$WORKER_HF:/root/.cache/huggingface" -v '$HOME/.cache/tensorfold-glm53:/cache'
+ -v "$WORKER_MOUNT" -v '$HOME/.cache/tensorfold-glm53:/cache'
"$IMAGE" "${rank1[@]}")
remote=""; for a in "${worker_cmd[@]}"; do
case "$a" in '$HOME'*) remote+=" \"$a\"" ;; *) remote+=" $(printf '%q' "$a")" ;; esac
@@ -243,7 +252,7 @@ foreground() {
exit "$code"
}
# NVIDIA's container banner, without its license notice (GOVERNING TERMS ...), which stays visible
-NOISE='^\s*$|^=+$|^== PyTorch ==|^NVIDIA Release|Copyright|All rights reserved|PyTorch Version|Various files include|NOTE: CUDA Forward|Using CUDA|cuda-compatibility|Container image|torch/utils/_pytree\.py.*register_constant'
+NOISE='^\s*$|EXL3 support is experimental|^=+$|^== PyTorch ==|^NVIDIA Release|Copyright|All rights reserved|PyTorch Version|Various files include|NOTE: CUDA Forward|Using CUDA|cuda-compatibility|Container image|torch/utils/_pytree\.py.*register_constant'
LOGS_PID=""
trap 'kill $LOGS_PID 2>/dev/null || true' EXIT
# GPU memory a container's processes hold so far (GiB); on the worker through ssh, with this definition
diff --git a/tools/bench.py b/tools/bench.py
deleted file mode 100755
index 535fe02..0000000
--- a/tools/bench.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python3
-"""Prefill and decode benchmark against the running server.
-
-Every prompt is fresh random prose (a new seed per run), so no kept prompt state (prefix reuse) ever matches and every
-token is prefilled. Reports the server's own prefill seconds and decode tokens/s.
-
-Usage: tools/bench.py [label] (API_URL, default http://127.0.0.1:$PORT with PORT 8888; DECODE_ONLY=1 skips prefill)
-"""
-import json
-import os
-import random
-import statistics
-import sys
-import time
-import urllib.error
-import urllib.request
-
-API_URL = os.environ.get("API_URL", "http://127.0.0.1:" + os.environ.get("PORT", "8888")).rstrip("/")
-URL = API_URL + "/v1/chat/completions"
-WORDS = ("time year people way day man thing woman life child world school state family student group country "
- "problem hand part place case week company system program question work government number night point "
- "home water room mother area money story fact month lot right study book eye job word business issue "
- "side kind head house service friend father power hour game line end member law car city community name "
- "president team minute idea kid body information back parent face others level office door health person "
- "art war history party result change morning reason research girl guy moment air teacher force education "
- "river mountain signal engine garden theory market winter method bridge letter window voice paper field").split()
-SIZES = [(1_000, 3), (4_000, 3), (16_000, 2), (64_000, 1)] # (approx prompt tokens, runs)
-
-
-def prose(tokens: int, seed: int) -> str:
- rng = random.Random(seed)
- out = []
- while len(out) < tokens * 0.72: # ~1.14 tokens a word: the prompt comes out at ~0.82 x tokens
- sentence = [rng.choice(WORDS) for _ in range(rng.randint(6, 16))]
- out += sentence[:-1] + [sentence[-1] + "."]
- return " ".join(out)
-
-
-def open_url(req: urllib.request.Request, timeout: float):
- """urlopen, with a one-line message instead of a traceback when the server is not there or refuses."""
-
- try:
- return urllib.request.urlopen(req, timeout=timeout)
- except urllib.error.HTTPError as exc:
- sys.exit(f"the server at {API_URL} answered {exc.code}: {exc.read().decode(errors='replace')[:300]}")
- except urllib.error.URLError as exc:
- sys.exit(f"cannot reach the server at {API_URL} ({exc.reason}): is it running? (./start.sh)")
-
-
-def run(prompt: str, max_tokens: int, temperature=None) -> dict:
- body = {"model": os.environ.get("MODEL", "GLM-5.3-Flash-EXL3"), "stream": True, "max_tokens": max_tokens,
- "stream_options": {"include_usage": True}, "messages": [{"role": "user", "content": prompt}]}
- if temperature is not None:
- body["temperature"] = temperature
- req = urllib.request.Request(URL, json.dumps(body).encode(), {"Content-Type": "application/json"})
- start, first, stats = time.time(), None, {}
- for line in open_url(req, 3600):
- line = line.decode().strip()
- if not line.startswith("data:") or line.endswith("[DONE]"):
- continue
- chunk = json.loads(line[5:])
- delta = (chunk.get("choices") or [{}])[0].get("delta", {})
- if first is None and (delta.get("content") or delta.get("reasoning_content")):
- first = time.time()
- if "tensorfold" in chunk:
- stats = {**chunk["tensorfold"], **chunk.get("usage", {})}
- stats["ttft"] = (first or time.time()) - start
- return stats
-
-
-def main() -> None:
- label = sys.argv[1] if len(sys.argv) > 1 else "run"
- seed = int(time.time())
- print(f"== {label}")
- for tokens, runs in ([] if os.environ.get("DECODE_ONLY") else SIZES):
- rs = [run(prose(tokens, seed + i * 7919 + tokens) + "\n\nSummarize the text above in one sentence.", 16)
- for i in range(runs)]
- assert all(r.get("cached", 0) == 0 for r in rs), "prompt cache hit: prompts are not fresh"
- n = statistics.median(r["prompt_tokens"] for r in rs)
- pre = statistics.median(r["prefill_s"] for r in rs)
- ttft = statistics.median(r["ttft"] for r in rs)
- each = ", ".join("%.2f" % r["prefill_s"] for r in rs)
- print(f"prefill {n:>7,.0f} tok: {pre:7.2f} s {n / pre:6.0f} tok/s TTFT {ttft:6.2f} s"
- f" ({runs} run{'s' if runs > 1 else ''}, each {each} s)")
- for name, prompt, temp in (("code greedy", "Write a Python quicksort with docstring and tests.", 0),
- ("chat sampled", "Explain why the sky is blue in a few paragraphs.", None)):
- rs = [run(prompt, 256, temp) for _ in range(5)]
- tps = [r.get("decode_tps") or r["completion_tokens"] / r["decode_s"] for r in rs] # parallel mode: no decode_tps
- print(f"decode {name:12s}: {statistics.median(tps):5.1f} tok/s (median of 5)")
-
-
-if __name__ == "__main__":
- main()
diff --git a/tools/client.py b/tools/client.py
new file mode 100644
index 0000000..3e7c139
--- /dev/null
+++ b/tools/client.py
@@ -0,0 +1,38 @@
+"""What the checks in tools/ share: the server's URL (API_URL, default http://127.0.0.1:8888, or just PORT), a
+one-line error instead of a traceback, and random prose of a given length."""
+import os
+import random
+import sys
+import urllib.error
+import urllib.request
+
+API_URL = os.environ.get("API_URL", "http://127.0.0.1:" + os.environ.get("PORT", "8888")).rstrip("/")
+URL = API_URL + "/v1/chat/completions"
+WORDS = ("time year people way day man thing woman life child world school state family student group country "
+ "problem hand part place case week company system program question work government number night point "
+ "home water room mother area money story fact month lot right study book eye job word business issue "
+ "side kind head house service friend father power hour game line end member law car city community name "
+ "president team minute idea kid body information back parent face others level office door health person "
+ "art war history party result change morning reason research girl guy moment air teacher force education "
+ "river mountain signal engine garden theory market winter method bridge letter window voice paper field").split()
+
+
+def prose(tokens: int, seed: int) -> str:
+ rng = random.Random(seed)
+ out = []
+ while len(out) < tokens * 0.72: # ~1.14 tokens a word: the prompt comes out at ~0.82 x tokens
+ sentence = [rng.choice(WORDS) for _ in range(rng.randint(6, 16))]
+ out += sentence[:-1] + [sentence[-1] + "."]
+ return " ".join(out)
+
+
+def open_url(req: urllib.request.Request, timeout: float):
+ """urlopen, with a one-line message instead of a traceback when the server is not there or refuses."""
+
+ try:
+ return urllib.request.urlopen(req, timeout=timeout)
+ except urllib.error.HTTPError as exc:
+ sys.exit(f"the server at {API_URL} answered {exc.code}: {exc.read().decode(errors='replace')[:300]}")
+ except urllib.error.URLError as exc:
+ sys.exit(f"cannot reach the server at {API_URL} ({exc.reason}): is it running? (./start.sh)")
+
diff --git a/tools/needle.py b/tools/needle.py
index c0d2066..9201184 100755
--- a/tools/needle.py
+++ b/tools/needle.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""Needle in a haystack at ~195k tokens: a passphrase hidden at ~60% depth of random prose, asked for greedily.
-Usage: tools/needle.py [label] [size] (size: bench.prose's length parameter, the prompt comes out at ~0.8 x size
-tokens; default 248000, ~195k tokens. API_URL / PORT as in bench.py). Exit code 1 if the answer is wrong.
+Usage: tools/needle.py [label] [size] (size: client.prose's length parameter, the prompt comes out at ~0.8 x size
+tokens; default 248000, ~195k tokens. API_URL / PORT as in client.py). Exit code 1 if the answer is wrong.
"""
import json
import os
@@ -10,8 +10,8 @@ import sys
import time
import urllib.request
-sys.dont_write_bytecode = True # no tools/__pycache__ from importing bench
-from bench import URL, open_url, prose # noqa: E402
+sys.dont_write_bytecode = True # no tools/__pycache__ from importing client
+from client import URL, open_url, prose # noqa: E402
SECRET = "violet-harbor-7291"
diff --git a/tools/toolcheck.py b/tools/toolcheck.py
index 7e14bc8..92e9670 100755
--- a/tools/toolcheck.py
+++ b/tools/toolcheck.py
@@ -1,15 +1,15 @@
#!/usr/bin/env python3
"""A tool call with an array parameter must come back with that argument as a JSON array (typed by the schema).
-Usage: tools/toolcheck.py (API_URL / PORT as in bench.py). Exit code 1 on failure.
+Usage: tools/toolcheck.py (API_URL / PORT as in client.py). Exit code 1 on failure.
"""
import json
import os
import sys
import urllib.request
-sys.dont_write_bytecode = True # no tools/__pycache__ from importing bench
-from bench import URL, open_url # noqa: E402
+sys.dont_write_bytecode = True # no tools/__pycache__ from importing client
+from client import URL, open_url # noqa: E402
TOOLS = [{"type": "function", "function": {
"name": "add_tags", "description": "Attach tags to a document.",
"parameters": {"type": "object", "required": ["doc_id", "tags"], "properties": {