2026-09-27_193307_engram-local.recipe.toml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # DeepSeek-V4.1-Flash on 4x DGX Spark with Aiden's SGLang production-1.6
  2. # (aidenle.com/recipes/deepseek-v4-1-flash-sglang-4x-dgx-spark).
  3. #
  4. # Image: aidendle94/sparkrun-sglang-dsv41-gb10:production-1.6 (Docker Hub,
  5. # arm64, 33.3 GB) = lmsysorg/sglang:dev-dsv41 (SGLang team's own DSV4.1
  6. # image, unmodified) + Aiden's MIT overlay (import hooks: Engram row store
  7. # from node-local/shard files inside the CUDA graph, b12x SM12x FP8 dense
  8. # kernels, SM120 prefill paging, allocator flush, one-shot RDMA collectives,
  9. # request guard). Lineage: replaced the vLLM stack as Aiden's production
  10. # 2026-09-17 (prefill +30-45%, KV pool +23%); 1.2: 16 concurrent; 1.5: rank
  11. # crash fix + 2 GB10 speedups; 1.6 current. Measured by Aiden on 4x: decode
  12. # 107/87/36 tok/s (count/code/prose C1), prefill 3.3K tok/s @32K, KV pool
  13. # ~4.2M, 524K context, ~10 min to healthy.
  14. #
  15. # Model: deepseek-ai/DeepSeek-V4.1-Flash (510 GB, fp8 native) on the NAS —
  16. # serve with --hf-cache /mnt/nas/ai/huggingface (weights are mmap-loaded from
  17. # the snapshot). The Engram rows are staged node-locally by [[staging]] below
  18. # (Aiden's measured production config: 47.2 GiB sparse copies per node) and
  19. # mounted at /engram-local — SPARK_ENGRAM_DIR points there.
  20. #
  21. # Per-rank Engram row ranges: the two tables have DIFFERENT row counts
  22. # (layer 1: 384,006,168; layer 14: 384,016,682 rows for this snapshot) and the
  23. # overlay refuses to start unless the ranks' ranges tile [0, N) exactly per
  24. # layer. Computed per node by aiden4x-launch.sh (next to this recipe) from
  25. # $NODE_RANK + the checkpoint's safetensors headers (floor/ceil tiling; the
  26. # launcher exports NODE_RANK per rank). A full range on every rank would
  27. # double-count row contributions in the reduce — the range is mandatory.
  28. #
  29. # B12X_ROCE_GID_INDEX reuses the launcher's per-node NCCL GID auto-detect
  30. # (the wrapper exports it), so no pinned GID anywhere.
  31. #
  32. # MEASURED 2026-09-26 (4nodes-switch, NAS model, NAS Engram rows):
  33. # 162/176 (92/100, ★★★★★) — best DSV4.1 score on this cluster.
  34. # PERF CAVEAT then: every FRESH context paid a 2-10 s prefill penalty —
  35. # engram rows came from the NAS shards (30 ms mean gather). The [[staging]]
  36. # block below now localizes them on node NVMe (Aiden's production config);
  37. # a re-bench on staged rows is pending — treat the 09-26 perf row as the
  38. # NAS-engram baseline, not this config.
  39. engine = "sglang"
  40. name = "DeepSeek-V4.1-Flash (SGLang 4x, Aiden production-1.6)"
  41. docker_image = "aidendle94/sparkrun-sglang-dsv41-gb10:production-1.6"
  42. model = "deepseek-ai/DeepSeek-V4.1-Flash"
  43. parent_model = "deepseek-ai/DeepSeek-V4.1-Flash"
  44. port = 30000
  45. required_nodes = 4
  46. tensor_parallel_size = 4
  47. distributed_backend = "mp"
  48. shm_size = "32gb"
  49. # The wrapper (mounted read-only from the host via extra_mounts below) sets
  50. # SPARK_ENGRAM_ROWS (+ B12X_ROCE_GID_INDEX) from NODE_RANK and execs the
  51. # engine with the launcher's full flag list in "$@".
  52. entrypoint = ["sh", "/aiden4x-launch.sh"]
  53. args = [
  54. "--trust-remote-code",
  55. "--served-model-name", "deepseek-v4.1-flash",
  56. "--load-format", "safetensors",
  57. # Aiden's measured shape (production-1.6); --tp 4 / --nnodes 4 /
  58. # --node-rank / --dist-init-addr are appended by the launcher
  59. "--ep-size", "4",
  60. "--attention-backend", "dsv4",
  61. "--moe-runner-backend", "flashinfer_mxfp4",
  62. # required for the MXFP8 route (selects the block-scaled path the hook wraps;
  63. # K=576 projections fall back to CUTLASS per shape)
  64. "--fp8-gemm-backend", "flashinfer_cutlass",
  65. "--mem-fraction-static", "0.80",
  66. "--chunked-prefill-size", "2048",
  67. "--context-length", "524288",
  68. "--max-running-requests", "16",
  69. "--cuda-graph-max-bs-decode", "16",
  70. "--random-seed", "0",
  71. "--enable-decoder-swa-bounded-replay",
  72. "--speculative-algorithm", "DSPARK",
  73. "--speculative-dspark-block-size", "5",
  74. "--tool-call-parser", "deepseekv41",
  75. "--reasoning-parser", "deepseek-v41",
  76. "--watchdog-timeout", "1800",
  77. "--min-free-slots-delay", "1",
  78. ]
  79. # The launcher also appends: --model-path <resolved NAS snapshot>, --nnodes 4,
  80. # --node-rank N, --dist-init-addr <head-ib>:25000, --host 0.0.0.0, --port 30000.
  81. # NOTE: no --default-chat-template-kwargs '{"thinking":true}' — the bench
  82. # harness controls thinking; Aiden's default is for his interactive fleet.
  83. # The per-rank Engram range wrapper, mounted read-only (bare keys above; the
  84. # table header must come after them or `args`/`[env]` would parse into it).
  85. [[extra_mounts]]
  86. host = "/home/kilork/aiden4x-launch.sh"
  87. container = "/aiden4x-launch.sh"
  88. read_only = true
  89. # Node-local sparse copy of the Engram tables (staging P2.5, sparse-copy —
  90. # the aiden overlay's engram-local.json contract). Built/verified per serve by
  91. # the launcher's [[staging]] below; the wrapper-computed SPARK_ENGRAM_ROWS and
  92. # the manifest agree because sparse_rows.py tiles ranks with the wrapper's
  93. # base+rem formula (the overlay refuses to start unless both are identical).
  94. [[extra_mounts]]
  95. host = "/home/kilork/aiden-engram"
  96. container = "/engram-local"
  97. read_only = true
  98. # Staging (spec: specs/tech-architecture/staging-feature.md): the sparse-copy
  99. # format writes the aiden16 contract directly (engram-local.json manifest +
  100. # sparse shard copies at the original safetensors byte offsets) so the overlay
  101. # reads rows from node-local NVMe. Ranges use the wrapper's base+rem tiling;
  102. # first serve packs ~95 GiB/node from the NAS, later serves verify sampled
  103. # row hashes against the ledger stored inside the dst tree.
  104. [[staging]]
  105. kind = "sparse-rows"
  106. format = "sparse-copy"
  107. id = "engram"
  108. src = "{{hf}}/hub/models--deepseek-ai--DeepSeek-V4.1-Flash/snapshots/dba1be0a40aa45a94ad051997016db3960a90277"
  109. dst = "/home/kilork/aiden-engram"
  110. min_free = "55G"
  111. # Engram row source: the node-local sparse copy staged by [[staging]] —
  112. # Aiden's measured production config (47.2 GiB rows on node NVMe). The
  113. # manifest (engram-local.json) carries the per-layer rank ranges; the
  114. # wrapper's SPARK_ENGRAM_ROWS is the identity cross-check the overlay runs.
  115. [env]
  116. # Engram row source: the node-local sparse copy staged by [[staging]] below
  117. # (Aiden's measured production config — 47.2 GiB of rows on node NVMe, ~0.3 ms
  118. # gather; previously read straight from the NAS snapshot, which cost a 2-10 s
  119. # fresh-context prefill penalty). The manifest (engram-local.json) carries the
  120. # per-layer rank ranges; SPARK_ENGRAM_ROWS from the wrapper is the cross-check.
  121. SPARK_ENGRAM_DIR = "/engram-local"
  122. SPARK_ENGRAM_MODE = "hostnode"
  123. SPARK_ENGRAM_EARLY = "1"
  124. SPARK_ENGRAM_PREFETCH = "1"
  125. SPARK_PAGE_CACHE_RELEASE = "1"
  126. SPARK_LATE_TAIL_SKIP = "1"
  127. SPARK_LATE_TAIL_SKIP_ALL = "1"
  128. SPARK_SM120_REAL_HEADS = "1"
  129. SPARK_ENGRAM_THREADS = "64"
  130. SPARK_ENGRAM_MAX_IDS = "65536"
  131. SPARK_MXFP8_BACKEND = "b12x"
  132. SPARK_ROCE_AR = "1"
  133. SPARK_ROCE_AR_MAX = "1MB"
  134. SPARK_ROCE_AG_MAX = "16MB"
  135. # b12x RoCE runtime (GID index set by the wrapper from the detected value)
  136. B12X_ROCE_HCA = "rocep1s0f0,roceP2p1s0f0"
  137. B12X_ROCE_SPIN_LIMIT = "300000000"
  138. # image defaults Aiden overrides
  139. SGLANG_ENABLE_DSV41_ENGRAM_HOST_TABLE = "0"
  140. SGLANG_FLASHINFER_MOE_FUSED_FINALIZE = "0"
  141. SGLANG_DSV41_REASONING_EFFORT = "100"
  142. PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:False"
  143. CUDA_DEVICE_ORDER = "PCI_BUS_ID"
  144. # Aiden's NCCL pins (4x 200G RoCE fabric, 192.168.200.0/24) — [env] wins over
  145. # the config's [nccl."4nodes-switch"] where they differ
  146. NCCL_NET = "IB"
  147. NCCL_IB_DISABLE = "0"
  148. NCCL_IB_HCA = "rocep1s0f0,roceP2p1s0f0"
  149. NCCL_SOCKET_IFNAME = "enp1s0f0np0"
  150. GLOO_SOCKET_IFNAME = "enp1s0f0np0"
  151. NCCL_IB_ROCE_VERSION_NUM = "2"
  152. NCCL_IB_ADDR_FAMILY = "AF_INET"
  153. NCCL_IB_ADDR_RANGE = "192.168.200.0/24"
  154. NCCL_IB_SUBNET_PREFIX_LEN = "24"
  155. NCCL_CROSS_NIC = "1"
  156. NCCL_IB_MERGE_NICS = "0"
  157. NCCL_IB_SUBNET_AWARE_ROUTING = "1"
  158. NCCL_CUMEM_ENABLE = "0"
  159. NCCL_P2P_DISABLE = "1"
  160. NCCL_SHM_DISABLE = "1"
  161. NCCL_BUFFSIZE = "1048576"
  162. NCCL_LL128_BUFFSIZE = "262144"
  163. NCCL_PROTO = "^LL128"
  164. NCCL_MAX_NCHANNELS = "8"