#!/bin/sh # Aiden production-1.6 launch wrapper for sm121 (per-rank Engram row ranges). # # The model's two Engram tables (layers 1 and 14) hold a different number of # rows each (384,006,168 / 384,016,682 for this snapshot), and the overlay # refuses to start unless the ranks' ranges tile [0, N) exactly per layer. # A full snapshot has no manifest, so the ranges come from SPARK_ENGRAM_ROWS; # a full range on every rank would double-count row contributions in the # reduce, so each rank gets its own contiguous slice. The per-layer row count # is read from the checkpoint's safetensors headers at launch (the table is # 384M rows of fp8 e4m3 + scale, so the per-layer N is not in config.json). set -e DIR="$(dirname "$(readlink -f "$0" 2>/dev/null || echo /)")/models--deepseek-ai--DeepSeek-V4.1-Flash/snapshots" SNAP="$(ls -d /root/.cache/huggingface/hub/models--deepseek-ai--DeepSeek-V4.1-Flash/snapshots/* | head -1)" R="${NODE_RANK:-0}" export SPARK_ENGRAM_ROWS="$(python3 - "$SNAP" "$R" <<'PY' import json, struct, sys snap, rank = sys.argv[1], int(sys.argv[2]) def rows(path, key): with open(path, "rb") as f: n = struct.unpack("