recipe.toml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # GLM-5.2 NF3-Hybrid — 🏎️ FAST LANE (DCP1, 200K max-len)
  2. # 4× DGX Spark (GB10, aarch64/sm_121a), TP=4, DCP=1.
  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. # Reference: https://github.com/tonyd2wild/GLM-5.2-NF3-Hybrid-4x-DGX-Spark-800kctx
  13. # cd recipes/glm52-nf3-hybrid && ./build.sh
  14. # Produces image: vllm-nf3-hybrid:probe
  15. #
  16. # DCP1 lane: each sequence's KV cache lives entirely on one node → zero
  17. # cross-node attention traffic per decode step. ~1/4 the KV pool of DCP4.
  18. # Best for interactive chat, agents, throughput-sensitive workloads.
  19. #
  20. # Performance (measured 2026-07-07, 512-tok gens, temp 0, MTP acceptance 3.3–4.0):
  21. # c1: 24–29 tok/s (content-dependent, peaks to 29.1 @ accept 4.02)
  22. # c2: 36.6 | c3: 45.7 | c4: 54.2 | c5: 59.2 | c6: 67.4
  23. # KV pool: 219,264 tokens | max-model-len: 200,000
  24. #
  25. # TUNING NOTES:
  26. # - gpu-memory-utilization 0.88 (GB10 unified memory; author's 0.96 is
  27. # dedicated-VRAM territory; 0.88 = safe for 200K + 12e9 KV allocation)
  28. # - kv-cache-memory-bytes 12e9 per node caps KV pool at 219K tokens
  29. # - max-num-batched-tokens ≥2048 or NF3 graph capture breaks
  30. # - max-cudagraph-capture-size must cover seqs×(1+k) = 6×5 = 30
  31. # - FAST lane uses MTP k=4, NO fuse_allreduce_rms (no benefit without
  32. # DCP network tax)
  33. # - k is lane-specific: FAST runs k=4, no fuse
  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 FAST LANE (vLLM)"
  41. docker_image = "vllm-nf3-hybrid:probe"
  42. model = "madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid"
  43. port = 8210
  44. required_nodes = 4
  45. tensor_parallel_size = 4
  46. pipeline_parallel_size = 1
  47. distributed_backend = "mp"
  48. shm_size = "64gb"
  49. entrypoint = ["vllm", "serve"]
  50. args = [
  51. # Quantization & KV cache
  52. "--quantization", "modelopt_fp4",
  53. "--kv-cache-dtype", "fp8",
  54. "--load-format", "fastsafetensors",
  55. # Context length (200K max-len, 219K KV pool)
  56. "--max-model-len", "200000",
  57. # Batch & memory — FAST lane: 6 concurrent, 12e9 KV bytes
  58. "--max-num-seqs", "6",
  59. "--max-num-batched-tokens", "4096",
  60. "--max-cudagraph-capture-size", "32",
  61. "--gpu-memory-utilization", "0.88",
  62. "--kv-cache-memory-bytes", "12000000000",
  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. # Speculative decode — FAST: MTP k=4 (accept 3.3–4.0, best aggregate)
  71. "--speculative-config", """
  72. '{"method":"mtp","num_speculative_tokens":4,"moe_backend":"b12x","draft_sample_method":"probabilistic"}'""",
  73. # Tool calling & reasoning (verified working from first boot)
  74. "--tool-call-parser", "glm47",
  75. "--reasoning-parser", "glm45",
  76. "--enable-auto-tool-choice",
  77. # General
  78. "--trust-remote-code",
  79. "--enable-flashinfer-autotune",
  80. "--served-model-name", "glm-5.2",
  81. ]
  82. [env]
  83. # ── DCP (Decode Context Parallelism) — FAST: DCP1 ────────────────────────
  84. # KV lives locally — zero cross-node attention traffic, ~1/4 pool of DCP4
  85. DECODE_CONTEXT_PARALLEL_SIZE = "1"
  86. DCP_COMM_BACKEND = "ag_rs"
  87. DCP_KV_CACHE_INTERLEAVE_SIZE = "1"
  88. # ── b12x suite (required) ─────────────────────────────────────────────────
  89. VLLM_USE_V2_MODEL_RUNNER = "1"
  90. VLLM_USE_B12X_FP8_GEMM = "1"
  91. VLLM_USE_B12X_MOE = "1"
  92. VLLM_USE_B12X_SPARSE_INDEXER = "1"
  93. VLLM_DCP_GLOBAL_TOPK = "1"
  94. VLLM_DCP_SHARD_DRAFT = "1"
  95. B12X_W4A16_TC_DECODE = "1"
  96. B12X_MOE_FORCE_A16 = "1"
  97. B12X_DENSE_SPLITK_TURBO = "1"
  98. # ── Hybrid loader knobs (v2) ──────────────────────────────────────────────
  99. HYBRID_TIER = "both"
  100. HYBRID_KEPT = "b12x_nf3"
  101. HYBRID_NF3 = "b12x_nf3"
  102. HYBRID_B12X_MAX_TOKENS = "4096"
  103. HYBRID_MXFP8_NATIVE = "1"
  104. HYBRID_MXFP8_TIER_JSON = "/usr/local/lib/python3.12/dist-packages/mxfp8_tier.json"
  105. # ── Architecture (aarch64/sm_121a DGX Spark) ──────────────────────────────
  106. TORCH_CUDA_ARCH_LIST = "12.1a"
  107. CUTE_DSL_ARCH = "sm_121a"
  108. FLASHINFER_CUDA_ARCH_LIST = "12.1a"
  109. # ── Offline mode (weights must be cached on each node) ────────────────────
  110. HF_HOME = "/root/.cache/huggingface"
  111. HF_HUB_OFFLINE = "1"
  112. TRANSFORMERS_OFFLINE = "1"
  113. # ── Timeout safety net (cold boot: cudagraph + JIT) ───────────────────────
  114. VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS = "3600"
  115. # ── NCCL / RoCE (cluster config ib_hca/socket_ifname used for most) ──────
  116. NCCL_CROSS_NIC = "1"
  117. NCCL_CUMEM_ENABLE = "0"
  118. NCCL_IGNORE_CPU_AFFINITY = "1"
  119. NCCL_DEBUG = "WARN"
  120. # ── Compute ────────────────────────────────────────────────────────────────
  121. OMP_NUM_THREADS = "4"