Browse Source

dsv41-flash-1017-4x-sglang: DeepSeek-V4.1-Flash-1017 drop-in on Aiden SGLang production-1.7.1 (digest-pinned) — aiden16 contract (wrapper + sparse-copy Engram staging) with the 1017 snapshot as the staging src; new per-node dst engram-1017 (old aiden-engram copies are keyed to the old snapshot)

Alexander Korolev 6 ngày trước cách đây
mục cha
commit
e89dfeca78

+ 38 - 0
recipes/dsv41-flash-1017-4x-sglang/aiden4x-launch.sh

@@ -0,0 +1,38 @@
+#!/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("<Q", f.read(8))[0]
+        h = json.loads(f.read(n))
+    return h[key]["shape"][0]
+n1 = rows(snap + "/model-00047-of-00048.safetensors", "layers.1.engram.embed.weight")
+n14 = rows(snap + "/model-00048-of-00048.safetensors", "layers.14.engram.embed.weight")
+def tile(n, r, parts=4):
+    base, rem = divmod(n, parts)
+    sizes = [base + (1 if i < rem else 0) for i in range(parts)]
+    lo = sum(sizes[:r])
+    return lo, lo + sizes[r]
+lo1, hi1 = tile(n1, rank)
+lo14, hi14 = tile(n14, rank)
+print(f"1:{lo1}:{hi1},14:{lo14}:{hi14}")
+PY
+)"
+# the b12x RoCE runtime takes the same GID index the launcher resolved for NCCL
+[ -n "${NCCL_IB_GID_INDEX:-}" ] && export B12X_ROCE_GID_INDEX="$NCCL_IB_GID_INDEX"
+exec python3 -m sglang.launch_server "$@"

+ 153 - 0
recipes/dsv41-flash-1017-4x-sglang/recipe.toml

