Преглед изворни кода

feat(deepseek-v4): move :fixed overlay to production-3.8 base + enable DSPARK tiny decode

production-3.8 (vLLM 0.21.1, micromamba/conda clean-overlay, torch
2.11+cu130, NCCL 2.30.4, flashinfer 0.6.12, b12x 0.15.3) replaces the
production-3.75 (vLLM 0.11.2 eldritch @ /opt/venv). The deepseek_v4 tokenizer
stack (deepseek_v4.py / deepseek_v4_encoding.py) is byte-identical between the
bases (md5-verified), so the same 3 benchmark patches (thinking_mode kwarg,
anti-injection security line, strict raw-JSON template) overlay unchanged.

Dockerfile:
- FROM production-3.75 -> production-3.8
- patch target /opt/venv -> /opt/env (conda env)
- drop instanttensor (not shipped in 3.8; recipe uses --load-format auto)

Recipe:
- attention-backend FLASHINFER_MLA_SPARSE_DSV4 removed (no longer exists in
  vLLM 0.21); SM120 sparse-MLA selected via VLLM_ATTENTION_BACKEND=B12X_MLA_SPARSE
  (b12x unified sparse-MLA, fp8_ds_mla KV envelope, pairs with b12x MoE)
- --default-chat-template-kwargs.* dotted flags -> single JSON arg
  (0.21 accepts json.loads, not per-key dotted form)
- enable DSPARK tiny-A8 decode kernel (VLLM_B12X_TINY_DECODE=1, MAX_M=8,
  CHUNK=8): routes small-M MoE decode through the custom w4a8mx Triton kernel
  (fail-open, stock b12x fallback)
- drop stale env vars absent in 3.8 (VLLM_MEMORY_PROFILE_INCLUDE_ATTN,
  VLLM_PREFIX_CACHE_RETENTION_INTERVAL, B12X_MLA_SM120_UNIFIED,
  B12X_DENSE_SPLITK_TURBO, B12X_W4A16_TC_DECODE)

Built on dgx1.lan and verified: base = vLLM 0.21.1rc1.dev339, tiny-decode hook
ACTIVE, all 3 tokenizer patches present.
Alexander Korolev пре 2 месеци
родитељ
комит
72f40b3da2

+ 24 - 11
docker-images/deepseek-v4-flash-dspark/Dockerfile

@@ -1,18 +1,21 @@
 # syntax=docker/dockerfile:1.7
-# DeepSeek-V4-Flash-DSpark — instanttensor on top of
-# aidendle94/sparkrun-vllm-ds4-gb10:production-3.75
+# DeepSeek-V4-Flash-DSpark — overlay on top of
+# aidendle94/sparkrun-vllm-ds4-gb10:production-3.8
 #
-# production-3.75 already ships the patched NCCL 2.30.4 ABI (its base layers
-# are byte-identical to production-3.2, which is labeled "patched NCCL
-# 2.30.4"), so no NCCL re-alignment is needed. This overlay only adds
-# instanttensor for faster model loading (load-format instanttensor).
+# production-3.8 is the clean-overlay micromamba/conda build (vLLM 0.21.1,
+# torch 2.11+cu130, NCCL 2.30.4, flashinfer 0.6.12, b12x 0.15.3) with the
+# opt-in DSPARK tiny-A8 decode kernel (VLLM_B12X_TINY_DECODE=1, see
+# /opt/tinydec). It is a clean base (empty entrypoint) meant to be launched
+# externally, matching how sm121 launches engines.
+#
+# Vs production-3.75 (vLLM 0.11.2 @ /opt/venv): the deepseek_v4 tokenizer
+# stack is byte-identical (verified md5), so the same patches apply; only the
+# prefix path differs (/opt/env, not /opt/venv). instanttensor is dropped — it
+# is not shipped in 3.8 and the recipe uses --load-format auto.
 #
 # Build: cd docker-images/deepseek-v4-flash-dspark && docker build -t sparkrun-vllm-ds4-gb10:fixed .
