recipe.toml 7.1 KB

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