@@ -0,0 +1,153 @@
+# DeepSeek-V4.1-Flash-1017 on 4x DGX Spark with Aiden's SGLang production-1.7.1
+# (aidenle.com/recipes/deepseek-v4-1-flash-sglang-4x-dgx-spark).
+#
+# DROP-IN of the 2026-10-17 re-cut `deepseek-ai/DeepSeek-V4.1-Flash-1017`
+# (same arch DeepseekV41ForCausalLM, fp8, 48 shards) over the old
+# `deepseek-ai/DeepSeek-V4.1-Flash` — same serving contract as
+# dsv41-flash-4x-sglang-aiden16, only the model repo (+ staging src) changes.
+#
+# Image: aidendle94/sparkrun-sglang-dsv41-gb10:production-1.7.1 (Docker Hub,
+# 2026-09-29 — Aiden's latest DSV4.1 SGLang production image) = lmsysorg
+# SGLang DSV4.1 + Aiden's MIT overlay (Engram row store inside the CUDA graph,
+# b12x SM12x FP8 dense kernels, SM120 prefill paging, RDMA collectives).
+#
+# Model: deepseek-ai/DeepSeek-V4.1-Flash-1017 (~476 GB, fp8) on the NAS HF
+# cache (weights mmap-loaded from the snapshot). The Engram rows are staged
+# node-locally by [[staging]] below and mounted at /engram-local —
+# SPARK_ENGRAM_DIR points there. NOTE: the staging dst is a NEW dir
+# (/home/kilork/engram-1017) — the old aiden-engram copies are packed from the
+# OLD snapshot's tables and must not be reused. First serve packs ~95 GiB/node
+# from the NAS; later serves verify sampled row hashes against the ledger.
+# Unknown risk: the 1.7.1 overlay predates 1017 — if the re-cut changed the
+# Engram table layout, staging/serve will say so (row ranges derive from the
+# checkpoint's safetensors headers, nothing is hardcoded).
+
+engine = "sglang"
+name = "DeepSeek-V4.1-Flash-1017 (SGLang 4x, Aiden production-1.7.1)"
+docker_image = "aidendle94/sparkrun-sglang-dsv41-gb10@sha256:f617afd8289e4be8f268ce7f6f07beaaff6b8c691fb27d2c3ab9d784d15c8143"
+model = "deepseek-ai/DeepSeek-V4.1-Flash-1017"
+parent_model = "deepseek-ai/DeepSeek-V4.1-Flash"
+port = 30000
+required_nodes = 4
+tensor_parallel_size = 4
+distributed_backend = "mp"
+shm_size = "32gb"
+
+# The wrapper (mounted read-only from the host via extra_mounts below) sets
+# SPARK_ENGRAM_ROWS (+ B12X_ROCE_GID_INDEX) from NODE_RANK and execs the
+# engine with the launcher's full flag list in "$@".
+entrypoint = ["sh", "/aiden4x-launch.sh"]
+
+args = [
+    "--trust-remote-code",
+    "--served-model-name", "deepseek-v4.1-flash",
+    "--load-format", "safetensors",
+    # Aiden's measured shape (production-1.6, carried into 1.7.1); --tp 4 /
+    # --nnodes 4 / --node-rank / --dist-init-addr are appended by the launcher
+    "--ep-size", "4",
+    "--attention-backend", "dsv4",
+    "--moe-runner-backend", "flashinfer_mxfp4",
+    # required for the MXFP8 route (selects the block-scaled path the hook wraps;
+    # K=576 projections fall back to CUTLASS per shape)
+    "--fp8-gemm-backend", "flashinfer_cutlass",
+    "--mem-fraction-static", "0.80",
+    "--chunked-prefill-size", "2048",
+    "--context-length", "524288",
+    "--max-running-requests", "16",
+    "--cuda-graph-max-bs-decode", "16",
+    "--random-seed", "0",
+    "--enable-decoder-swa-bounded-replay",
+    "--speculative-algorithm", "DSPARK",
+    "--speculative-dspark-block-size", "5",
+    "--tool-call-parser", "deepseekv41",
+    "--reasoning-parser", "deepseek-v41",
+    "--watchdog-timeout", "1800",
+    "--min-free-slots-delay", "1",
+]
+
+# The launcher also appends: --model-path <resolved NAS snapshot>, --nnodes 4,
+# --node-rank N, --dist-init-addr <head-ib>:25000, --host 0.0.0.0, --port 30000.
+
+# NOTE: no --default-chat-template-kwargs '{"thinking":true}' — the bench
+# harness controls thinking; Aiden's default is for his interactive fleet.
+
+# The per-rank Engram range wrapper, mounted read-only (copied from the
+# dsv41-flash-4x-sglang-aiden16 recipe dir; placed at this host path on the
+# launch nodes).
+[[extra_mounts]]
+host = "/home/kilork/aiden4x-launch.sh"
+container = "/aiden4x-launch.sh"
+read_only = true
+
+# Node-local sparse copy of the Engram tables (staging P2.5, sparse-copy —
+# the aiden overlay's engram-local.json contract). Built/verified per serve by
+# the [[staging]] block; the wrapper-computed SPARK_ENGRAM_ROWS and the
+# manifest agree because sparse_rows.py tiles ranks with the wrapper's
+# base+rem formula (the overlay refuses to start unless both are identical).
+[[extra_mounts]]
+host = "/home/kilork/engram-1017"
+container = "/engram-local"
+read_only = true
+
+# Staging: sparse-copy packs the aiden contract (engram-local.json manifest +
+# sparse shard copies at the original safetensors byte offsets) from the 1017
+# snapshot. Ranges use the wrapper's base+rem tiling; first serve packs
+# ~95 GiB/node from the NAS, later serves verify sampled row hashes against
+# the ledger stored inside the dst tree.
+[[staging]]
+kind = "sparse-rows"
+format = "sparse-copy"
+id = "engram"
+src = "{{hf}}/hub/models--deepseek-ai--DeepSeek-V4.1-Flash-1017/snapshots/1bae0e1088993b9b82de08f59de5be5a34e42170"
+dst = "/home/kilork/engram-1017"
+min_free = "55G"
+
+[env]
+# Engram row source: the node-local sparse copy staged by [[staging]] above
+# (Aiden's measured production config — ~47 GiB of rows on node NVMe). The
+# manifest (engram-local.json) carries the per-layer rank ranges;
+# SPARK_ENGRAM_ROWS from the wrapper is the cross-check.
+SPARK_ENGRAM_DIR = "/engram-local"
+SPARK_ENGRAM_MODE = "hostnode"
+SPARK_ENGRAM_EARLY = "1"
+SPARK_ENGRAM_PREFETCH = "1"
+SPARK_PAGE_CACHE_RELEASE = "1"
+SPARK_LATE_TAIL_SKIP = "1"
+SPARK_LATE_TAIL_SKIP_ALL = "1"
+SPARK_SM120_REAL_HEADS = "1"
+SPARK_ENGRAM_THREADS = "64"
+SPARK_ENGRAM_MAX_IDS = "65536"
+SPARK_MXFP8_BACKEND = "b12x"
+SPARK_ROCE_AR = "1"
+SPARK_ROCE_AR_MAX = "1MB"
+SPARK_ROCE_AG_MAX = "16MB"
+# b12x RoCE runtime (GID index set by the wrapper from the detected value)
+B12X_ROCE_HCA = "rocep1s0f0,roceP2p1s0f0"
+B12X_ROCE_SPIN_LIMIT = "300000000"
+# image defaults Aiden overrides
+SGLANG_ENABLE_DSV41_ENGRAM_HOST_TABLE = "0"
+SGLANG_FLASHINFER_MOE_FUSED_FINALIZE = "0"
+SGLANG_DSV41_REASONING_EFFORT = "100"
+PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:False"
+CUDA_DEVICE_ORDER = "PCI_BUS_ID"
+# Aiden's NCCL pins (4x 200G RoCE fabric, 192.168.200.0/24) — [env] wins over
+# the config's [nccl."4nodes-switch"] where they differ
+NCCL_NET = "IB"
+NCCL_IB_DISABLE = "0"
+NCCL_IB_HCA = "rocep1s0f0,roceP2p1s0f0"
+NCCL_SOCKET_IFNAME = "enp1s0f0np0"
+GLOO_SOCKET_IFNAME = "enp1s0f0np0"
+NCCL_IB_ROCE_VERSION_NUM = "2"
+NCCL_IB_ADDR_FAMILY = "AF_INET"
+NCCL_IB_ADDR_RANGE = "192.168.200.0/24"
+NCCL_IB_SUBNET_PREFIX_LEN = "24"
+NCCL_CROSS_NIC = "1"
+NCCL_IB_MERGE_NICS = "0"
+NCCL_IB_SUBNET_AWARE_ROUTING = "1"
+NCCL_CUMEM_ENABLE = "0"
+NCCL_P2P_DISABLE = "1"
+NCCL_SHM_DISABLE = "1"
+NCCL_BUFFSIZE = "1048576"
+NCCL_LL128_BUFFSIZE = "262144"
+NCCL_PROTO = "^LL128"
+NCCL_MAX_NCHANNELS = "8"