recipe.toml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # DeepSeek-V4.1-Flash on 4x DGX Spark — Mia AI-Lab TP4 production line
  2. # (github.com/MiaAI-Lab/DeepSeek-v4.1-Flash-DGX-Sparks @ cad252b7d3,
  3. # forum /t/382725 posts #136-#156). Their own TP4 profile, adapted to sm121:
  4. # the image is our docker-images/mia-tp4 build (Dockerfile.canary-roce —
  5. # SGLang dsv4.1 branch f80c91a4b + SG17 RoCEnante overlay + b12x/b12x_next,
  6. # everything pinned in runtime/sources.manifest); the boot.py entrypoint is
  7. # bypassed — we launch sglang.launch_server directly, so the flags boot.py
  8. # would emit live in `args` and the gated adapters live in [env] (the image's
  9. # PYTHONPATH/sitecustomize arms them from env alone).
  10. #
  11. # Their production shape (docs/tp4.md, measured 2026-09-25, switched fabric):
  12. # decode prose c1 87.7 tok/s, prefill 4.1-5.9K tok/s cold, 1M context with a
  13. # verified 1,011,084-token needle, qeval 72/75. Claims UNVERIFIED here.
  14. #
  15. # Model: NAS checkpoint via --hf-cache (same dba1be0a snapshot as the
  16. # aiden16 lane). Engram: UNPACKED read path (DSV41_SOURCE = the checkpoint)
  17. # for the v1 boot — their pack_engram.py packing (~48 GiB/rank) is exactly
  18. # our staging P2 (sparse-rows) and waits for that feature; per the repo the
  19. # unpacked worker read is a per-step penalty, so perf here is a floor.
  20. #
  21. # boot.py maps OFFLOAD_MODE=nvme + no DSV41_PACKED_DIR to "rows straight
  22. # from the checkpoint" (adapter/engram_backend.py) — the equivalent of the
  23. # aiden16 NAS fallback, but their engine (row store + prefetch + 4 GiB
  24. # cache). Their served-model-name is kept identical to aiden16 so bench
  25. # providers work unchanged.
  26. #
  27. # If a boot log line from docs/tp4.md's "must show" block is missing, the
  28. # line is not active — grep it: shared-expert padding, indexer chunked
  29. # ARMED, gamma=5/verify_num_draft_tokens=6, RoCEnante ready, moe_b12x_next
  30. # armed/EP_SIZE=1, hc_fused bit-identical, max_running_requests=16.
  31. engine = "sglang"
  32. name = "DeepSeek-V4.1-Flash (SGLang TP4, Mia production line)"
  33. docker_image = "dsv41-4x-spark:mia-tp4"
  34. docker_image_dir = "mia-tp4"
  35. model = "deepseek-ai/DeepSeek-V4.1-Flash"
  36. parent_model = "deepseek-ai/DeepSeek-V4.1-Flash"
  37. port = 30000
  38. required_nodes = 4
  39. tensor_parallel_size = 4
  40. distributed_backend = "mp"
  41. shm_size = "32gb"
  42. entrypoint = ["python3", "-m", "sglang.launch_server"]
  43. # = boot.py serve() + production EXTRA_SGLANG_ARGS, launcher appends
  44. # --model-path/--nnodes/--node-rank/--dist-init-addr/--host/--port.
  45. args = [
  46. "--served-model-name", "deepseek-v4.1-flash",
  47. "--trust-remote-code",
  48. "--load-format", "safetensors",
  49. "--ep-size", "1", # production: tensor-shard all 384 experts
  50. "--attention-backend", "dsv4",
  51. "--moe-runner-backend", "flashinfer_mxfp4",
  52. "--fp8-gemm-backend", "flashinfer_cutlass", # required for the MXFP8 route
  53. "--mem-fraction-static", "0.80",
  54. "--chunked-prefill-size", "4096",
  55. "--context-length", "1048576",
  56. "--max-total-tokens", "8000000", # pinned KV pool (their 0.80 budget)
  57. "--max-running-requests", "16",
  58. "--cuda-graph-max-bs-decode", "16",
  59. "--min-free-slots-delay", "1", # 16 means 16 (delayer default holds ~13)
  60. "--random-seed", "0",
  61. "--enable-decoder-swa-bounded-replay",
  62. "--enable-cache-report",
  63. "--speculative-algorithm", "DSPARK",
  64. "--speculative-dspark-block-size", "5",
  65. "--tool-call-parser", "deepseekv41",
  66. "--reasoning-parser", "deepseek-v41",
  67. "--enable-deepseek-v4-fp4-indexer", # kept to match their measured arg line
  68. "--watchdog-timeout", "1800",
  69. ]
  70. [env]
  71. # Master gate for every TP4 production adapter (sitecustomize's
  72. # _tp4_launcher check — start-tp4.sh sets this; without it the gated
  73. # installs (indexer v3, shared_pad_k, l2_prefetch, moe_b12x_next, …)
  74. # silently stay off and the stock FlashInfer path rejects the 576-wide
  75. # EP1 experts. Must be set before anything else arms.
  76. DSV41_LAUNCHER = "tp4"
  77. # boot.py exports these to the container; the adapters read them from env
  78. # (not from sglang's flags). TP_SIZE is load-bearing: tp3_pad.py defaults to
  79. # 3 when unset, pads heads 64->96 under our TP4 and the sparse-MLA kernel
  80. # aborts on 24 heads/rank. DSV41_TP_PAD=0 is their own TP4 setting (docs/tp4.md:
  81. # everything divides 4, the pad has nothing to fix).
  82. TP_SIZE = "4"
  83. EP_SIZE = "1"
  84. DSV41_TP_PAD = "0"
  85. # ---- image defaults our path must keep explicit ----
  86. OFFLOAD_MODE = "nvme" # never ram (Engram would evict the model)
  87. STATE_PATH = "/state" # boot.py's state dir (sparks tables, api key)
  88. DSV41_SOURCE = "/root/.cache/huggingface/hub/models--deepseek-ai--DeepSeek-V4.1-Flash/snapshots/dba1be0a40aa45a94ad051997016db3960a90277"
  89. SGLANG_FLASHINFER_MOE_FUSED_FINALIZE = "0" # determinism gate
  90. SGLANG_DSV41_REASONING_EFFORT = "100"
  91. PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:False" # True => NaN logits >64-token prefills
  92. # Packed Engram read path (staging P2): [[staging]] below materializes this
  93. # node's rank slice at /home/kilork/mia-state/engram, bind-mounted into the
  94. # container at /state/engram (the mia-state mount). With the files present
  95. # the row store attaches packed; DSV41_SOURCE stays as the unpacked
  96. # fallback if a slice is ever missing.
  97. DSV41_PACKED_DIR = "/state/engram"
  98. # ---- production-line adapter gates (docs/tp4.md "What runs" / EXTRA_CONTAINER_ENV) ----
  99. DSV41_INDEXER_CHUNKED = "1"
  100. SGLANG_DSPARK_FOLDED_SAMPLING = "2"
  101. SGLANG_ROCE_ALLREDUCE = "1"
  102. SGLANG_ROCE_MAX_SIZE = "2097152"
  103. DSV41_ROCE_GATHER = "2097152"
  104. B12X_ROCE_HCA = "rocep1s0f0,roceP2p1s0f0"
  105. B12X_ROCE_CACHE_DIR = "/state/b12x-roce"
  106. B12X_COMPILE_CACHE_DIR = "/state/b12x-compile"
  107. SPARK_PREFILL_TP_SPLIT = "1"
  108. SPARK_PREFILL_TP_MIN_CONTEXT = "32768"
  109. SPARK_PREFILL_TP_MIN_ROWS = "1024"
  110. SGLANG_RUST_BUILD_MODE = "never"
  111. DSV41_FAST_LOAD = "1"
  112. DSV41_FAST_LOAD_EP_SIZE = "1"
  113. DSV41_FAST_LOAD_TP_SLICE = "auto"
  114. DSV41_FAST_LOAD_N_EXPERTS = "384"
  115. DSV41_FAST_LOAD_INFLIGHT_GB = "6"
  116. DSV41_ENGRAM_PREFETCH = "1"
  117. DSV41_CACHE_GIB = "4" # engram row cache (67-76% hits)
  118. DSV41_CACHE_WAYS = "16"
  119. DSV41_SHARED_PAD_K = "1"
  120. DSV41_WO_A_W8 = "1"
  121. DSV41_WO_A_W8_MID = "1"
  122. DSV41_WO_A_W8_DROP = "1"
  123. DSV41_DRAFT_TAU = "0.7"
  124. DSV41_DRAFT_HEAD_FP8 = "1"
  125. DSV41_DRAFT_HEAD_FP8_IMPL = "tp4"
  126. DSV41_BLOCK_VERIFY = "1"
  127. DSV41_FOLDED_FENCE = "1"
  128. DSV41_VERIFY_CAP = "conf:0.1"
  129. DSV41_AUTOTUNE_KEEP = "1"
  130. DSV41_REPLICATED_SPLIT = "wqkv_a,engram.wkv"
  131. DSV41_DRAFT_MAIN_PROJ_SPLIT = "1"
  132. DSV41_ROUTER_LIVE = "1"
  133. DSV41_MOE_B12X_NEXT = "1"
  134. DSV41_MOE_B12X_NEXT_DETERMINISTIC = "1"
  135. DSV41_HC_FUSED = "1"
  136. DSV41_PREFILL_SP = "1"
  137. DSV41_PREFILL_SP_FP8 = "1"
  138. DSV41_L2_PREFETCH = "1"
  139. # ---- fabric / NCCL (their memory fix: 4.7 GiB pinned -> 139 MB; aiden16's
  140. # measured pins for the same NICs, plus Mia's buffer reduction) ----
  141. NCCL_NET = "IB"
  142. NCCL_IB_DISABLE = "0"
  143. NCCL_IB_HCA = "rocep1s0f0,roceP2p1s0f0"
  144. NCCL_SOCKET_IFNAME = "enp1s0f0np0"
  145. GLOO_SOCKET_IFNAME = "enp1s0f0np0"
  146. NCCL_IB_ROCE_VERSION_NUM = "2"
  147. NCCL_IB_ADDR_FAMILY = "AF_INET"
  148. NCCL_IB_ADDR_RANGE = "192.168.200.0/24"
  149. NCCL_IB_SUBNET_PREFIX_LEN = "24"
  150. NCCL_CROSS_NIC = "1"
  151. NCCL_IB_MERGE_NICS = "0"
  152. NCCL_IB_SUBNET_AWARE_ROUTING = "1"
  153. NCCL_CUMEM_ENABLE = "0"
  154. NCCL_P2P_DISABLE = "1"
  155. NCCL_SHM_DISABLE = "1"
  156. NCCL_BUFFSIZE = "1048576"
  157. NCCL_LL128_BUFFSIZE = "262144"
  158. NCCL_PROTO = "^LL128"
  159. NCCL_MAX_NCHANNELS = "8"
  160. [[extra_mounts]]
  161. # boot.py's state dir: dspark tables (future), b12x jit/roce caches; per-node host dir
  162. host = "/home/kilork/mia-state"
  163. container = "/state"
  164. # ---- staging (spec: specs/tech-architecture/staging-feature.md) ----
  165. # Per-rank Engram rows packed onto node-local NVMe (staging P2, packed-bin):
  166. # rows split by launch rank (rank r owns rows r*rows/tp .. (r+1)*rows/tp),
  167. # derived from the checkpoint header at stage time. First serve packs from
  168. # the NAS snapshot (~7 min/layer/node, all nodes in parallel); later serves
  169. # verify sampled row hashes against the ledger and pack only what changed.
  170. [[staging]]
  171. kind = "sparse-rows"
  172. id = "engram"
  173. src = "{{hf}}/hub/models--deepseek-ai--DeepSeek-V4.1-Flash/snapshots/dba1be0a40aa45a94ad051997016db3960a90277"
  174. dst = "/home/kilork/mia-state/engram"
  175. min_free = "55G"