# SM86 DeepSeek-V4 256K-500K Roadmap Goal: keep 50+ tok/s while reopening 256K-500K context on SM86. ## Current Champion - Public reproduction runbook: `docs/SM86_DSV4_RUNBOOK.md`. - 262K graphs-only: ~59.6 tok/s, coherent. - 2 x 176K: 81.3 tok/s aggregate, coherent. - 3 x 114K: 104.5 tok/s aggregate, coherent. - 4 x 80K: 120.1 tok/s aggregate, coherent. - Launch shape: compressed hybrid KV intact, cudagraph reservation off, no spec. - Canonical scripts: - `scripts/serve_sm86_64k_cudagraph.sh` - `scripts/serve_sm86_262k_cudagraph.sh` - `scripts/serve_sm86_176k_2seq_cudagraph.sh` - `scripts/serve_sm86_114k_3seq_cudagraph.sh` - `scripts/serve_sm86_80k_4seq_cudagraph.sh` Control run: ```bash scripts/serve_sm86_262k_cudagraph.sh ``` Expected: ~59.6 tok/s. If this drops, fix launch/config before touching kernels. ## Keep - `--kv-cache-dtype fp8_ds_mla` - Hybrid KV cache manager enabled. - `VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS=0` - Cudagraphs enabled. - `FUSE_ALLREDUCE_RMS=1` - Graphs-only first; spec decode is parked. ## Avoid - Do not use DCP for the quick path. Current vLLM DCP forces uniform KV groups and destroys DSV4 hybrid compression. - Do not use `--disable-hybrid-kv-cache-manager`. - Do not revive MTP spec unless descriptor logs prove the draft path is failing to replay captured graphs. - Do not chase custom allreduce while peer access is false on TP8 PHB. - Do not chase MoE before communication; rank0 trace shows TP allreduce dominates. ## Trace Result Trace source: rank0 torch profiler graph trace, 227 graph launches (raw trace available on request). Run shape: 64K envelope, graphs-only champion, `FUSE_ALLREDUCE_RMS=1`, size-1 `FULL_DECODE_ONLY` graphs, ~300 generated tokens after warmup. Rank0 graph-interior bucket totals over 227 graph launches: - `ncclDevKernel_AllReduce_Sum_bf16_RING_LL`: 3.970s total, 19,836 calls, ~17.49ms kernel duration per graph. - FlashInfer sparse MLA decode: 0.425s total, ~1.87ms per graph. - Marlin linear kernels: 0.487s total, ~2.15ms per graph. - Marlin MoE WNA16 kernels: 0.231s total, ~1.02ms per graph. - NCCL all-gather for logits: 0.165s total, ~0.73ms per graph. Readout: the 18ms/step wall is TP8 allreduce transport. MoE and sparse attention are secondary. The next lever is reducing or accelerating TP collectives. ## Context Ladder Reproduced context frontier: ```bash scripts/serve_sm86_262k_cudagraph.sh ``` Expected capture shape: `num_spec_tokens=0`, `uniform_decode_query_len=1`, `capture_sizes=[1]`, and `cg_mode=FULL` for steady decode. Any `SM86 cudagraph skip` or `SM86 cudagraph miss` line is the next root cause. If capture regresses, rerun once with dispatch diagnostics: ```bash CUDAGRAPH_DISPATCH_DEBUG=1 scripts/serve_sm86_262k_cudagraph.sh ``` Experimental upper context scripts remain in-tree but are not published reproduction envelopes: ```bash scripts/serve_sm86_393k_cudagraph.sh scripts/serve_sm86_524k_cudagraph.sh ``` 393K missed the graph/pool window by about 30 MiB on the tested 3090 stack: 1792 blocks passed the engine minimum but failed graph warmup; 1760 blocks failed the engine minimum. Bank 262K unless a future workspace reduction changes that margin. ## Sequence Ladder Run in this order: ```bash scripts/serve_sm86_176k_2seq_cudagraph.sh scripts/serve_sm86_114k_3seq_cudagraph.sh scripts/serve_sm86_80k_4seq_cudagraph.sh ``` Measured curve: - 1 x 262K: 59.6 tok/s. - 2 x 176K: 81.3 tok/s aggregate. - 3 x 114K: 104.5 tok/s aggregate. - 4 x 80K: 120.1 tok/s aggregate. Do not hand-merge these into local scripts. The common launcher prints the complete argv and critical env block at startup; debug from that manifest. ## Profile Buckets Separate these in the graph-only profiler: - TP allreduce per layer - MoE routing and expert kernels - CSA lightning indexer - CSA sparse MQA - HCA dense compressed MQA - SWA branch - mHC kernels Expected first suspects at long context: CSA indexer and TP allreduce. ## Comm Matrix Run only after 262K graph boot is coherent: ```bash SPECULATIVE_CONFIG=none NCCL_ALGO=Tree NCCL_PROTO=Simple scripts/serve_sm86_64k_cudagraph.sh SPECULATIVE_CONFIG=none NCCL_ALGO=Ring NCCL_PROTO=Simple scripts/serve_sm86_64k_cudagraph.sh SPECULATIVE_CONFIG=none NCCL_ALGO=Tree NCCL_PROTO=LL128 scripts/serve_sm86_64k_cudagraph.sh SPECULATIVE_CONFIG=none VLLM_ALLREDUCE_USE_FLASHINFER=1 VLLM_FLASHINFER_ALLREDUCE_BACKEND=trtllm scripts/serve_sm86_64k_cudagraph.sh SPECULATIVE_CONFIG=none FUSE_ALLREDUCE_RMS=1 scripts/serve_sm86_64k_cudagraph.sh ``` If the matrix does not move the needle, the next material lever is the peer-access path: module/driver/NCCL change to make CUDA P2P true. Existing vLLM custom allreduce disables itself on TP8 PHB/no-P2P. ## Kernel Work After Profile Only patch kernels after graph-interior data identifies the bucket: - fused fp8 sparse-decode attention to avoid bf16 workspace round-trip - CSA indexer decode tuning - MoE routing/expert launch fusion - allreduce/RMS fusion if adjacent AR+norm is visible ## Spec Decode Status Round 2 result: MTP + graphs fell to ~20 tok/s from 56 tok/s graphs-only. Probe if needed: ```bash SPEC_CUDAGRAPH_DEBUG=4 scripts/serve_sm86_64k_cudagraph.sh ``` Readout: - `cg_mode=FULL` for draft prefill/decode: spec is captured and loses on draft compute. - `cg_mode=NONE`: spec dispatch/key selection is broken and may be worth fixing. ## Source Links - DeepSeek-V4 technical report: https://arxiv.org/html/2606.19348v1 - CSA/HCA walkthrough: https://prathamp.com/blog/deepseek-v4-csa-and-hca/ - Ampere community fork: https://github.com/Lasimeri/vllm-dsv4-ampere - Rank0 graph trace: torch profiler, summary in Trace Result above ## Notes From Sources - V4-Flash uses CSA/HCA interleaving after the first sliding-window layers. - CSA compresses KV by 4x, then sparse-selects compressed entries. - HCA compresses KV by 128x, then attends densely over the compressed stream. - The KV memory win depends on heterogeneous KV groups: SWA, CSA C4, HCA C128, and indexer/state caches. - Lasimeri's DCP notes independently confirm that current vLLM DCP and DSV4 hybrid compression are not compatible as a quick win.