recipe.toml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # GLM-5.2 NF4 Lloyd-Experts-GPTQ — 4× DGX Spark (GB10, sm_121a), TP=4, DCP=4.
  2. #
  3. # Model: aidendle94/GLM-5.2-NF4-Lloyd-Experts-GPTQ
  4. # → https://huggingface.co/aidendle94/GLM-5.2-NF4-Lloyd-Experts-GPTQ
  5. #
  6. # Lloyd-codebook NF4 routed-expert overlay for GLM-5.2 (744B MoE, 256
  7. # experts/layer, 8 activated/token, 78 layers, sparse-MLA). Expert weights
  8. # quantized to 4-bit with a fitted Lloyd–Max codebook (−16.8% expert
  9. # reconstruction error vs E2M1/MXFP4 baseline on the same GPTQ pipeline).
  10. # Codes are indices into per-layer grids/L{n}.json — NOT the E2M1 table.
  11. #
  12. # LOADING: the Lloyd repo is experts-only (L{n}.safetensors + grids/). It
  13. # cannot be served standalone. The base checkpoint is
  14. # aidendle94/GLM-5.2-MXFP4-Experts-GPTQ (full model: config.json with
  15. # quant_method="hybrid_mxfp4_ct", hybrid-ct-*.safetensors non-expert weights
  16. # in block-FP8/NVFP4, tokenizer, mtp-draft). The Lloyd NF4 experts overlay
  17. # the MXFP4 experts for layers 3–77 (all 75 MoE layers) via the nf4_e8m0_k32
  18. # kernel baked into production-hybrid-1.4, activated per-layer by
  19. # VLLM_NF4_LAYERS. The Lloyd repo path is resolved per-node from the HF
  20. # cache (refs/main → latest snapshot) and substituted into VLLM_NF4_EXPERTS_PATH.
  21. #
  22. # Image: sparkrun-vllm-ds4-gb10:glm52
  23. # Built from docker-images/glm52/Dockerfile, which FROMs
  24. # aidendle94/sparkrun-vllm-ds4-gb10:production-hybrid-1.4 (bakes the
  25. # nf4_e8m0_k32 / nf4_packed kernel — inert without VLLM_NF4_LAYERS).
  26. #
  27. # PREREQUISITES:
  28. # - Both repos cached on every node via HF_HOME:
  29. # huggingface-cli download aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  30. # huggingface-cli download aidendle94/GLM-5.2-NF4-Lloyd-Experts-GPTQ
  31. # (MXFP4 base ~390 GB, Lloyd experts ~385 GB)
  32. #
  33. # REFERENCE:
  34. # https://huggingface.co/aidendle94/GLM-5.2-NF4-Lloyd-Experts-GPTQ
  35. # https://huggingface.co/aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  36. engine = "vllm"
  37. name = "GLM-5.2 NF4 Lloyd-Experts-GPTQ (vLLM)"
  38. docker_image = "sparkrun-vllm-ds4-gb10:glm52"
  39. model = "aidendle94/GLM-5.2-MXFP4-Experts-GPTQ"
  40. required_nodes = 4
  41. tensor_parallel_size = 4
  42. pipeline_parallel_size = 1
  43. distributed_backend = "mp"
  44. shm_size = "10gb"
  45. docker_image_dir = "glm52"
  46. entrypoint = ["vllm", "serve"]
  47. args = [
  48. # Model name
  49. "--served-model-name", "glm52",
  50. # General
  51. "--trust-remote-code",
  52. "--reasoning-parser", "glm45",
  53. "--tool-call-parser", "glm47",
  54. "--enable-auto-tool-choice",
  55. "--enable-prefix-caching",
  56. # DCP (Decode Context Parallelism)
  57. "--decode-context-parallel-size", "4",
  58. "--dcp-comm-backend", "ag_rs",
  59. # Engine backends
  60. "--attention-backend", "B12X_MLA_SPARSE",
  61. # HF overrides — 78-char index_topk_pattern (GLM-5.2 MLP/expert routing)
  62. "--hf-overrides", """
  63. '{"index_topk_pattern":"FFFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSS"}'""",
  64. # KV cache — NVFP4 with per-token scaling (nvfp4_ds_mla)
  65. "--kv-cache-dtype", "nvfp4_ds_mla",
  66. "--kv-cache-memory-bytes", "5500000000",
  67. # Context & batch config
  68. "--max-model-len", "262144",
  69. "--max-num-batched-tokens", "2048",
  70. "--max-num-seqs", "3",
  71. "--gpu-memory-utilization", "0.89",
  72. # Speculative decode — MTP k=4 with adaptive depths
  73. # {{mtp_draft}} is substituted per-node with the resolved HF cache path
  74. # (refs/main → latest snapshot) so symlinks resolve correctly.
  75. "--speculative-config", """
  76. '{"model":"{{mtp_draft}}","method":"mtp","num_speculative_tokens":4,"draft_attention_backend":"B12X_MLA_SPARSE","adaptive_speculative_tokens_window":32}'""",
  77. # Compilation — FULL_AND_PIECEWISE with all custom ops, 8 capture sizes
  78. "--compilation-config", """
  79. '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"],"cudagraph_capture_sizes":[1,2,3,4,5,6,8]}'""",
  80. # Timeout safety net (cold boot: ranks finish minutes apart)
  81. "--distributed-timeout-seconds", "3600",
  82. "--cpu-distributed-timeout-seconds", "3600",
  83. ]
  84. # Persistent JIT/torch-inductor cache (avoids ~20 min recompilation on cold boot).
  85. # `alias = "jit_cache"` resolves via [mount_aliases] in config.toml; if absent,
  86. # falls back to host "~/.cache/jit" (expanded to /home/<ssh_user>/.cache/jit).
  87. # `env` injects -e XDG_CACHE_HOME=/root/.cache/jit so vLLM/torch write there.
  88. [[extra_mounts]]
  89. alias = "jit_cache"
  90. host = "~/.cache/jit"
  91. container = "/root/.cache/jit"
  92. env = "XDG_CACHE_HOME"
  93. # MTP draft model — from the MXFP4 base checkpoint's repo. Resolved at serve
  94. # time, per node, from the HF cache (refs/main → latest snapshot), so the
  95. # path survives `huggingface-cli download` updates without a fragile symlink.
  96. # The recipe references {{mtp_draft}} in --speculative-config; the launcher
  97. # substitutes the resolved full HF cache path per-node (no bind-mount — the
  98. # HF cache is already mounted at /root/.cache/huggingface, so symlinks
  99. # resolve correctly).
  100. [[extra_mounts]]
  101. repo = "aidendle94/GLM-5.2-MXFP4-Experts-GPTQ"
  102. subfolder = "mtp-draft"
  103. container = "mtp_draft"
  104. # Lloyd NF4 expert overlay — the Lloyd repo is experts-only (L{n}.safetensors
  105. # + grids/L{n}.json codebooks). Resolved at serve time, per node, from the HF
  106. # cache (refs/main → latest snapshot). The launcher substitutes
  107. # {{lloyd_experts}} into VLLM_NF4_EXPERTS_PATH below, giving the 1.4 image's
  108. # baked-in nf4_e8m0_k32 kernel the path to the per-layer expert weights.
  109. # VLLM_NF4_LAYERS activates the NF4 path for layers 3–77 (all 75 MoE layers).
  110. [[extra_mounts]]
  111. repo = "aidendle94/GLM-5.2-NF4-Lloyd-Experts-GPTQ"
  112. container = "lloyd_experts"
  113. [env]
  114. # ── NF4 Lloyd expert overlay ──────────────────────────────────────────────
  115. # Activates the nf4_e8m0_k32 kernel (baked in production-hybrid-1.4) for
  116. # layers 3–77 (all 75 MoE layers). {{lloyd_experts}} is substituted per-node
  117. # with the resolved HF cache path to the Lloyd repo snapshot.
  118. VLLM_NF4_LAYERS = "3-77"
  119. VLLM_NF4_EXPERTS_PATH = "{{lloyd_experts}}"
  120. # ── b12x suite ────────────────────────────────────────────────────────────
  121. VLLM_USE_V2_MODEL_RUNNER = "1"
  122. VLLM_USE_B12X_MOE = "1"
  123. VLLM_USE_B12X_SPARSE_INDEXER = "1"
  124. VLLM_DCP_SHARD_DRAFT = "1"
  125. VLLM_DCP_GLOBAL_TOPK = "1"
  126. VLLM_DSV4_INDEXER_SP = "1"
  127. # ── MLA CKV gather (sparse gather for decode) ─────────────────────────────
  128. VLLM_B12X_MLA_CKV_GATHER = "1"
  129. VLLM_B12X_MLA_CKV_GATHER_MAX_TOKENS = "262144"
  130. VLLM_B12X_MLA_DECODE_SPARSE_GATHER = "1"
  131. VLLM_B12X_MLA_DECODE_GATHER_V2 = "1"
  132. # ── Speculative decode ────────────────────────────────────────────────────
  133. VLLM_ADAPTIVE_SPEC_DEPTHS = "2,4"
  134. # ── NVFP4 KV cache ────────────────────────────────────────────────────────
  135. VLLM_NVFP4_MLA_PER_TOKEN_SCALE = "1"
  136. # ── Timeout safety net ────────────────────────────────────────────────────
  137. VLLM_ENGINE_READY_TIMEOUT_S = "3600"
  138. VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS = "1800"
  139. VLLM_ALLOW_LONG_MAX_MODEL_LEN = "1"
  140. # ── MUST unset baked VLLM_PREFIX_CACHE_RETENTION_INTERVAL ─────────────────
  141. # The image bakes a value that GLM-5.2's KV coordinator rejects.
  142. # Empty string = unset at runtime.
  143. VLLM_PREFIX_CACHE_RETENTION_INTERVAL = ""
  144. # ── Architecture (aarch64/sm_121a DGX Spark) ──────────────────────────────
  145. CUTE_DSL_ARCH = "sm_121a"
  146. TORCH_CUDA_ARCH_LIST = "12.1a"
  147. # ── JIT cache ──────────────────────────────────────────────────────────────
  148. # Persisted via the [[extra_mounts]] jit_cache entry above: XDG_CACHE_HOME is
  149. # injected from that mount, pointing at /root/.cache/jit (no hardcoded dupe).
  150. # ── NCCL overrides ─────────────────────────────────────────────────────────
  151. # Cluster config provides NCCL_IB_HCA, NCCL_IB_GID_INDEX, NCCL_SOCKET_IFNAME
  152. # Launcher defaults: NCCL_IGNORE_CPU_AFFINITY=1, NCCL_NET=IB, NCCL_DEBUG=WARN
  153. NCCL_IB_DISABLE = "0" # enable IB (override launcher default)
  154. NCCL_MAX_NCHANNELS = "4"
  155. NCCL_MIN_NCHANNELS = "4"
  156. NCCL_CUMEM_ENABLE = "0"
  157. # ── Compute ────────────────────────────────────────────────────────────────
  158. OMP_NUM_THREADS = "4"