recipe.toml 7.2 KB

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