recipe.toml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # GLM-5.2 QuantTrio Int4-Int8Mix — 4× DGX Spark / GB10 (sm_121), TP=4.
  2. # MTP k=4, cudagraph FULL, prefix caching, fp8_ds_mla KV, 350k ctx.
  3. #
  4. # Model: QuantTrio/GLM-5.2-Int4-Int8Mix (mixed Int4/Int8, 10% expert-pruned)
  5. # → https://huggingface.co/QuantTrio/GLM-5.2-Int4-Int8Mix
  6. # MTP draft: CosmicRaisins/GLM-5.2-MTP-INT4-aligned
  7. # → https://huggingface.co/CosmicRaisins/GLM-5.2-MTP-INT4-aligned
  8. #
  9. # BUILD THE IMAGE FIRST:
  10. # Reference: https://github.com/CosmicRaisins/glm-5.2-gb10
  11. # The custom image vllm-node-tf5-glm52-b12x:probe is built from eugr/spark-vllm-docker
  12. # fork at pinned ref ab666069935c1f23e8ef56038b4659ac9e8f19f8, then applies mods
  13. # glm52-sm12x-sparse and glm52-b12x-sparse on top. See the repo's bootstrap.sh
  14. # for the full build-and-copy workflow.
  15. #
  16. # 1) git clone https://github.com/eugr/spark-vllm-docker
  17. # 2) cd spark-vllm-docker && ./build-and-copy.sh \
  18. # --vllm-ref ab666069935c1f23e8ef56038b4659ac9e8f19f8 \
  19. # -t vllm-node-tf5-glm52-b12x:probe --tf5
  20. # 3) Bake mods glm52-sm12x-sparse + glm52-b12x-sparse into the image
  21. # (see Dockerfile.glm52-consolidated in the repo)
  22. #
  23. # PREREQUISITES:
  24. # - NCCL 2.30.4 staged on every node at /root/.cache/huggingface/hub/nccl-2.30.4/libnccl.so.2
  25. # (the image LD_PRELOADs it). Get it with:
  26. # pip install --no-deps -d /tmp/ncclwheel nvidia-nccl-cu13==2.30.4 && mkdir -p ... && unzip ...
  27. # - Weights cached on every node:
  28. # huggingface-cli download QuantTrio/GLM-5.2-Int4-Int8Mix
  29. # huggingface-cli download CosmicRaisins/GLM-5.2-MTP-INT4-aligned
  30. #
  31. # TUNING NOTES (from community):
  32. # - gpu-memory-utilization 0.92 is the sweet spot for 350k ctx on 4× GB10 with MTP
  33. # - MTP k=4 is more reliable on startup than k=5 on GB10
  34. # - cudagraph FULL requires b12x installed; without it, use PIECEWISE
  35. engine = "vllm"
  36. name = "GLM-5.2 Int4-Int8Mix (vLLM)"
  37. docker_image = "vllm-node-tf5-glm52-b12x:probe"
  38. model = "QuantTrio/GLM-5.2-Int4-Int8Mix"
  39. port = 8210
  40. required_nodes = 4
  41. tensor_parallel_size = 4
  42. pipeline_parallel_size = 1
  43. distributed_backend = "mp"
  44. shm_size = "64gb"
  45. entrypoint = ["vllm", "serve"]
  46. args = [
  47. # Reasoning & tools
  48. "--reasoning-parser", "glm45",
  49. "--tool-call-parser", "glm47",
  50. "--enable-auto-tool-choice",
  51. # KV cache & memory
  52. "--kv-cache-dtype", "fp8_ds_mla",
  53. "--max-model-len", "262144",
  54. "--max-num-seqs", "1",
  55. "--max-num-batched-tokens", "4096",
  56. "--gpu-memory-utilization", "0.92",
  57. # Compilation (b12x required for FULL cudagraph)
  58. "--compilation-config", """
  59. '{"cudagraph_mode":"FULL"}'""",
  60. # MTP speculative decoding
  61. "--speculative-config", """
  62. '{"model":"/root/.cache/huggingface/hub/glm52-mtp-int4-aligned","method":"mtp","num_speculative_tokens":4,"attention_backend":"FLASHMLA_SPARSE"}'""",
  63. # Other
  64. "--trust-remote-code",
  65. "--enable-prefix-caching",
  66. "--enable-flashinfer-autotune",
  67. "--served-model-name", "glm52",
  68. ]
  69. [env]
  70. # Timeout safety net for cold boot (cudagraph + JIT)
  71. VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS = "1800"
  72. # NCCL shm_broadcast fix
  73. LD_PRELOAD = "/root/.cache/huggingface/hub/nccl-2.30.4/libnccl.so.2"
  74. # Offline mode — weights must be cached on each node
  75. HF_HOME = "/root/.cache/huggingface"
  76. TRITON_CACHE_DIR = "/root/.cache/huggingface/.tritoncache"
  77. HF_HUB_OFFLINE = "1"
  78. TRANSFORMERS_OFFLINE = "1"
  79. # GLM-5.2 sparse-MLA suite (these guard the Triton fallback paths on sm_121)
  80. VLLM_ALLOW_LONG_MAX_MODEL_LEN = "1"
  81. VLLM_SPARSE_INDEXER_MAX_LOGITS_MB = "256"
  82. GLM52_BIND_HOST_TRITON = "1"
  83. GLM52_MQA_LOGITS_TRITON = "1"
  84. GLM52_PAGED_MQA_TRITON = "1"
  85. GLM52_PAGED_MQA_TOPK_CHUNK_SIZE = "8192"
  86. GLM52_B12X_MLA = "1"
  87. TORCH_CUDA_ARCH_LIST = "12.1a"
  88. # NCCL / RoCE (launcher auto-sets most; recipe env wins last)
  89. NCCL_NET = "IB"
  90. NCCL_IB_DISABLE = "0"
  91. NCCL_IB_GID_INDEX = "3"
  92. NCCL_CROSS_NIC = "1"
  93. NCCL_CUMEM_ENABLE = "0"
  94. NCCL_IGNORE_CPU_AFFINITY = "1"
  95. NCCL_DEBUG = "WARN"
  96. # MoE & compute
  97. OMP_NUM_THREADS = "8"
  98. [mods]
  99. commands = [
  100. # Copy Triton sparse-MLA kernel files into the vLLM tree inside the container.
  101. # These are mounted via the mods system at /mods/glm52-sm12x-sparse/ and copied
  102. # into the vLLM Python package paths before the engine starts.
  103. "cp /mods/glm52-sm12x-sparse/sparse_mla_kernels.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/mla/",
  104. "cp /mods/glm52-sm12x-sparse/sparse_mla_env.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/mla/",
  105. "cp /mods/glm52-sm12x-sparse/sm12x_sparse_mla_attn.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/mla/",
  106. "cp /mods/glm52-sm12x-sparse/patch_flashmla_ops.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/mla/",
  107. "cp /mods/glm52-sm12x-sparse/flashmla_sparse.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/mla/",
  108. "cp /mods/glm52-sm12x-sparse/sm12x_deep_gemm_fallbacks.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/ops/deepseek_v4_ops/",
  109. "cp /mods/glm52-sm12x-sparse/sm12x_mqa.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/ops/deepseek_v4_ops/",
  110. "cp /mods/glm52-sm12x-sparse/b12x_sparse_helpers.py /usr/local/lib/python3.12/dist-packages/vllm/v1/attention/ops/deepseek_v4_ops/",
  111. # upstream vLLM #46862: fused indexer Q rope+fp8-quant
  112. "cp /mods/glm52-sm12x-sparse/sparse_attn_indexer.py /usr/local/lib/python3.12/dist-packages/vllm/model_executor/layers/",
  113. "cp /mods/glm52-sm12x-sparse/deepseek_v2.py /usr/local/lib/python3.12/dist-packages/vllm/model_executor/models/",
  114. ]