|
|
@@ -31,11 +31,22 @@ NAS="${TF1017_NAS:-/mnt/nas/ai/huggingface/hub}"
|
|
|
PUB="${TF1017_PUB:-/mnt/nas/ai/sm121/dsv41-tf-1017}"
|
|
|
IMG="${TF1017_IMAGE:-dsv41-tf-1017:v1}"
|
|
|
RANK="${NODE_RANK:-0}"
|
|
|
-REV="${TF1017_MODEL_REV:-afc7aa0aab98ee735c0f54e0a122019af1ac08f1}"
|
|
|
-EREV="${TF1017_ENGRAM_REV:-1bae0e1088993b9b82de08f59de5be5a34e42170}"
|
|
|
+# Pins are only a fallback: the HF cache's `refs/main` is the truth (a
|
|
|
+# re-cut/re-download moves the snapshot, and a hardcoded rev then points at a
|
|
|
+# directory that no longer exists — exactly what broke the 2026-10-21 serve).
|
|
|
+pin_or_ref() { # <hub dir> <pinned rev>
|
|
|
+ local d="$NAS/$1" ref
|
|
|
+ ref=$(cat "$d/refs/main" 2>/dev/null || true)
|
|
|
+ if [[ -n "$ref" && -d "$d/snapshots/$ref" ]]; then echo "$ref"; else echo "$2"; fi
|
|
|
+}
|
|
|
+REV="${TF1017_MODEL_REV:-$(pin_or_ref models--LibertAIDAI--DeepSeek-V4.1-Flash-1017-EXL3-2.9bpw afc7aa0aab98ee735c0f54e0a122019af1ac08f1)}"
|
|
|
+EREV="${TF1017_ENGRAM_REV:-$(pin_or_ref models--deepseek-ai--DeepSeek-V4.1-Flash-1017 1bae0e1088993b9b82de08f59de5be5a34e42170)}"
|
|
|
|
|
|
WBUNDLE="$NAS/models--LibertAIDAI--DeepSeek-V4.1-Flash-1017-EXL3-2.9bpw/snapshots/$REV"
|
|
|
EBUNDLE="$NAS/models--deepseek-ai--DeepSeek-V4.1-Flash-1017/snapshots/$EREV"
|
|
|
+[[ -d "$WBUNDLE" ]] || { echo "[tf1017] FATAL: no checkpoint snapshot at $WBUNDLE" >&2; exit 1; }
|
|
|
+[[ -d "$EBUNDLE" ]] || { echo "[tf1017] FATAL: no Engram source snapshot at $EBUNDLE" >&2; exit 1; }
|
|
|
+echo "[tf1017] checkpoint rev $REV, Engram rev $EREV"
|
|
|
CKPT="$ROOT/models/checkpoint"
|
|
|
PACKED="$ROOT/engram-packed-1017"
|
|
|
CACHE="$ROOT/cache"
|
|
|
@@ -77,11 +88,32 @@ fi
|
|
|
# 3. per-rank Engram packs (host python + numpy; no image needed) ------------
|
|
|
if [[ "${TF1017_SKIP_PACK:-0}" != "1" ]]; then
|
|
|
if [[ ! -s "$PACKED/engram-l14-r${RANK}of2.bin" ]]; then
|
|
|
- python3 -c 'import numpy' 2>/dev/null || python3 -m pip install --user --quiet numpy
|
|
|
echo "[tf1017] packing Engram tables for rank $RANK (~94 GiB, reads 189 GiB from the NAS)"
|
|
|
- python3 "$HELP/pack_engram.py" \
|
|
|
- --src "$EBUNDLE" --config "$CKPT/config.json" \
|
|
|
- --out "$PACKED" --rank "$RANK"
|
|
|
+ if [[ "${TF1017_PACK_IN_IMAGE:-1}" = "1" ]] && docker image inspect "$IMG" >/dev/null 2>&1; then
|
|
|
+ # Prefer the image: it has numpy + the exact python the packer was
|
|
|
+ # written against. Host python is PEP-668 managed on dgx7/8
|
|
|
+ # (`error: externally-managed-environment`) — no host installs.
|
|
|
+ # Mount the whole repo dir (`snapshots/` + `blobs/`), not just the
|
|
|
+ # snapshot: the snapshot files are symlinks into the hub's blobs,
|
|
|
+ # so a snapshot-only mount makes model.safetensors.index.json
|
|
|
+ # dangle inside the container.
|
|
|
+ # Mount the whole hub: snapshot files are symlinks to the
|
|
|
+ # per-model blobs, which are themselves symlinks to hub-level
|
|
|
+ # blobs (huggingface_hub >= 0.34 layout) — anything less leaves
|
|
|
+ # model.safetensors.index.json dangling in the container.
|
|
|
+ docker run --rm --network none --entrypoint python3 \
|
|
|
+ -v "$NAS":/hub:ro -v "$CKPT":/ckpt:ro -v "$PACKED":/out \
|
|
|
+ -v "$HELP/pack_engram.py":/pack_engram.py:ro \
|
|
|
+ "$IMG" /pack_engram.py --src "/hub/${EBUNDLE#"$NAS"/}" \
|
|
|
+ --config /ckpt/config.json --out /out --rank "$RANK"
|
|
|
+ else
|
|
|
+ python3 -c 'import numpy' 2>/dev/null \
|
|
|
+ || python3 -m pip install --user --quiet --break-system-packages numpy \
|
|
|
+ || { echo "[tf1017] FATAL: numpy missing for the Engram packer and pip refused (no image on this node yet)" >&2; exit 1; }
|
|
|
+ python3 "$HELP/pack_engram.py" \
|
|
|
+ --src "$EBUNDLE" --config "$CKPT/config.json" \
|
|
|
+ --out "$PACKED" --rank "$RANK"
|
|
|
+ fi
|
|
|
fi
|
|
|
[[ -s "$PACKED/engram-l1-r${RANK}of2.bin" && -s "$PACKED/engram-l14-r${RANK}of2.bin" ]] \
|
|
|
|| { echo "[tf1017] FATAL: Engram packs missing for rank $RANK" >&2; exit 1; }
|