recipe.toml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # GLM-5.2 MXFP4-Experts-GPTQ — 4× DGX Spark (GB10, sm_121a), TP=4.
  2. #
  3. # Model: aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  4. # → https://huggingface.co/aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  5. #
  6. # GPTQ-quantized MXFP4 experts for GLM-5.2 (744B MoE, 256 experts/layer,
  7. # 8 activated per token, 78 layers, sparse-MLA). Experts quantized to
  8. # MXFP4 via GPTQ; non-expert layers (attention, indexer, router, lm_head)
  9. # kept in BF16.
  10. #
  11. # Image: aidendle94/sparkrun-vllm-ds4-gb10:production-hybrid-1.2
  12. # vLLM + b12x suite with hybrid_mxfp4_ct quant config, index-authoritative
  13. # loader, NVFP4 KV cache with per-token scaling, sparse-MLA CKV gather.
  14. #
  15. # PREREQUISITES:
  16. # - Weights cached on every node via HF_HOME:
  17. # huggingface-cli download aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  18. # (requires free disk on each node)
  19. #
  20. # REFERENCE:
  21. # https://forums.developer.nvidia.com/t/glm-5-2-hybrid-fp8-nvfp4-mxfp4-optimal-runtime-recipe/377598
  22. # https://huggingface.co/aidendle94/GLM-5.2-MXFP4-Experts-GPTQ
  23. engine = "vllm"
  24. name = "GLM-5.2 MXFP4-Experts-GPTQ (vLLM)"
  25. docker_image = "sparkrun-vllm-ds4-gb10:glm52"
  26. model = "aidendle94/GLM-5.2-MXFP4-Experts-GPTQ"
  27. parent_model = "zai-org/GLM-5.2"
  28. required_nodes = 4
  29. tensor_parallel_size = 4
  30. pipeline_parallel_size = 1
  31. distributed_backend = "mp"
  32. shm_size = "10gb"
  33. docker_image_dir = "glm52"
  34. entrypoint = ["vllm", "serve"]
  35. args = [
  36. # Model name
  37. "--served-model-name", "glm52",
  38. # General
  39. "--trust-remote-code",
  40. "--reasoning-parser", "glm45",
  41. "--tool-call-parser", "glm47",
  42. "--enable-auto-tool-choice",
  43. "--enable-prefix-caching",
  44. # DCP (Decode Context Parallelism)
  45. "--decode-context-parallel-size", "4",
  46. "--dcp-comm-backend", "ag_rs",
  47. # Engine backends
  48. "--attention-backend", "B12X_MLA_SPARSE",
  49. # HF overrides — 78-char index_topk_pattern (GLM-5.2 MLP/expert routing)
  50. "--hf-overrides", """
  51. '{"index_topk_pattern":"FFFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSSFSSS"}'""",
  52. # KV cache — NVFP4 with per-token scaling (nvfp4_ds_mla)
  53. "--kv-cache-dtype", "nvfp4_ds_mla",
  54. "--kv-cache-memory-bytes", "5500000000",
  55. # Context & batch config
  56. "--max-model-len", "262144",
  57. "--max-num-batched-tokens", "2048",
  58. "--max-num-seqs", "3",
  59. "--gpu-memory-utilization", "0.89",
  60. # Speculative decode — MTP k=4 with adaptive depths
  61. # {{mtp_draft}} is substituted per-node with the resolved HF cache path
  62. # (refs/main → latest snapshot) so symlinks resolve correctly.
  63. "--speculative-config", """
  64. '{"model":"{{mtp_draft}}","method":"mtp","num_speculative_tokens":4,"draft_attention_backend":"B12X_MLA_SPARSE","adaptive_speculative_tokens_window":32}'""",
  65. # Compilation — FULL_AND_PIECEWISE with all custom ops, 8 capture sizes
  66. "--compilation-config", """
  67. '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"],"cudagraph_capture_sizes":[1,2,3,4,5,6,8]}'""",
  68. # Timeout safety net (cold boot: ranks finish minutes apart)
  69. "--distributed-timeout-seconds", "3600",
  70. "--cpu-distributed-timeout-seconds", "3600",
  71. ]
  72. # Persistent JIT/torch-inductor cache (avoids ~20 min recompilation on cold boot).
  73. # `alias = "jit_cache"` resolves via [mount_aliases] in config.toml; if absent,
  74. # falls back to host "~/.cache/jit" (expanded to /home/<ssh_user>/.cache/jit).
  75. # `env` injects -e XDG_CACHE_HOME=/root/.cache/jit so vLLM/torch write there.
  76. [[extra_mounts]]
  77. alias = "jit_cache"
  78. host = "~/.cache/jit"
  79. container = "/root/.cache/jit"
  80. env = "XDG_CACHE_HOME"
  81. # MTP draft model — a subfolder of the main GLM-5.2 repo. Resolved at serve
  82. # time, per node, from the HF cache (refs/main → latest snapshot), so the
  83. # path survives `huggingface-cli download` updates without a fragile symlink.
  84. # The recipe references {{mtp_draft}} in --speculative-config; the launcher
  85. # substitutes the resolved full HF cache path per-node (no bind-mount — the
  86. # HF cache is already mounted at /root/.cache/huggingface, so symlinks
  87. # resolve correctly).
  88. [[extra_mounts]]
  89. repo = "aidendle94/GLM-5.2-MXFP4-Experts-GPTQ"
  90. subfolder = "mtp-draft"
  91. container = "mtp_draft"
  92. [env]
  93. # ── b12x suite ────────────────────────────────────────────────────────────
  94. VLLM_USE_V2_MODEL_RUNNER = "1"
  95. VLLM_USE_B12X_MOE = "1"
  96. VLLM_USE_B12X_SPARSE_INDEXER = "1"
  97. VLLM_DCP_SHARD_DRAFT = "1"
  98. VLLM_DCP_GLOBAL_TOPK = "1"
  99. VLLM_DSV4_INDEXER_SP = "1"
  100. # ── MLA CKV gather (sparse gather for decode) ─────────────────────────────
  101. VLLM_B12X_MLA_CKV_GATHER = "1"
  102. VLLM_B12X_MLA_CKV_GATHER_MAX_TOKENS = "262144"
  103. VLLM_B12X_MLA_DECODE_SPARSE_GATHER = "1"
  104. VLLM_B12X_MLA_DECODE_GATHER_V2 = "1"
  105. # ── Speculative decode ────────────────────────────────────────────────────
  106. VLLM_ADAPTIVE_SPEC_DEPTHS = "2,4"
  107. # ── NVFP4 KV cache ────────────────────────────────────────────────────────
  108. VLLM_NVFP4_MLA_PER_TOKEN_SCALE = "1"
  109. # ── Timeout safety net ────────────────────────────────────────────────────
  110. VLLM_ENGINE_READY_TIMEOUT_S = "3600"
  111. VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS = "1800"
  112. VLLM_ALLOW_LONG_MAX_MODEL_LEN = "1"
  113. # ── MUST unset baked VLLM_PREFIX_CACHE_RETENTION_INTERVAL ─────────────────
  114. # The image bakes a value that GLM-5.2's KV coordinator rejects.
  115. # Empty string = unset at runtime.
  116. VLLM_PREFIX_CACHE_RETENTION_INTERVAL = ""
  117. # ── Architecture (aarch64/sm_121a DGX Spark) ──────────────────────────────
  118. CUTE_DSL_ARCH = "sm_121a"
  119. TORCH_CUDA_ARCH_LIST = "12.1a"
  120. # ── JIT cache ──────────────────────────────────────────────────────────────
  121. # Persisted via the [[extra_mounts]] jit_cache entry above: XDG_CACHE_HOME is
  122. # injected from that mount, pointing at /root/.cache/jit (no hardcoded dupe).
  123. # ── NCCL overrides ─────────────────────────────────────────────────────────
  124. # Cluster config provides NCCL_IB_HCA, NCCL_IB_GID_INDEX, NCCL_SOCKET_IFNAME
  125. # Launcher defaults: NCCL_IGNORE_CPU_AFFINITY=1, NCCL_NET=IB, NCCL_DEBUG=WARN
  126. NCCL_IB_DISABLE = "0" # enable IB (override launcher default)
  127. NCCL_MAX_NCHANNELS = "4"
  128. NCCL_MIN_NCHANNELS = "4"
  129. NCCL_CUMEM_ENABLE = "0"
  130. # ── Compute ────────────────────────────────────────────────────────────────
  131. OMP_NUM_THREADS = "4"
  132. # Volumes not needed — model is a Hugging Face Hub ID, downloaded via HF_HOME