recipe.toml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # GLM-5.2 NF3-Hybrid — 🧠 CONTEXT LANE (DCP4, 800K max-len)
  2. # 4× DGX Spark (GB10, aarch64/sm_121a), TP=4, DCP=4.
  3. #
  4. # Model: madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid
  5. # → https://huggingface.co/madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid
  6. #
  7. # Unpruned GLM-5.2 (753B/40B MoE, all 256 experts) in 3-format hybrid quant:
  8. # 327GB — top-64 experts/layer in NVFP4, remaining 192 in NF3 (3-bit),
  9. # non-expert layers in MXFP8.
  10. #
  11. # BUILD THE IMAGE FIRST:
  12. # cd docker-images/glm52-nf3-hybrid && bash build.sh
  13. # cd docker-images/glm52-nf3-hybrid && bash build.sh
  14. # Produces image: vllm-nf3-hybrid:probe
  15. #
  16. # DCP4 lane: KV sharded across all 4 nodes → 877K-token pool.
  17. # Every decode step pays ag_rs allreduce on all 78 layers.
  18. # MTP k=3 (needs fuse_allreduce_rms) — near-perfect acceptance ~3.0
  19. # beat k=4/5 by ~8% on long network-taxed steps.
  20. #
  21. # Performance (measured 2026-07-07, 512-tok gens, temp 0, shallow ctx):
  22. # c1: 21.4–21.6 tok/s | c2: 32.9 | c3: 38.9
  23. # c4: 45.4 | c5: 37.4 | c6: 40.1 aggregate
  24. # KV pool: 877,056 tokens | max-model-len: 800,000
  25. # Boot ~20 min, MTP k=3 acceptance ~3.0
  26. #
  27. # TUNING NOTES:
  28. # - gpu-memory-utilization 0.88 (GB10 unified memory; author's 0.96 is
  29. # dedicated-VRAM territory)
  30. # - max-num-batched-tokens ≥2048 or NF3 graph capture breaks
  31. # - max-cudagraph-capture-size must cover seqs×(1+k) = 4×4 = 16
  32. # - VLLM_DCP_SHARD_DRAFT=1 mandatory for MTP draft KV under DCP
  33. # - k is lane-specific: CONTEXT lane runs k=3 + fuse_allreduce_rms
  34. #
  35. # PREREQUISITES:
  36. # - Weights cached on every node:
  37. # huggingface-cli download madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid
  38. # (327GB, 334GB on disk, 96 safetensors shards)
  39. engine = "vllm"
  40. name = "GLM-5.2 NF3-Hybrid CONTEXT LANE (vLLM)"
  41. docker_image = "vllm-nf3-hybrid:probe"
  42. model = "madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid"
  43. required_nodes = 4
  44. tensor_parallel_size = 4
  45. pipeline_parallel_size = 1
  46. distributed_backend = "mp"
  47. shm_size = "64gb"
  48. docker_image_dir = "glm52-nf3-hybrid"
  49. entrypoint = ["vllm", "serve"]
  50. args = [
  51. # Quantization & KV cache
  52. "--quantization", "modelopt_fp4",
  53. "--kv-cache-dtype", "fp8",
  54. "--load-format", "auto",
  55. # "--load-format", "fastsafetensors",
  56. # Context length (800K max-len, 877K KV pool)
  57. "--max-model-len", "800000",
  58. # Batch & memory
  59. "--max-num-seqs", "4",
  60. "--max-num-batched-tokens", "4096",
  61. "--max-cudagraph-capture-size", "32",
  62. "--gpu-memory-utilization", "0.92",
  63. # Engine backends
  64. "--attention-backend", "B12X_MLA_SPARSE",
  65. "--moe-backend", "b12x",
  66. # Scheduling
  67. "--async-scheduling",
  68. "--enable-chunked-prefill",
  69. "--enable-prefix-caching",
  70. # Compilation (CONTEXT: fuse_allreduce_rms for DCP network tax)
  71. "--compilation-config", """
  72. '{"pass_config":{"fuse_allreduce_rms":true}}'""",
  73. # Speculative decode — CONTEXT: MTP k=3 (near-perfect acceptance ~3.0)
  74. "--speculative-config", """
  75. '{"method":"mtp","num_speculative_tokens":3,"moe_backend":"b12x","draft_sample_method":"probabilistic"}'""",
  76. # Tool calling & reasoning (verified working from first boot)
  77. "--tool-call-parser", "glm47",
  78. "--reasoning-parser", "glm45",
  79. "--enable-auto-tool-choice",
  80. # General
  81. "--trust-remote-code",
  82. "--enable-flashinfer-autotune",
  83. "--served-model-name", "glm-5.2",
  84. ]
  85. [env]
  86. # ── DCP (Decode Context Parallelism) — CONTEXT: DCP4 ──────────────────────
  87. # KV sharded across all 4 nodes — 4× pool, decode pays ag_rs gather
  88. DECODE_CONTEXT_PARALLEL_SIZE = "4"
  89. DCP_COMM_BACKEND = "ag_rs"
  90. DCP_KV_CACHE_INTERLEAVE_SIZE = "1"
  91. # ── b12x suite (required) ─────────────────────────────────────────────────
  92. VLLM_USE_V2_MODEL_RUNNER = "1"
  93. VLLM_USE_B12X_FP8_GEMM = "1"
  94. VLLM_USE_B12X_MOE = "1"
  95. VLLM_USE_B12X_SPARSE_INDEXER = "1"
  96. VLLM_DCP_GLOBAL_TOPK = "1"
  97. VLLM_DCP_SHARD_DRAFT = "1"
  98. B12X_W4A16_TC_DECODE = "1"
  99. B12X_MOE_FORCE_A16 = "1"
  100. B12X_DENSE_SPLITK_TURBO = "1"
  101. # ── Hybrid loader knobs (v2) ──────────────────────────────────────────────
  102. HYBRID_TIER = "both"
  103. HYBRID_KEPT = "b12x_nf3"
  104. HYBRID_NF3 = "b12x_nf3"
  105. HYBRID_B12X_MAX_TOKENS = "4096"
  106. HYBRID_MXFP8_NATIVE = "1"
  107. # Real path to tier json inside the image (loader hardcodes /opt/venv layout)
  108. HYBRID_MXFP8_TIER_JSON = "/usr/local/lib/python3.12/dist-packages/mxfp8_tier.json"
  109. # ── Architecture (aarch64/sm_121a DGX Spark) ──────────────────────────────
  110. TORCH_CUDA_ARCH_LIST = "12.1a"
  111. CUTE_DSL_ARCH = "sm_121a"
  112. FLASHINFER_CUDA_ARCH_LIST = "12.1a"
  113. # ── Offline mode (weights must be cached on each node) ────────────────────
  114. HF_HOME = "/root/.cache/huggingface"
  115. HF_HUB_OFFLINE = "1"
  116. TRANSFORMERS_OFFLINE = "1"
  117. # ── Timeout safety net (cold boot: cudagraph + JIT) ───────────────────────
  118. VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS = "3600"
  119. # ── NCCL / RoCE (cluster config ib_hca/socket_ifname used for most) ──────
  120. NCCL_CROSS_NIC = "1"
  121. NCCL_CUMEM_ENABLE = "0"
  122. NCCL_IGNORE_CPU_AFFINITY = "1"
  123. NCCL_DEBUG = "WARN"
  124. # ── Compute ────────────────────────────────────────────────────────────────
  125. OMP_NUM_THREADS = "4"