Skip to content

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

Python

Launcher: probe a second rail across the link before using it, and log the rails (#66, #88)

MiaAI-Lab19f9ec67d802
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d991fed..0094a5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,16 @@
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
+
+- **A second rail is tested before it is used (#66).** At two Sparks the launcher added the cabled port's PCIe twin by name
+ (v1.6) without checking that it reaches the peer; a twin that is up with a GID but unaddressed, on another subnet or at another
+ MTU ended in `vendor_err 0x81` (transport retry exceeded) in the first all-gather. `start.sh` now sends a full-size
+ unfragmentable ping from each second rail's own address to the peer's matching rail, both ways, and drops a rail that does not
+ answer with a `WARN` naming both devices, addresses and MTUs (one rail then, as `NCCL_RAILS=1`). The Link line also prints the
+ GID indexes and the rail count passed to `NCCL_IB_HCA` / `TF_ROCE_HCA` (#88). TP=3/4 and the ring are unchanged (they pair
+ devices by subnet). Scripts only, no patch.
+
## v1.9.1 (2026-10-08): the spill tier's free-disk floor makes room
Image: `v0.6.0-ff5dffc865d3` (`sha256:20275b2be818635a9c711d80a177477488d2c75cad373cc644422295c4fe9f07`), 94 patches (v1.9's, with `0088` updated). Tested live on two Sparks: with
diff --git a/README.md b/README.md
index 7b3e97c..79ce462 100644
--- a/README.md
+++ b/README.md
@@ -553,7 +553,7 @@ Less common settings are described in `scripts/config.sh` and `scripts/nodes.sh`
`TF_VERSION`, `TF_REPO`, `BASE_IMAGE` (the patches are made for TensorFold v0.6.0; after changing any of these run
`scripts/prepare.sh --rebuild`), `IMAGE`, `CONTAINER_NAME`, `GHCR_IMAGE`, `HF_CACHE` (default `$HF_HOME` or
`~/.cache/huggingface`), `KERNEL_CACHE`, `STATE_DIR`, `MIN_FREE_GB`, `IMAGE_FREE_GB`, `NCCL_RAILS` (`1`: one RoCE
-port even when the cabled port's two PCIe links, or a second port, are up), `NCCL_CHANNELS` (4), `NCCL_DEBUG`, `RSYNC_OPTS`. `start.sh` also takes `HF_HUB_OFFLINE=0` (let the
+port even when the cabled port's two PCIe links, or a second port, are up; at two Sparks `start.sh` pings each second rail across the link before using it and drops one that does not answer, with a warning), `NCCL_CHANNELS` (4), `NCCL_DEBUG`, `RSYNC_OPTS`. `start.sh` also takes `HF_HUB_OFFLINE=0` (let the
server reach Hugging Face; by default it serves from the local cache only).
### Thinking and sampling
diff --git a/scripts/nodes.sh b/scripts/nodes.sh
index 52b5d1b..a76c115 100644
--- a/scripts/nodes.sh
+++ b/scripts/nodes.sh
@@ -162,6 +162,23 @@ rails() {
echo "$hcas"
}
+# rail_info <rdma device>: "<netdev> <IPv4 address> <MTU>" of the port a RoCE device sits on ("- - -" when it has none).
+# Self-contained: it runs on the workers too (its definition is sent over ssh).
+rail_info() {
+ local n
+ for n in /sys/class/infiniband/"$1"/device/net/*; do
+ [[ -d $n ]] || continue
+ echo "${n##*/} $(ip -o -4 addr show dev "${n##*/}" | awk '{print $4}' | head -1 | cut -d/ -f1) $(cat "$n/mtu" 2>/dev/null || echo 1500)"
+ return 0
+ done
+ echo "- - -"
+}
+
+# rail_ping <local address> <peer address> <MTU>: one rail's traffic reaches the peer's twin - a full-size, unfragmentable
+# ping from that rail's own address (-I), so an unaddressed, differently-subnetted or smaller-MTU twin fails here
+# instead of as vendor_err 0x81 (transport retry exceeded) in the first all-gather (issue #66). Self-contained, like rail_info.
+rail_ping() { ping -c2 -W2 -I "$1" -M do -s $(( $3 - 28 )) "$2" >/dev/null 2>&1; }
+
# The same function on worker i (its definition is sent over ssh).
worker_link_info() { worker "$1" "$(declare -f link_info); link_info $2"; }
@@ -195,6 +212,36 @@ cx7_peer() {
return 1
}
+# probe_rails: before a second rail (the PCIe twin of the cabled port, or a second cabled port) is used, check that it
+# reaches the peer. roce.py pairs the two nodes' devices by list position at two ranks, so a twin that is up and has a GID
+# but no path to the peer's twin (no address, another subnet, another MTU, a cable on a different port) ends in vendor_err
+# 0x81. Rail k of the head is probed against rail k of the worker, in both directions; a rail that fails is dropped from both
+# lists with a warning (the first device, the link itself, is never probed: the launcher reached the worker over it).
+probe_rails() {
+ local -a h w keep_h=() keep_w=()
+ local k hip hmtu wip wmtu mtu=0 ok
+ IFS=, read -ra h <<<"$HEAD_HCAS"; IFS=, read -ra w <<<"$WORKER_HCAS"
+ (( ${#h[@]} > 1 && ${#h[@]} == ${#w[@]} )) || return 0
+ [[ -z "${WORKER_DOWN[1]:-}" ]] || { warn "DRY_RUN: the second rail ($HEAD_HCAS / $WORKER_HCAS) is not probed: the worker cannot be reached"; return 0; }
+ keep_h=("${h[0]}"); keep_w=("${w[0]}")
+ for (( k = 1; k < ${#h[@]}; k++ )); do
+ read -r _ hip hmtu <<<"$(rail_info "${h[k]}")"
+ read -r _ wip wmtu <<<"$(worker 1 "$(declare -f rail_info); rail_info ${w[k]}")"
+ ok=0
+ if [[ "$hip" =~ ^[0-9.]+$ && "$wip" =~ ^[0-9.]+$ && "$hmtu" =~ ^[0-9]+$ && "$wmtu" =~ ^[0-9]+$ ]]; then
+ mtu=$(( hmtu < wmtu ? hmtu : wmtu ))
+ if rail_ping "$hip" "$wip" "$mtu" && worker 1 "$(declare -f rail_ping); rail_ping $wip $hip $mtu"; then ok=1; fi
+ fi
+ if (( ok )); then
+ keep_h+=("${h[k]}"); keep_w+=("${w[k]}")
+ log "Rail ${h[k]} <-> ${w[k]}: $hip <-> $wip reaches the peer (MTU $mtu): used"
+ else
+ warn "second rail ${h[k]} (${hip:--}, MTU ${hmtu:--}) <-> ${w[k]} (${wip:--}, MTU ${wmtu:--}) does not reach the peer: NOT used, running on fewer rails. Give both twins an IPv4 address on one subnet per rail with the same MTU on both Sparks (README), or set NCCL_RAILS=1 to silence this"
+ fi
+ done
+ HEAD_HCAS=$(IFS=,; echo "${keep_h[*]}"); WORKER_HCAS=$(IFS=,; echo "${keep_w[*]}")
+}
+
# TP=2: 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.
@@ -219,6 +266,7 @@ detect_link() {
HEAD_HCAS=$(rails "$HEAD_DEV" "$HEAD_GID")
WORKER_HCAS=$(worker 1 "$(declare -f rails); rails $WORKER_DEV $WORKER_GID")
[[ "${NCCL_RAILS:-2}" == 1 ]] && { HEAD_HCAS=$HEAD_HCA; WORKER_HCAS=$WORKER_HCA; }
+ [[ "${NCCL_RAILS:-2}" == 1 ]] || probe_rails
[[ "$(tr ',' '\n' <<<"$HEAD_HCAS" | wc -l)" == "$(tr ',' '\n' <<<"$WORKER_HCAS" | wc -l)" ]] ||
{ HEAD_HCAS=$HEAD_HCA; WORKER_HCAS=$WORKER_HCA; }
for v in HEAD_HCA HEAD_GID WORKER_HCA WORKER_GID; do
diff --git a/start.sh b/start.sh
index c118080..2e46c04 100755
--- a/start.sh
+++ b/start.sh
@@ -229,7 +229,7 @@ docker run --rm --entrypoint python "$IMAGE" -c \
if (( DRY )); then warn "DRY_RUN: tensorfold serve in $IMAGE rejects these arguments: $(tail -1 "$STATE_DIR/args.err")"
else cat "$STATE_DIR/args.err" >&2; die "tensorfold serve rejects these arguments (see above); nothing was changed"; fi
detect_links
-if (( TP == 2 )); then log "Link: $HEAD_ADDR ($HEAD_DEV) <-> $WORKER_ADDR ($WORKER_DEV), RoCE $HEAD_HCAS / $WORKER_HCAS"
+if (( TP == 2 )); then log "Link: $HEAD_ADDR ($HEAD_DEV) <-> $WORKER_ADDR ($WORKER_DEV), RoCE $HEAD_HCAS / $WORKER_HCAS (GID $HEAD_GID / $WORKER_GID; $(tr ',' '\n' <<<"$HEAD_HCAS" | wc -l) rail(s) -> NCCL_IB_HCA, TF_ROCE_HCA)"
else
log "Rendezvous: $MASTER_ADDR:$MASTER_PORT; NCCL bootstrap over ${NODE_DEV[*]} (rank 0 to $((TP - 1)))"
for r in 0 $(worker_ids); do