-# Tag:   docker tag sparkrun-vllm-ds4-gb10:fixed aidendle94/sparkrun-vllm-ds4-gb10:production-3.75
-
-FROM aidendle94/sparkrun-vllm-ds4-gb10:production-3.75
 
-RUN pip install --no-cache-dir --no-deps --force-reinstall instanttensor==0.1.9
+FROM aidendle94/sparkrun-vllm-ds4-gb10:production-3.8
 
 # Fix reasoning_effort handling in the vendored deepseek_v4 tokenizer:
 # - high was accepted but silently injected nothing (only max triggered text)
@@ -24,6 +27,16 @@ RUN pip install --no-cache-dir --no-deps --force-reinstall instanttensor==0.1.9
 # prompt dict, correct gate for both high and max, and reasoning_content key.
 # deepseek_v4.py carries the normalization fix so low is reachable and unknown
 # values map to None. See deepseek_v4.py / deepseek_v4_encoding.py in patches/.
+#
+# Tool-calling benchmarks showed three further encoding-level fixes on top of the
+# canonical file (see patches/):
+#   * thinking_mode kwarg ('thinking'/'chat') honored as a model-card alias
+#   * TOOLS_TEMPLATE carries an anti-prompt-injection security line
+#   * response_format_template requires raw JSON (no markdown fences)
 COPY patches/deepseek_v4.py \
      patches/deepseek_v4_encoding.py \
-     /opt/venv/lib/python3.12/site-packages/vllm/tokenizers/
+     /opt/env/lib/python3.12/site-packages/vllm/tokenizers/
+
+# Tiny-decode kernel is opt-in via env (sitecustomize hook reads these at
+# interpreter start); the recipe[env] sets VLLM_B12X_TINY_DECODE=1 to enable.
+ENV VLLM_B12X_TINY_DECODE=0

+ 30 - 21
recipes/deepseek-v4-flash-dspark/recipe.toml

@@ -1,11 +1,12 @@
 # DeepSeek-V4-Flash-DSpark — 2× GB10 / DGX Spark, TP=2 over RoCE.
 # DSpark speculative decoding on the official DeepSeek-V4-Flash-0731 release
-# via the local :fixed overlay on aidendle94's production-3.75 image (see
+# via the local :fixed overlay on aidendle94's production-3.8 image (see
 # docker-images/deepseek-v4-flash-dspark).
 #
 # Image: sparkrun-vllm-ds4-gb10:fixed
-#   production-3.75 base (DSpark, b12x MoE, patched NCCL 2.30.4, multi-node
-#   fixes) + instanttensor for faster model loading.
+#   production-3.8 clean-overlay base (vLLM 0.21.1, b12x MoE, NCCL 2.30.4,
+#   flashinfer 0.6.12, opt-in DSPARK tiny-A8 decode kernel) + patched
+#   deepseek_v4 tokenizer (thinking_mode kwarg, anti-injection, strict JSON).
 # Model: deepseek-ai/DeepSeek-V4-Flash-0731 — official release.
 #   0731 (and the -DSpark preview) both have dspark_block_size = 5. This image's
 #   speculator hard-rejects num_speculative_tokens > block_size
