recipe.toml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. # P0 PROBE variant of ../glm53-full-mxfp4-4x — night-shift ladder, step 1:
  2. # no DCP, 131072 ctx, 4 GiB KV pin. The cheapest configuration that still
  3. # exercises the full stack (checkpoint load, MoE path, arch dispatch, no MTP)
  4. # with the least memory at risk. If it boots and the numerics smoke passes,
  5. # promote to the DCP4/512K sibling. If it fails, the cause is stack-level,
  6. # not context-level — fix there before spending another 45-minute load.
  7. #
  8. # GLM-5.3 (FULL, non-Flash) MXFP4 — RedHatAI official quant — 4× DGX Spark, TP=4.
  9. #
  10. # REPLACES the failed full-model variant: `local-inference-lab/GLM-5.3-NVFP4-Spark`
  11. # (406 GiB → 101.5 GiB weights/node → OOM-proven on 4 nodes 2026-09-08/09: the
  12. # engine crash-restarted and began a SECOND full load while the first copy was
  13. # still resident → 2×101.5 > 121.63 GiB → all four nodes OOM-thrashed, sshd down
  14. # on 3 of 4, HA power-cycle required). That checkpoint is abandoned (recipes
  15. # glm53-full-nvfp4-spark-lab / -aiden / glm53-spark-nvfp4-4x deleted).
  16. #
  17. # THIS checkpoint: RedHatAI/GLM-5.3-MXFP4 — 403.4 GB (375.6 GiB) → 100.85 GB
  18. # (93.9 GiB) weights/node on 4x. ~7.6 GiB/node more headroom than the NVFP4
  19. # attempt, which is what makes 4x plausible at all. LLM-Compressor
  20. # (compressed-tensors) quant: "mxfp4-pack-quantized", weights FP4-e2m1 group-32
  21. # with E8M0 scales, dynamic per-group FP4 activations; mlp.gate / lm_head /
  22. # embed_tokens / eh_proj / indexer.{wk,weights_proj} stay bf16.
  23. # Model: https://huggingface.co/RedHatAI/GLM-5.3-MXFP4
  24. # Parent: zai-org/GLM-5.3 (FP8). Card: gsm8k 96.36 vs 97.60 (FP8) = 98.7%
  25. # recovery; ifeval 89.25 vs 93.53 = 95.4%.
  26. # Card's serving recipe (4× B200): --kv-cache-dtype fp8_e4m3 --tp 4
  27. # --reasoning-parser glm45 --speculative-config '{"method":"mtp","num_speculative_tokens":5}'
  28. #
  29. # GEOMETRY (config.json, verified 2026-09-13): arch GlmMoeDsaForCausalLM
  30. # (model_type glm_moe_dsa), 78 layers, hidden 6144, 256 routed experts + 1
  31. # shared, top-8, moe_inter 2048, MLA (kv_lora 512 / q_lora 2048 / qk_nope 192 /
  32. # qk_rope 64 / v 256), DSA lightning indexer (index_topk 2048), 1M native ctx,
  33. # first_k_dense_replace 3, num_nextn_predict_layers 1 (MTP head IN the
  34. # checkpoint), 141 shards, no separate drafter.
  35. # ~740B total params / ~40B active. The Flash variant we serve in prod is
  36. # 320B/18B (45 layers, hidden 4096, 288 experts) — this is a different model.
  37. #
  38. # ── BASE STACK: our own jovian r35 build (docker-images/jovian-judgement +
  39. # build_profile r35 → image jovian-judgement:r35-glm53) ────────────────
  40. # Selected 2026-09-13. Evidence (all verified by read-only inspection of the
  41. # images on dgx1):
  42. # * registers the full-model arch: registry.py →
  43. # "GlmMoeDsaForCausalLM": ("vllm.models.deepseek_v32", ...) — the NEW
  44. # `deepseek_v32` implementation, which is "MLA + a lightning indexer that
  45. # selects the top-k tokens for a sparse MLA" and dispatches to an
  46. # NVIDIA-specific path (deepseek_v32/nvidia/model.py:
  47. # DeepseekV32ForCausalLM as GlmMoeDsaForCausalLM). That is exactly the
  48. # GB10/sm_121a target; the lab fork and aiden's image register the same
  49. # class from the older `deepseek_v2` module instead.
  50. # * ships the MXFP4 scheme: model_executor/layers/quantization/
  51. # compressed_tensors/schemes/compressed_tensors_w4a4_mxfp4.py
  52. # ("mxfp4-pack-quantized") → the RedHat checkpoint loads natively.
  53. # * it is OUR reproducible clone-at-pin build (vLLM de982a50 + b12x 98086604,
  54. # r35 lock 2026-09-11 = newest published lab composition), all gates green,
  55. # patches ours to write — and it is the SAME image our GLM-5.3-Flash 4x
  56. # prod runs, so the A/B vs prod is clean and the JIT caches are warm.
  57. # * the b12x MoE/attention backends are the GB10-tuned ones our GLM prod
  58. # uses (--moe-backend b12x / --attention-backend B12X).
  59. # Rejected: `glm53-flash-nvfp4-lab:local` and aiden's
  60. # `aidendle94/sparkrun-vllm-glm53-gb10:production-1.2` — both older vLLM
  61. # (0.1.dev20051+g487ecf187, `deepseek_v2` GLM class); the lab fork needed two
  62. # SM120 mla_attention hotfix mods to boot the full model at all
  63. # (masked_mha_available AttributeError + forward_mha NotImplementedError, both
  64. # never re-tested — the lane parked). Keep them as a fallback reference only:
  65. # if the r35 deepseek_v32 path trips on the DSA/indexer kernels, port those
  66. # two sed mods (documented in the deleted glm53-full-nvfp4-spark-lab history)
  67. # onto the lab image and re-point docker_image/docker_image_dir.
  68. #
  69. # ── MEMORY PLAN (the binding constraint — read before the first boot) ──────
  70. # 121.63 GiB unified/node. Idle free: 116-117 GiB.
  71. # weights 93.9 GiB (403.4 GB / 4) ← ~101.5 was fatal
  72. # vLLM procs+docker ~12 GiB
  73. # KV pin 8 GiB (--kv-cache-memory-bytes)
  74. # activations + CUDA graphs ~4 GiB
  75. # ⇒ ~118 GiB — tight but inside the node. GMU 0.85 is the ADMISSION
  76. # guardrail only (free ≥ 0.85×121.63 = 103.4 GiB; 0.88 = 107.0 GiB fails
  77. # once the ~12 GiB of starting processes are counted, the 2026-09-08
  78. # #48140 class) — the KV pool is pinned, so GMU does not change capacity.
  79. #
  80. # WHY DCP4: the full model's attention KV is NOT the Flash lane's compact
  81. # MLA cache. The parked run measured ~54 KB/token (4 GiB ↔ ~79.6K tokens;
  82. # "524288 would need 26.34 GiB") vs the Flash lane's ~2 KB/token at 512K.
  83. # Decode-context-parallel-4 shards the KV across the 4 ranks, so the 8 GiB
  84. # pin buys 32 GiB aggregate → a single 524288-token request needs ~27 GiB
  85. # aggregate (≈6.8 GiB/rank) and just fits. Without DCP a 512K request is
  86. # impossible behind these weights. CAVEAT: DCP4 is qualified in r35 for the
  87. # Flash model (CP1/CP4 shapes); it is UNVERIFIED for the full model — if the
  88. # boot rejects it (the GLM C4 page-stride / interleave-multiple-of-4 gates
  89. # that block DFlash2 on 2x), drop --decode-context-parallel-size +
  90. # --cp-kv-cache-interleave-size and lower --max-model-len to fit ~10 GiB of
  91. # aggregate KV (~180K tokens).
  92. #
  93. # --max-model-len 524288 = the operator's floor (128K/131K profiles are not
  94. # usable for us). --max-num-seqs 8 keeps the pool from being shredded by
  95. # short requests; the admission scheduler handles the rest.
  96. #
  97. # ── BOOT PLAN / HAZARD ─────────────────────────────────────────────────────
  98. # The 2026-09-08 disaster was NOT a bad weight footprint per se — it was a
  99. # post-load crash + auto-restart that started a SECOND full load on top of
  100. # the first. Watch the first boot: if the engine logs a second
  101. # "Loading safetensors" pass, kill immediately (`sm121 stop`), do not wait.
  102. # Always `sm121 serve --keep` for the first/unknown boot (default is --rm,
  103. # which wipes the crash logs).
  104. # Ladder if the boot dies: (1) disable DCP4, max-model-len 131072, KV pin
  105. # 4 GiB (prove stack+checkpoint end-to-end, the parked lane's approach);
  106. # (2) then re-add DCP4 + 512K; (3) only then add spec.
  107. # Boot markers to record: "Model loading took X GiB", the KV line
  108. # ("GPU KV cache size: N tokens, Maximum concurrency for 524288 tokens per
  109. # request: Mx"), "Application startup complete". MAX_JOBS=2 below is the
  110. # compile-OOM guard (12 parallel nvcc jobs × ~3 GiB behind 94 GiB of weights
  111. # = cicc OOM-killed, 2026-09-04 lesson).
  112. #
  113. # ── MXFP4 vs NVFP4: what changed, and what is already in our tree ──────────
  114. # The full-model NVFP4 lane is retired (see above), so this checkpoint is the
  115. # lab's MXFP4 family: routed-expert weights FP4-e2m1 with power-of-two (E8M0)
  116. # group-32 scales — the same shape as their own GLM-5.1 MXFP4 repack, which is
  117. # why their GLM-5.1 runbook (models/glm-5.1-mxfp4.md) is the reference for
  118. # this lane even though GLM-5.3 moved on: the MXFP4 ingestion path, the
  119. # FlashInfer Cutlass MXFP4xMXFP8 MoE route, the standard-SwiGLU rule and the
  120. # "do not set B12X_MOE_FORCE_A16" warning all still apply. That runbook also
  121. # unsets empty NCCL graph variables before launch
  122. # (NCCL_GRAPH_FILE / NCCL_GRAPH_DUMP_FILE / VLLM_B12X_MLA_EXTEND_MAX_CHUNKS)
  123. # — unset them in the shell if a previous lane exported them empty; an empty
  124. # value is not the same as an unset one to NCCL.
  125. #
  126. # ── SPECULATIVE DECODING ───────────────────────────────────────────────────
  127. # NOT enabled on the first boot: the checkpoint's MTP head is real
  128. # (num_nextn_predict_layers=1) and the card suggests mtp k=5, but spec adds
  129. # draft KV + graph shapes onto a memory budget that has no room for
  130. # surprises, and the full-model MTP path is unproven on this stack. After a
  131. # clean boot + smoke + bench, add:
  132. # "--speculative-config", """'{"method":"mtp","num_speculative_tokens":3,"attention_backend":"B12X"}'"""
  133. # (k=3 = our Flash prod's verified depth; try 5 after k=3 is clean).
  134. #
  135. # PREREQUISITE: weights in the shared NAS HF cache on all 4 nodes
  136. # (models--RedHatAI--GLM-5.3-MXFP4, 403.4 GB, 141 shards) —
  137. # `hf download RedHatAI/GLM-5.3-MXFP4`; HF_HUB_OFFLINE=1 below makes a
  138. # missing shard a hard load failure. NAS had 16 TB free at 2026-09-13.
  139. #
  140. # A/B TARGET: our GLM-5.3-Flash r35 MTP3 4x prod (dev65/seed 42, hardmode):
  141. # 163/176 (93), 1,554 pp / 49.6 tg / 1,544 ms TTFT @d0 c1, KV 8.06M @512K.
  142. # This lane is a capability/quality lane first (does the full model fit and
  143. # hold 512K on 4 nodes), throughput second.
  144. engine = "vllm"
  145. name = "GLM-5.3 (full) MXFP4 — P0 PROBE: no DCP, 131K, 4 GiB KV (r35 img)"
  146. docker_image = "jovian-judgement:r35-glm53"
  147. docker_image_dir = "jovian-judgement"
  148. # NOTE: build_profile must stay a TOP-LEVEL key — a bare key after
  149. # [[extra_mounts]] would parse into the last mount table and be silently
  150. # ignored (2026-09-08).
  151. build_profile = "r35"
  152. entrypoint = ["vllm", "serve"]
  153. model = "RedHatAI/GLM-5.3-MXFP4"
  154. parent_model = "zai-org/GLM-5.3"
  155. required_nodes = 4
  156. tensor_parallel_size = 4
  157. pipeline_parallel_size = 1
  158. distributed_backend = "mp"
  159. shm_size = "32gb"
  160. args = [
  161. # R31/r35 delta (their qualified locks): adaptive prefill/decode
  162. # compute-time sharing with a fixed 40% prefill floor.
  163. "--prefill-compute-share", "0.4",
  164. # Stable served name — quant-agnostic (shared across glm53 lanes)
  165. "--served-model-name", "glm53",
  166. "--trust-remote-code",
  167. "--distributed-executor-backend", "mp",
  168. # Admission guardrail only (KV is pinned below): 0.85×121.63 = 103.4 GiB.
  169. # 0.88 (107.0) is the Flash lane's value and is too tight here — the full
  170. # model's weights leave ~24 GiB before the engine's own ~12 GiB.
  171. "--gpu-memory-utilization", "0.85",
  172. # 8 GiB/rank pin (measured 2026-09-13: the engine needs 6.58 GiB/rank for
  173. # ONE 131072-token request on this model - 51.6 KB/token/rank, fp8_ds_mla
  174. # KV - so the earlier 4 GiB probe pin could not hold a single full-length
  175. # request; 8 GiB leaves headroom and matches the DCP4/512K sibling).
  176. "--kv-cache-memory-bytes", "8589934592",
  177. # PROBE: no DCP (the sibling has DCP4). Bare TP4: each rank holds the full
  178. # KV sequence, 4 GiB pinned per rank is plenty for a 131K probe.
  179. # No --kv-cache-dtype: let the r35 fork pick its native default for
  180. # GlmMoeDsa attention (the Flash lane's explicit fp8/fp8_ds_mla spellings
  181. # both failed auto-selection on this build, and those were Flash-MLA
  182. # knobs). The card's --kv-cache-dtype fp8_e4m3 is the fallback spelling
  183. # if the pool needs to shrink.
  184. "--attention-backend", "B12X",
  185. # MXFP4 kernel routing (measured on the first boot, 2026-09-13 ~23:10 UTC):
  186. # - MoE: the compressed-tensors W4A4-MXFP4 scheme picks MarlinExperts on
  187. # its own (A16 dequant GEMM - correct on GB10). The --moe-backend flag
  188. # does not reach that scheme (verified inert: it still logged "Using
  189. # MarlinExperts for MXFP4 MoE" with the flag set), so we do not set it.
  190. # - LINEAR: the default priority [FlashInfer, Marlin, Humming, B12x]
  191. # starts with the FlashInfer kernel, whose is_supported() wrongly
  192. # accepts capability 121 (the numeric has_device_capability(100) check
  193. # passes on GB10) while the cute-dsl mm_fp4 GEMM it calls rejects it at
  194. # runtime with:
  195. # BackendSupportedError: mm_fp4 does not support backend 'cute-dsl'
  196. # with capability 121
  197. # (the first probe boot died there, kv_b_proj dequant in mla_attention.py).
  198. # --linear-backend b12x forces the B12xMxFp4LinearKernel - "MXFP4 linear
  199. # through the native B12X SM120 dense GEMM" - the right path on GB10,
  200. # verified per component: is_device_capability_family(120)=True, b12x
  201. # blockscaled.is_supported()=True, and the cute-dsl input quantize
  202. # (flashinfer_mxfp4_quantize) works on capability 121; only the cute-dsl
  203. # mm_fp4 GEMM is unsupported there. Boot log to look for:
  204. # "Using B12xMxFp4LinearKernel for MXFP4 GEMM"
  205. # (The lab's GLM-5.1 runbook describes the same kernel family for the
  206. # quant_method=mxfp4 ingestion path - this checkpoint goes through the
  207. # compressed-tensors path, which is why --moe-backend was the wrong lever.)
  208. # First attempt: b12x (the native SM120 GEMM) - correct selection, but the
  209. # unconditional b12x warmup (b12x_warmup.py, no config gate) crashes on
  210. # this checkpoint's layer shapes during kernel compile:
  211. # RuntimeError: Expected source and destination tensors to have the same
  212. # rank, but got 3 and 4 (b12x/gemm/blockscaled/_linear.py dense_gemm,
  213. # via _apply_b12x_mxfp4_linear on a synthetic zero source)
  214. # so the mxfp4 LINEAR layers run on Marlin (weight-only A16 dequant GEMM -
  215. # the same family as the MarlinExperts the MoE scheme picked). Slower than
  216. # native FP4 for the attention projections, but the MoE experts (the
  217. # dominant cost) are Marlin either way. The b12x warmup rank bug is
  218. # filed-worthy for the lab (RedHatAI GLM-5.3-MXFP4 on GB10/sm_121a).
  219. "--linear-backend", "marlin",
  220. # pure I/O loader (kept across every GLM config)
  221. "--load-format", "instanttensor",
  222. "--block-size", "256",
  223. "--max-model-len", "131072",
  224. "--max-num-seqs", "8",
  225. "--max-num-batched-tokens", "4096",
  226. "--enable-chunked-prefill",
  227. "--async-scheduling",
  228. "--enable-prefix-caching",
  229. # Their proven boot: no flashinfer autotune, no CuTe-DSL warmup (the
  230. # autotune scratch at 512K shapes does not fit the headroom, 2026-08-28).
  231. "--kernel-config", """
  232. '{"enable_cutedsl_warmup":false,"enable_flashinfer_autotune":false}'""",
  233. "--language-model-only",
  234. # NO --speculative-config on the first boot — see the header. MTP head is
  235. # in the checkpoint (num_nextn_predict_layers=1); add mtp k=3 after a
  236. # clean boot + bench.
  237. "--tool-call-parser", "glm47",
  238. "--enable-auto-tool-choice",
  239. "--reasoning-parser", "glm45",
  240. ]
  241. [env]
  242. # R31 lock: 16 NCCL channels (their qualified runtime).
  243. NCCL_NCHANNELS = "16"
  244. HF_HUB_OFFLINE = "1"
  245. # RoCEnante (b12x one-shot RoCE all-reduce/all-gather) — default on for r27+
  246. # lanes since the 2026-09-08 A/B (4x DCP4: decode +31..+90%, quality 160 vs
  247. # 155; specs/tech-architecture/glm53-recipe-state.md). Needs the CX-7 RoCE
  248. # fabric (all of ours); single-node serves skip it silently.
  249. VLLM_ENABLE_ROCE_ALLREDUCE = "1"
  250. # Compile-OOM guard: first boot JIT-compiles the mxfp8 gemm module with 12
  251. # parallel nvcc jobs (~3 GiB each) behind ~94 GiB of resident weights →
  252. # cicc OOM-killed (2026-09-04). flashinfer's run_ninja reads MAX_JOBS.
  253. MAX_JOBS = "2"
  254. # NoPE-MLA rope-pad runtime gate (mod baked into the image)
  255. VLLM_MLA_NOPE_PAD_ROPE = "1"
  256. VLLM_ENGINE_READY_TIMEOUT_S = "3600"
  257. # Upstream launch-script env (memory + compile knobs)
  258. PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True"
  259. VLLM_USE_AOT_COMPILE = "0"
  260. VLLM_USE_STANDALONE_COMPILE = "1"
  261. VLLM_USE_FLASHINFER_SAMPLER = "1"
  262. VLLM_USE_BREAKABLE_CUDAGRAPH = "0"
  263. TORCH_USE_RTLD_GLOBAL = "1"
  264. VLLM_NO_USAGE_STATS = "1"
  265. # Architecture (aarch64 / sm_121a DGX Spark)
  266. TORCH_CUDA_ARCH_LIST = "12.1a"
  267. FLASHINFER_CUDA_ARCH_LIST = "12.1f"
  268. CUTE_DSL_ARCH = "sm_121a"
  269. CMAKE_CUDA_ARCHITECTURES = "121"
  270. OMP_NUM_THREADS = "2"
  271. [[extra_mounts]]
  272. host = "~/sm121-cache/glm53-jit-121f/b12x"
  273. container = "/root/.cache/b12x"
  274. # JIT caches persist per-node across serves (was: cold /root/.cache per
  275. # container -> ~20 min flashinfer/torch recompile every serve). The host
  276. # dirs are shared between lanes of the same arch — each cache
  277. # self-namespaces by its engine version key internally.
  278. [[extra_mounts]]
  279. host = "~/sm121-cache/jit-121f/flashinfer"
  280. container = "/root/.cache/flashinfer"
  281. [[extra_mounts]]
  282. host = "~/sm121-cache/jit-121f/torchinductor"
  283. container = "/root/.cache/torchinductor"
  284. [[extra_mounts]]
  285. host = "~/sm121-cache/jit-121f/vllm"
  286. container = "/root/.cache/vllm"