recipe.toml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # DeepSeek-V4-Flash-0731 DSpark — AGENT-SERVING profile (2× GB10, TP=2).
  2. #
  3. # Fork of deepseek-v4-flash-eugr tuned for interactive agent traffic, applying
  4. # the validated "agent-2048" profile from the SvangenStudios DGX-Spark
  5. # agent-serving benchmarks (v0.1.1, measured 2026-08-02 on this exact stack:
  6. # DeepSeek-V4-Flash-0731, DSpark k=5, 2× DGX Spark, TP=2, RoCE):
  7. # https://github.com/SvangenStudios/dgx-spark-agent-serving-benchmarks
  8. # configs/agent-2048.env / results/RESULTS.md §4
  9. #
  10. # The benchmark's headline finding: --max-num-batched-tokens is a FAIRNESS
  11. # lever for agent workloads, not just a jitter lever. Against an ongoing
  12. # decode stream, a 262K-token prefill at 2048 delivers 2.9× the decode share
  13. # (5.0% vs 1.7%), 3.1× the decode tokens, 73% lower p95 output-chunk jitter,
  14. # and +67% KV-pool capacity — for 7.7% prefill throughput. The launcher's
  15. # whole purpose is agent serving (a model may be serving this very agent), so
  16. # 2048 is the more correct default here.
  17. #
  18. # Mental model (benchmark §3): an LLM server is three nearly-independent
  19. # engines — prefill (compute-bound, serializes), decode (bandwidth-bound,
  20. # scales to ~N=4), admission (scheduler-bound, BLOCKED during long prefill).
  21. # Chunk size governs how often decode gets a scheduling slot between prefill
  22. # chunks; smaller = more slots. It does NOT fix new-request admission (a
  23. # short request submitted during a large prefill waits until prefill
  24. # completes — 221× normal TTFT in both profiles).
  25. #
  26. # Knob changes vs deepseek-v4-flash-eugr (everything else identical — same
  27. # eugr image, same backends, same env):
  28. # --max-num-batched-tokens 8192 -> 2048 (the fairness lever)
  29. # --max-num-seqs 8 -> 6 (decode saturates ~N=4; 6 gives
  30. # headroom without inflating
  31. # worst-case latency)
  32. # --max-cudagraph-capture-size 64 -> 36 (= max_num_seqs * (k+1) = 6*6;
  33. # the k+1 multiple rule — the
  34. # benchmark notes k=5 rejects
  35. # MAX_NUM_SEQS=1 at boot)
  36. # --gpu-memory-utilization 0.85 -> 0.78 (benchmark: "0.80 boots but dies
  37. # under traffic"; GMU is a KV
  38. # lever, not a safety lever, when
  39. # weights dominate memory)
  40. # --max-model-len auto -> 1048576 (benchmark's 1M working capacity
  41. # — verified 12/12 needles at
  42. # 32K/128K/512K/900K)
  43. #
  44. # Trade-off: this profile costs ~7.7% prefill throughput vs the 8192 batch
  45. # profile. Use deepseek-v4-flash-eugr (8192) for exclusive long-context batch
  46. # jobs (512K–1M) with no concurrent agent traffic. See the batch-8192 profile
  47. # in the benchmark repo for the opposite extreme.
  48. #
  49. # 3× Sparks (TP=3): bump tensor_parallel_size + required_nodes to 3 (the eugr
  50. # image supports it per forum comment #28). k=5 unchanged (model-native).
  51. engine = "vllm"
  52. name = "DeepSeek V4 Flash DSpark (eugr b12x, agent 2048)"
  53. docker_image = "eugr/spark-vllm-b12x:sm121"
  54. model = "deepseek-ai/DeepSeek-V4-Flash-0731"
  55. required_nodes = 2
  56. tensor_parallel_size = 2
  57. pipeline_parallel_size = 1
  58. distributed_backend = "mp"
  59. shm_size = "32gb"
  60. docker_image_dir = "deepseek-v4-flash-eugr"
  61. entrypoint = ["vllm", "serve"]
  62. args = [
  63. "--kv-cache-dtype", "fp8",
  64. "--block-size", "256",
  65. "--load-format", "instanttensor",
  66. # 1M working capacity (benchmark §2: 12/12 needles at 32K–900K). A 900K
  67. # prefill takes ~15 min and starves everything — batch capacity, not an
  68. # interactive mode.
  69. "--max-model-len", "1048576",
  70. # Decode saturates around N≈4 (benchmark §3); 6 gives headroom without
  71. # inflating worst-case latency. cudagraph capture = max_num_seqs*(k+1)=36.
  72. "--max-num-seqs", "6",
  73. # FAIRNESS LEVER (benchmark §4): 2048 gives 2.9× the decode share under a
  74. # concurrent prefill vs 8192, +67% KV pool, 73% lower jitter, for 7.7%
  75. # prefill throughput. Use 8192 only for exclusive long-context batch jobs.
  76. "--max-num-batched-tokens", "2048",
  77. # = max_num_seqs * (k+1) = 6 * 6 (the k+1 multiple rule).
  78. "--max-cudagraph-capture-size", "36",
  79. # Benchmark finding: "0.80 boots but dies under traffic" — 0.78 is the
  80. # safe ceiling. GMU is a KV lever, not a safety lever, when weights
  81. # dominate memory (~77.7 GiB of ~119.6 GiB node).
  82. "--gpu-memory-utilization", "0.78",
  83. "--served-model-name", "deepseek-v4-flash",
  84. # Engine backends — b12x across attention / MoE / linear
  85. "--attention-backend", "B12X_MLA_SPARSE",
  86. "--moe-backend", "b12x",
  87. "--linear-backend", "b12x",
  88. # Prefix caching — agent frameworks build prompts append-only, so reuse is
  89. # 95.7–98.4% per turn (benchmark §9: divergence at the last token of the
  90. # previous prompt; only ~270–660 tokens re-prefilled per agent step).
  91. "--enable-prefix-caching",
  92. # Compilation
  93. "--compilation-config", """
  94. '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"]}'""",
  95. # DSpark speculative decoding — k=5 (DeepSeek-V4-Flash native
  96. # dspark_block_size). draft_sample_method per eugr recipe; draft attention
  97. # backend B12X_MLA_SPARSE. The baked mod makes the embedded draft load via
  98. # lazy safetensors while the target stays on InstantTensor.
  99. "--speculative-config", """
  100. '{"method":"dspark","num_speculative_tokens":5,"draft_sample_method":"probabilistic","attention_backend":"B12X_MLA_SPARSE"}'""",
  101. # Tokenizer / reasoning — reasoning-config pins the parser + empty
  102. # reasoning markers (deepseek_v4 tokenizer mode emits them itself).
  103. "--tokenizer-mode", "deepseek_v4",
  104. "--tool-call-parser", "deepseek_v4",
  105. "--reasoning-parser", "deepseek_v4",
  106. "--reasoning-config", """
  107. '{"reasoning_parser":"deepseek_v4","reasoning_start_str":"","reasoning_end_str":""}'""",
  108. "--enable-auto-tool-choice",
  109. "--generation-config", "vllm",
  110. "--default-chat-template-kwargs.thinking=true",
  111. "--default-chat-template-kwargs.reasoning_effort=high",
  112. "--disable-custom-all-reduce",
  113. "--trust-remote-code",
  114. ]
  115. # Persistent vLLM compile cache (speeds up restarts). Mounted at vLLM's
  116. # default cache root for root (/root/.cache/vllm); the HF cache is already
  117. # mounted at /root/.cache/huggingface by the launcher. Shares the eugr
  118. # recipe's cache dir (same image/backends — compile artifacts are reusable).
  119. [[extra_mounts]]
  120. host = "~/.cache/vllm-ds4-eugr"
  121. container = "/root/.cache/vllm"
  122. [env]
  123. # --- b12x + compile (from eugr's recipe env, verbatim) ---
  124. CUTE_DSL_ARCH = "sm_121a"
  125. VLLM_USE_AOT_COMPILE = "1"
  126. VLLM_USE_BREAKABLE_CUDAGRAPH = "0"
  127. VLLM_USE_MEGA_AOT_ARTIFACT = "-1"
  128. VLLM_MEMORY_PROFILE_INCLUDE_ATTN = "1"
  129. VLLM_USE_FLASHINFER_SAMPLER = "1"
  130. VLLM_USE_B12X_WO_PROJECTION = "1"
  131. VLLM_USE_B12X_MHC = "1"
  132. VLLM_USE_B12X_FP8_GEMM = "1"
  133. VLLM_USE_B12X_MOE = "1"
  134. VLLM_USE_B12X_SPARSE_INDEXER = "1"
  135. VLLM_USE_V2_MODEL_RUNNER = "1"
  136. B12X_MLA_SM120_UNIFIED = "1"
  137. B12X_MOE_FORCE_A8 = "1"
  138. # --- arch / memory / GPU isolation (operational on the sm121 cluster) ---
  139. TORCH_CUDA_ARCH_LIST = "12.1a"
  140. PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True"
  141. OMP_NUM_THREADS = "4"
  142. CUDA_VISIBLE_DEVICES = "0"
  143. CUDA_DEVICE_ORDER = "PCI_BUS_ID"
  144. CUDA_CACHE_MAXSIZE = "4294967296"
  145. # --- offline ---
  146. HF_HUB_OFFLINE = "1"
  147. # --- NCCL overrides (GB10 single-NIC tuning; image-agnostic — mirrors
  148. # recipes/deepseek-v4-flash. The launcher still injects IB/HCA/socket
  149. # vars from the cluster config; these are recipe-level extras.) ---
  150. NCCL_P2P_LEVEL = "SYS"
  151. NCCL_CUMEM_ENABLE = "0"
  152. NCCL_IB_TIMEOUT = "24"
  153. NCCL_IB_QPS_PER_CONNECTION = "8"
  154. NCCL_BUFFERSIZE = "16777216"
  155. NCCL_SOCKET_FAMILY = "inet"
  156. # PCIe allreduce not needed on GB10 single-NIC
  157. VLLM_ENABLE_PCIE_ALLREDUCE = "0"
  158. VLLM_PCIE_ALLREDUCE_BACKEND = "cpp"