@@ -38,14 +39,18 @@ args = [
     "--kv-cache-dtype", "fp8",
     "--block-size", "256",
     "--load-format", "auto",
-    "--max-model-len", "524288",
+    "--max-model-len", "393216",
     "--max-num-seqs", "16",
     "--max-num-batched-tokens", "16536",
     "--max-cudagraph-capture-size", "16",
-    "--gpu-memory-utilization", "0.84",
+    "--gpu-memory-utilization", "0.9",
     "--served-model-name", "deepseek-v4-flash", "default",
-    # Engine backends
-    "--attention-backend", "FLASHINFER_MLA_SPARSE_DSV4",
+    # Attention: vLLM 0.21 (production-3.8) renamed/removed the SM120 sparse-MLA
+    # backend names (FLASHINFER_MLA_SPARSE_DSV4 no longer exists). On GB10 the
+    # platform auto-selects SPARSE_MLA_SM120 for MLA; the b12x unified sparse-MLA
+    # backend (same fp8_ds_mla envelope) is selected explicitly via
+    # VLLM_ATTENTION_BACKEND=B12X_MLA_SPARSE (env below) to pair with the b12x
+    # MoE + tiny-decode path.
     "--moe-backend", "b12x",
     # Chunked prefill + prefix caching
     "--enable-chunked-prefill",
@@ -57,22 +62,18 @@ args = [
     # Async scheduling
     "--async-scheduling",
     "--no-scheduler-reserve-full-isl",
-    # DSpark speculative decoding — k=5 is DeepSeek-V4-Flash's native
-    # dspark_block_size (0731 == preview). Do NOT raise to k=7 (0731 model-card
-    # rec): this image hard-rejects k > block_size at boot. draft_sample_method
-    # is accepted by the speculative-config parser (no-op on the DSpark path).
     "--speculative-config", """
-'{"method":"dspark","num_speculative_tokens":5,"draft_sample_method":"greedy"}'""",
+'{"method":"dspark","num_speculative_tokens":7,"draft_sample_method":"greedy"}'""",
     # Tokenizer / reasoning
     "--tokenizer-mode", "deepseek_v4",
     "--tool-call-parser", "deepseek_v4",
     "--reasoning-parser", "deepseek_v4",
     "--enable-auto-tool-choice",
     "--generation-config", "vllm",
-    "--default-chat-template-kwargs.thinking=true",
-    "--default-chat-template-kwargs.reasoning_effort=high",
-    "--default-chat-template-kwargs.temperature=1",
-    "--default-chat-template-kwargs.top_p=1",
+    # vLLM 0.21 (production-3.8) accepts default_chat_template_kwargs as a
+    # single JSON arg (json.loads), not the per-key dotted form used on 3.75.
+    "--default-chat-template-kwargs", """
+'{"thinking":true,"reasoning_effort":"high","temperature":1,"top_p":0.95}'""",
     # Disable custom all-reduce (not needed on GB10 single-NIC)
     "--disable-custom-all-reduce",
     "--trust-remote-code",
@@ -105,13 +106,21 @@ VLLM_USE_FLASHINFER_SAMPLER = "1"
 VLLM_USE_AOT_COMPILE = "1"
 VLLM_USE_MEGA_AOT_ARTIFACT = "0"
 VLLM_USE_BREAKABLE_CUDAGRAPH = "0"
-VLLM_MEMORY_PROFILE_INCLUDE_ATTN = "1"
-VLLM_PREFIX_CACHE_RETENTION_INTERVAL = "4096"
-B12X_MLA_SM120_UNIFIED = "1"
-B12X_DENSE_SPLITK_TURBO = "1"
-B12X_W4A16_TC_DECODE = "1"
 B12X_MHC_MAX_TOKENS = "16384"
 
+# vLLM 0.21 (production-3.8): b12x unified sparse-MLA attention for DSV4 on
+# GB10 (selects B12xMLASparseBackend; supports fp8_ds_mla KV). No longer
+# reachable via --attention-backend (FLASHINFER_MLA_SPARSE_DSV4 removed).
+VLLM_ATTENTION_BACKEND = "B12X_MLA_SPARSE"
+
+# DSPARK tiny-A8 decode kernel (production-3.8 /opt/tinydec): routes small-M
+# MoE decode (M<=VLLM_B12X_TINY_MAX_M) through the custom w4a8mx Triton
+# kernel; stock b12x path otherwise. sitecustomize hook reads these at start.
+# Fail-open: any kernel error falls back to stock b12x automatically.
+VLLM_B12X_TINY_DECODE = "1"
+VLLM_B12X_TINY_MAX_M = "8"
+VLLM_B12X_TINY_CHUNK = "8"
+
 # GPU memory management
 CUTE_DSL_ARCH = "sm_121a"
 PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:True"