{"id":652,"date":"2026-01-28T05:50:21","date_gmt":"2026-01-28T05:50:21","guid":{"rendered":"https:\/\/blog.liguanxin.cn\/?p=652"},"modified":"2026-01-28T05:50:21","modified_gmt":"2026-01-28T05:50:21","slug":"deepseek-v3-2-%e4%b8%8a%e4%b8%8b%e6%96%87%e5%b9%b6%e8%a1%8c%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blog.liguanxin.cn\/index.php\/2026\/01\/28\/deepseek-v3-2-%e4%b8%8a%e4%b8%8b%e6%96%87%e5%b9%b6%e8%a1%8c%e8%af%a6%e8%a7%a3\/","title":{"rendered":"[DeepSeek v3.2] \u4e0a\u4e0b\u6587\u5e76\u884c\u8be6\u89e3"},"content":{"rendered":"<h1>1. \u6838\u5fc3\u6539\u52a8\u603b\u7ed3<\/h1>\n<p>\u5728\u6b64\u4e4b\u524d\uff0cDeepSeek v3.2 \u7684 CP \u5b9e\u73b0\uff08\u5373 Native Sparse Attention \u7684 CP\uff09\u5b58\u5728\u4e00\u4e9b\u5c40\u9650\u6027\uff0c\u6bd4\u5982\u53ea\u80fd\u652f\u6301 Batch Size = 1\uff0c\u4e14\u5fc5\u987b\u5f3a\u5236\u4f7f\u7528 DeepEP \u540e\u7aef\uff0c\u4e0d\u652f\u6301 FP8 KV Cache\u3002<\/p>\n<p><strong>\u4e3b\u8981\u6539\u52a8\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u65b0\u589e round-robin-split \u6a21\u5f0f\uff1a<\/strong>\u66ff\u4ee3\u9ed8\u8ba4\u7684 in-seq-split\uff08\u6309\u5e8f\u5217\u5757\u5207\u5206\uff09\u3002\u65b0\u6a21\u5f0f\u901a\u8fc7 token_idx % cp_size \u7684\u65b9\u5f0f\u5c06 Token \u5747\u5300\u6253\u6563\u5230\u5404\u4e2a GPU \u4e0a\u3002<\/li>\n<li><strong>\u89e3\u9664\u9650\u5236\uff1a<\/strong>\u57fa\u4e8e\u65b0\u7684\u5207\u5206\u6a21\u5f0f\uff0c\u89e3\u9664\u4e86\u5bf9 Batch Size \u4e3a 1 \u7684\u9650\u5236\uff0c\u5e76\u5141\u8bb8\u4f7f\u7528 Fused MoE\uff08\u5355\u673a\u6027\u80fd\u901a\u5e38\u4f18\u4e8e DeepEP\uff09\u548c FP8 KV Cache\u3002<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2026\/01\/screenshot-20260128-114608.png\" alt=\"\" \/><\/p>\n<h1>2. \u5173\u952e\u6587\u4ef6\u4e0e\u4ee3\u7801\u6539\u52a8\u8be6\u89e3<\/h1>\n<\/li>\n<\/ul>\n<p><strong>A. \u53c2\u6570\u4e0e\u6587\u6863\u66f4\u65b0 (server_args.py, docs\/&#8230;)<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u65b0\u53c2\u6570 &#8211;nsa-prefill-cp-mode\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>\u589e\u52a0\u4e86 in-seq-split (\u65e7\u9ed8\u8ba4\u503c) \u548c round-robin-split (\u65b0\u529f\u80fd) \u4e24\u4e2a\u9009\u9879\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u4ee3\u7801\u903b\u8f91\uff1a<\/strong>\u5728 server_args.py \u4e2d\uff0c\u5982\u679c\u7528\u6237\u5f00\u542f\u4e86 NSA CP \u4e14\u6ca1\u6709\u663e\u5f0f\u6307\u5b9a\u4e3a round-robin-split\uff0c\u4ee3\u7801\u4f1a\u5f3a\u5236\u964d\u7ea7\u914d\u7f6e\uff08MoE dense tp=1, backend=deepep, dtype=bf16, batch=1\uff09\u3002\u4f46\u5982\u679c\u9009\u4e86 round-robin-split\uff0c\u8fd9\u4e9b\u5f3a\u5236\u9650\u5236\u5c31\u88ab\u79fb\u9664\u4e86\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>B. \u6838\u5fc3\u5207\u5206\u903b\u8f91 (python\/sglang\/srt\/layers\/attention\/nsa\/utils.py)<\/strong><\/p>\n<p>\u8fd9\u662f\u672c\u6b21\u6539\u52a8\u6700\u5e95\u5c42\u7684\u5730\u65b9\uff0c\u5b9a\u4e49\u4e86\u6570\u636e\u5982\u4f55\u88ab\u5207\u5206\u3002<\/p>\n<ul>\n<li>\n<p><strong>nsa_cp_round_robin_split_data:<\/strong><\/p>\n<ul>\n<li>\u65e7\u6a21\u5f0f\u662f\u5c06\u5e8f\u5217\u5207\u6210\u8fde\u7eed\u7684\u5757\uff08Chunk\uff09\u3002<\/li>\n<li>\u65b0\u6a21\u5f0f\uff08Round-Robin\uff09\u7684\u4ee3\u7801\u5982\u4e0b\uff1a\n<pre><code class=\"language-python\"># \u7b80\u5316\u7406\u89e3\uff1a\u6309 GPU \u6570\u91cf\u8fdb\u884c\u53d6\u6a21\u5206\u53d1\nindices = torch.arange(cp_rank, tokens, cp_size, device=input_.device)\nreturn input_[indices]<\/code><\/pre>\n<p>\u8fd9\u610f\u5473\u7740 Token 0 \u53bb Rank 0\uff0cToken 1 \u53bb Rank 1\uff0cToken 2 \u53bb Rank 2\u2026 \u4ee5\u6b64\u7c7b\u63a8\u3002\u8fd9\u79cd\u65b9\u5f0f\u80fd\u66f4\u597d\u5730\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Triton Kernel (nsa_cp_round_robin_split_q_seqs_kernel):<\/strong><\/p>\n<ul>\n<li>\u4e3a\u4e86\u9ad8\u6548\u5904\u7406\uff0c\u5f15\u5165\u4e86\u4e00\u4e2a Triton kernel \u6765\u8ba1\u7b97\u6253\u6563\u540e\u7684\u5e8f\u5217\u957f\u5ea6\u548c Batch \u7d22\u5f15\u3002\u7531\u4e8e Token \u88ab\u6253\u6563\uff0c\u539f\u672c\u7684\u5e8f\u5217\u957f\u5ea6\u5728\u6bcf\u4e2a GPU \u4e0a\u4f1a\u53d8\u77ed\uff0c\u9700\u8981\u91cd\u65b0\u8ba1\u7b97 cu_seqlens \u7b49\u5143\u6570\u636e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>C. \u6ce8\u610f\u529b\u5c42\u9002\u914d (python\/sglang\/srt\/layers\/attention\/nsa\/nsa_indexer.py &amp;<\/strong> nsa_backend.py)<\/p>\n<ul>\n<li><strong>\u652f\u6301\u6253\u6563\u540e\u7684 KV Cache:<\/strong>\n<ul>\n<li>\u4fee\u6539\u4e86 get_indexer_kvcache_range \u548c topk_transform \u7b49\u65b9\u6cd5\uff0c\u9002\u914d round-robin \u540e\u7684\u7d22\u5f15\u3002<\/li>\n<li>\u5728\u8ba1\u7b97 Attention \u4e4b\u524d\uff0c\u6570\u636e\u5df2\u7ecf\u88ab\u6253\u6563\uff1b\u8ba1\u7b97\u5b8c Key\/Value \u540e\uff0c\u901a\u8fc7 cp_all_gather_rerange_output \u91cd\u65b0\u6536\u96c6\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u901a\u4fe1\u4f18\u5316:<\/strong>\n<ul>\n<li>\u9488\u5bf9 round-robin \u6a21\u5f0f\uff0c\u4e13\u95e8\u4f18\u5316\u4e86 gather \u548c rerange\uff08\u91cd\u6392\uff09\u7684\u903b\u8f91\uff0c\u786e\u4fdd\u6253\u6563\u8ba1\u7b97\u540e\u7684\u7ed3\u679c\u80fd\u6b63\u786e\u62fc\u56de\u539f\u59cb\u5e8f\u5217\u987a\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>D. \u8c03\u5ea6\u7b56\u7565\u4f18\u5316 (python\/sglang\/srt\/managers\/schedule_policy.py)<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u89e3\u9501 Multi-batch:<\/strong><\/p>\n<ul>\n<li>\n<p>\u65e7\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">if self.nsa_enable_prefill_cp and len(self.can_run_list) &gt;= 1:\nreturn AddReqResult.OTHER # \u5f3a\u5236\u53ea\u8fd0\u884c 1 \u4e2a\u8bf7\u6c42<\/code><\/pre>\n<\/li>\n<li>\n<p>\u65b0\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\"># \u53ea\u6709\u5728\u65e7\u6a21\u5f0f(in-seq-split)\u4e0b\u624d\u9650\u5236 batch=1\nif self.nsa_prefill_cp_in_seq_split and len(self.can_run_list) &gt;= 1:\nreturn AddReqResult.OTHER<\/code><\/pre>\n<\/li>\n<li>\n<p>\u8fd9\u610f\u5473\u7740\u5982\u679c\u4f7f\u7528 round-robin-split\uff0c\u8c03\u5ea6\u5668\u73b0\u5728\u5141\u8bb8\u4e00\u6b21\u6027\u4e3a\u591a\u4e2a\u8bf7\u6c42\u8fdb\u884c Prefill\uff0c\u663e\u8457\u63d0\u5347\u541e\u5410\u91cf\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>E. \u901a\u4fe1\u5c42 (python\/sglang\/srt\/layers\/communicator_nsa_cp.py)<\/strong><\/p>\n<ul>\n<li>\u91cd\u6784\u4e86 NSACPCommunicateSimpleFn \u7b49\u901a\u4fe1\u51fd\u6570\u3002<\/li>\n<li>\u5728 in-seq-split \u548c round-robin-split \u4e0b\uff0cScattered\uff08\u5206\u6563\uff09\u548c Full\uff08\u5b8c\u6574\uff09\u5f20\u91cf\u4e4b\u95f4\u7684\u8f6c\u6362\u903b\u8f91\u4e0d\u540c\u3002\u4ee3\u7801\u4e2d\u589e\u52a0\u4e86\u9488\u5bf9 nsa_enable_prefill_cp \u7684\u7279\u5b9a\u5904\u7406\u8def\u5f84\uff0c\u5141\u8bb8\u5728 Scatter \u6a21\u5f0f\u4e0b\u76f4\u63a5\u8fdb\u884c LayerNorm \u548c Residual \u7d2f\u52a0\uff0c\u51cf\u5c11\u4e86\u4e0d\u5fc5\u8981\u7684\u901a\u4fe1\u5f00\u9500\u3002<\/li>\n<\/ul>\n<p><strong>F. \u6a21\u578b\u6587\u4ef6 (python\/sglang\/srt\/models\/deepseek_v2.py)<\/strong><\/p>\n<ul>\n<li>\u5728\u6a21\u578b\u7684 Forward \u8fc7\u7a0b\u4e2d\uff0c\u5c06\u786c\u7f16\u7801\u7684\u68c0\u67e5\u66ff\u6362\u4e3a nsa_use_prefill_cp(forward_batch) \u5de5\u5177\u51fd\u6570\u8c03\u7528\u3002<\/li>\n<li>\u8fd9\u4f7f\u5f97\u6a21\u578b\u80fd\u591f\u52a8\u6001\u611f\u77e5\u5f53\u524d\u7684 CP \u6a21\u5f0f\uff0c\u5e76\u5728\u8f93\u5165\u5c42\u3001MoE \u5c42\u548c\u8f93\u51fa\u5c42\u6b63\u786e\u5730\u6267\u884c cp_split_and_rebuild_data\uff08\u5207\u5206\u6570\u636e\uff09\u6216 cp_all_gather_rerange_output\uff08\u805a\u5408\u6570\u636e\uff09\u3002<\/li>\n<\/ul>\n<h1>3. \u5982\u4f55\u5f00\u542f\uff1f<\/h1>\n<p>\u5728\u65b0\u7248\u672c\u4e2d\uff0c\u542f\u52a8 DeepSeek v3.2 \u670d\u52a1\u65f6\uff0c\u63a8\u8350\u6dfb\u52a0\u4ee5\u4e0b\u53c2\u6570\u4ee5\u83b7\u5f97\u6700\u4f73\u6027\u80fd\uff08\u7279\u522b\u662f\u5728\u5355\u673a\u591a\u5361\u73af\u5883\u4e0b\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">python -m sglang.launch_server \\\n  --model deepseek-ai\/DeepSeek-V3.2-Exp \\\n  --tp 8 --dp 1 \\\n  --enable-dp-attention \\\n  --enable-nsa-prefill-context-parallel \\\n  --nsa-prefill-cp-mode round-robin-split \\\n  --max-running-requests 32<\/code><\/pre>\n<h1>4.\u4e00\u4e9b\u7ec6\u8282<\/h1>\n<h3><strong>\u7b2c\u4e00\u90e8\u5206\uff1a\u65e7\u7248 CP \u7684\u5b9e\u73b0\u4e0e Batch=1 \u9650\u5236<\/strong><\/h3>\n<p><strong>1. \u65e7\u7248 CP (Sequence Splitting \/ in-seq-split) \u662f\u600e\u4e48\u505a\u7684\uff1f<\/strong><\/p>\n<p>\u65e7\u7248\u7684 Context Parallelism\uff08\u4e0a\u4e0b\u6587\u5e76\u884c\uff09\u91c7\u7528\u7684\u662f\u6700\u76f4\u89c2\u7684<strong>\u8fde\u7eed\u5207\u5206<\/strong>\u903b\u8f91\u3002<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u957f\u5ea6\u4e3a 8000 \u7684 Prompt\uff0c\u6211\u4eec\u5728 8 \u5f20\u5361\u4e0a\u8fd0\u884c\uff08TP=8, CP=8\uff09\u3002<\/p>\n<ul>\n<li><strong>Rank 0<\/strong>: \u62ff\u5230 Token 0 ~ 999<\/li>\n<li><strong>Rank 1<\/strong>: \u62ff\u5230 Token 1000 ~ 1999<\/li>\n<li>\u2026<\/li>\n<li><strong>Rank 7<\/strong>: \u62ff\u5230 Token 7000 ~ 7999<\/li>\n<\/ul>\n<p><strong>2. \u4e3a\u4ec0\u4e48\u8981\u9650\u5236 Batch Size = 1\uff1f<\/strong><\/p>\n<p>\u8fd9\u79cd\u8fde\u7eed\u5207\u5206\u5728\u591a Batch \u573a\u666f\u4e0b\u4f1a\u9047\u5230\u5730\u72f1\u7ea7\u7684<strong>\u8d1f\u8f7d\u5747\u8861\uff08Load Balancing\uff09\u548c\u7d22\u5f15\u5bf9\u9f50<\/strong>\u95ee\u9898\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u8d1f\u8f7d\u4e0d\u5747\u8861\uff1a<\/strong><\/p>\n<ul>\n<li>\u5047\u8bbe\u6765\u4e86\u4e24\u4e2a\u8bf7\u6c42\uff1aReq A (8000 tokens), Req B (800 tokens)\u3002<\/li>\n<li>Rank 0 \u9700\u8981\u5904\u7406 Req A \u7684 0~999 \u548c Req B \u7684 0~99\u3002<\/li>\n<li>\u4f46\u5982\u679c\u6709\u4e00\u4e2a\u8bf7\u6c42\u7279\u522b\u77ed\uff0c\u4e14\u5207\u5206\u7c92\u5ea6\u5f88\u5927\uff0c\u53ef\u80fd\u51fa\u73b0 Req C \u53ea\u6709 5 \u4e2a Token\uff0c\u5bfc\u81f4\u53ea\u6709 Rank 0 \u6709\u6d3b\u5e72\uff0cRank 1-7 \u90fd\u5728\u7a7a\u8f6c\u7b49\u5f85\u3002<\/li>\n<li>\u6216\u8005\uff0cReq A \u7684\u8ba1\u7b97\u91cf\u8fdc\u5927\u4e8e Req B\uff0c\u5bfc\u81f4\u6d41\u6c34\u7ebf\u5728\u7b49\u5f85\u6700\u6162\u7684\u90a3\u4e2a chunk \u5904\u7406\u5b8c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7d22\u5f15\u7ba1\u7406\u7684\u590d\u6742\u6027\uff1a<\/strong><\/p>\n<ul>\n<li>DeepSeek V3 \u4f7f\u7528\u7684\u662f NSA (Native Sparse Attention)\uff0c\u9700\u8981\u590d\u6742\u7684 Block \u7d22\u5f15\u3002<\/li>\n<li>\u5982\u679c Batch &gt; 1\uff0c\u4e14\u6bcf\u4e2a Batch \u7684\u957f\u5ea6\u4e0d\u540c\uff0c\u6bcf\u4e2a Rank \u6301\u6709\u7684 KV Cache \u7684\u7269\u7406\u4f4d\u7f6e\u548c\u903b\u8f91\u4f4d\u7f6e\u7684\u6620\u5c04\u5173\u7cfb\u4f1a\u53d8\u5f97\u6781\u5176\u7834\u788e\u3002\u4e3a\u4e86\u80fd\u6b63\u786e\u8ba1\u7b97 Attention\uff0c\u9700\u8981\u7ef4\u62a4\u4e00\u5957\u6781\u5176\u590d\u6742\u7684 Metadata \u6765\u8bf4\u660e\u201cRank 2 \u7684\u7b2c X \u4e2a Token \u5bf9\u5e94 Batch Y \u7684\u903b\u8f91\u4f4d\u7f6e Z\u201d\u3002<\/li>\n<li>\u65e7\u7248\u59a5\u534f\uff1a\u4e3a\u4e86\u5de5\u7a0b\u5b9e\u73b0\u7684\u7b80\u5355\uff0c\u65e7\u4ee3\u7801\u7d22\u6027\u5f3a\u5236\u8981\u6c42 len(can_run_list) == 1\uff0c\u4fdd\u8bc1\u6240\u6709 GPU \u53ea\u9700\u8981\u5168\u5fc3\u5168\u610f\u5904\u7406\u8fd9\u4e00\u4e2a\u5927\u5e8f\u5217\uff0c\u7d22\u5f15\u662f\u8fde\u7eed\u4e14\u53ef\u9884\u6d4b\u7684\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><strong>\u7b2c\u4e8c\u90e8\u5206\uff1aFused MoE vs DeepEP<\/strong><\/h3>\n<p><strong>1. DeepEP (Deep Expert Parallelism) \u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n<p>DeepEP \u662f DeepSeek \u5b98\u65b9\u4e3a\u4e86\u89e3\u51b3\u8de8\u8282\u70b9\u7684 All-to-All \u901a\u4fe1\u6548\u7387\u800c\u5f00\u53d1\u7684\u5e93\u3002<\/p>\n<ul>\n<li><strong>\u573a\u666f\uff1a<\/strong>\u4e3b\u8981\u4e3a\u4e86\u89e3\u51b3\u5927\u89c4\u6a21 MoE\uff08\u4e13\u5bb6\u5e76\u884c\uff09\u4e2d\uff0cToken \u9700\u8981\u88ab\u53d1\u9001\u5230\u4e0d\u540c GPU \u4e0a\u7684\u4e13\u5bb6\uff08Expert\uff09\u53bb\u8ba1\u7b97\uff0c\u8ba1\u7b97\u5b8c\u518d\u53d1\u56de\u6765\u7684\u573a\u666f\u3002<\/li>\n<li><strong>\u673a\u5236\uff1a<\/strong>\u5b83\u662f\u4e00\u5957\u9ad8\u5ea6\u4f18\u5316\u7684\u901a\u4fe1+\u8ba1\u7b97\u539f\u8bed\u3002\u5728 DeepSeek V3 \u7684\u539f\u59cb\u8bbe\u7f6e\u4e2d\uff0c\u4e3a\u4e86\u6781\u81f4\u6027\u80fd\uff0c\u5f80\u5f80\u9700\u8981\u4e13\u95e8\u7684\u901a\u4fe1\u5185\u6838\u6765\u5904\u7406 Token \u7684\u5206\u53d1\u3002<\/li>\n<li><strong>\u65e7\u7248 CP \u4f9d\u8d56 DeepEP\uff1a<\/strong>\u56e0\u4e3a\u65e7\u7248\u662f\u8fde\u7eed\u5207\u5206\uff0cToken \u5728 Rank \u95f4\u7684\u5206\u5e03\u4e0d\u4e00\u5b9a\u7b26\u5408\u4e13\u5bb6\u7684\u5206\u5e03\uff0c\u6216\u8005\u4e3a\u4e86\u914d\u5408 DeepSeek \u539f\u59cb\u4ee3\u7801\u7684\u903b\u8f91\uff0c\u5f3a\u7ed1\u5b9a\u4e86 DeepEP \u540e\u7aef\u3002<\/li>\n<\/ul>\n<p><strong>2. Fused MoE \u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b83\u5728\u8fd9\u91cc\u66f4\u597d\uff1f<\/strong><\/p>\n<p>Fused MoE\uff08\u5728 vLLM\/SGLang \u7b49\u63a8\u7406\u6846\u67b6\u4e2d\u5e38\u89c1\uff09\u662f\u9488\u5bf9<strong>\u5355\u673a TP\uff08Tensor Parallel\uff09<\/strong>\u73af\u5883\u9ad8\u5ea6\u4f18\u5316\u7684 Kernel\u3002<\/p>\n<ul>\n<li><strong>\u673a\u5236\uff1a<\/strong>\u5b83\u4e0d\u8fdb\u884c\u590d\u6742\u7684\u8de8\u8282\u70b9\u70b9\u5bf9\u70b9 Token \u4f20\u8f93\uff0c\u800c\u662f\u5047\u8bbe\u6743\u91cd\u5df2\u7ecf\u6309 TP \u5207\u5206\u597d\u4e86\u3002<\/li>\n<li><strong>Fused\uff08\u878d\u5408\uff09\uff1a<\/strong>\u5b83\u5c06\u201cGate\uff08\u9009\u4e13\u5bb6\uff09 -&gt; Sort\uff08\u6309\u4e13\u5bb6\u91cd\u6392 Token\uff09 -&gt; GEMM\uff08\u4e13\u5bb6\u8ba1\u7b97\uff09 -&gt; Unsort\uff08\u8fd8\u539f\u987a\u5e8f\uff09\u201d\u8fd9\u4e00\u7cfb\u5217\u64cd\u4f5c\uff0c\u5c3d\u53ef\u80fd\u878d\u5408\u5728 Kernel \u5185\u90e8\u6216\u6781\u5c11\u7684 Kernel Launch \u4e2d\u5b8c\u6210\u3002<\/li>\n<li><strong>\u4f18\u52bf\uff1a<\/strong>\n<ul>\n<li><strong>Round-Robin \u7684\u5929\u4f5c\u4e4b\u5408\uff1a<\/strong>\u65b0\u7684 CP \u6a21\u5f0f\uff08Round-Robin\uff09\u5c06 Token 0,1,2,3&#8230; \u5747\u5300\u6253\u6563\u5230 Rank 0,1,2,3&#8230;\u3002\u8fd9\u610f\u5473\u7740\u6bcf\u4e2a GPU \u4e0a\u90fd\u6709\u4e00\u5806\u968f\u673a\u5206\u5e03\u7684 Token\u3002\u8fd9\u79cd\u5206\u5e03\u5929\u7136\u9002\u5408\u6570\u636e\u5e76\u884c\u7c7b\u7684\u5904\u7406\uff0c\u4e0d\u518d\u9700\u8981 DeepEP \u90a3\u79cd\u590d\u6742\u7684\u8c03\u5ea6\u3002<\/li>\n<li><strong>\u5f00\u9500\u66f4\u4f4e\uff1a<\/strong>\u5728\u5355\u673a\u573a\u666f\u4e0b\uff0cSGLang \u7684 Fused MoE \u5b9e\u73b0\u6bd4\u8c03\u7528 DeepEP \u7684\u901a\u4fe1\u539f\u8bed\u5f00\u9500\u66f4\u5c0f\uff0c\u4e14\u5bf9 FP8 \u7684\u652f\u6301\u66f4\u6210\u719f\uff08\u65e7\u7248 DeepEP \u5728 SGLang \u63a5\u5165\u4e2d\u88ab\u9501\u5b9a\u5728 BF16\uff09\u3002<\/li>\n<li><strong>\u901a\u7528\u6027\uff1a<\/strong>\u89e3\u9664\u4e86\u5bf9\u7279\u5b9a\u901a\u4fe1\u5e93\u7684\u5f3a\u4f9d\u8d56\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><strong>\u7b2c\u4e09\u90e8\u5206\uff1aKV Cache \u7684\u6d41\u52a8\uff1a\u6253\u6563\u3001\u62fc\u56de\u4e0e\u518d\u6253\u6563<\/strong><\/h3>\n<p>\u8fd9\u662f\u8be5 PR \u6700\u6838\u5fc3\u7684\u6539\u52a8\uff1a<strong>Round-Robin \u6a21\u5f0f\u4e0b\u7684\u6570\u636e\u6d41\u3002<\/strong><br \/>\n\u6211\u4eec\u8ffd\u8e2a\u4e00\u4e2a Batch \u5728 Prefill \u9636\u6bb5\u7684\u751f\u547d\u5468\u671f\u3002\u5047\u8bbe CP=4\uff084\u5f20\u5361\uff09\uff0c\u4e00\u4e2a\u5e8f\u5217 [T0, T1, T2, T3, T4, T5, T6, T7]\u3002<\/p>\n<p><strong>1. \u8f93\u5165\u9636\u6bb5\uff1aRound-Robin \u6253\u6563 (Scatter)<\/strong><\/p>\n<p>\u5728\u8fdb\u5165\u6a21\u578b\u7684\u7b2c\u4e00\u5c42\u4e4b\u524d\uff0c\u8f93\u5165 ID \u88ab\u91cd\u65b0\u5206\u53d1\uff08\u4ee3\u7801\u4e2d\u7684 nsa_cp_round_robin_split_data\uff09\u3002<\/p>\n<ul>\n<li><strong>Rank 0:<\/strong> \u6301\u6709 [T0, T4]<\/li>\n<li><strong>Rank 1:<\/strong> \u6301\u6709 [T1, T5]<\/li>\n<li><strong>Rank 2:<\/strong> \u6301\u6709 [T2, T6]<\/li>\n<li><strong>Rank 3:<\/strong> \u6301\u6709 [T3, T7]<\/li>\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u7edd\u5bf9\u7684\u8d1f\u8f7d\u5747\u8861\u3002\u65e0\u8bba Batch \u91cc\u6709\u591a\u5c11\u4e2a\u8bf7\u6c42\uff0c\u957f\u77ed\u5982\u4f55\uff0c\u6bcf\u4e2a GPU \u62ff\u5230\u7684 Token \u6570\u91cf\u51e0\u4e4e\u5b8c\u5168\u4e00\u81f4\uff08\u6700\u591a\u5dee 1 \u4e2a\uff09\u3002<\/li>\n<\/ul>\n<p><strong>2. \u524d\u5411\u8ba1\u7b97\uff1a\u975e Attention \u5c42 (MLP \/ Fused MoE)<\/strong><\/p>\n<p>\u5728 MLP \u6216 MoE \u5c42\uff0c\u8ba1\u7b97\u662f Point-wise\uff08\u9010 Token \u72ec\u7acb\uff09\u7684\u3002<\/p>\n<ul>\n<li>Rank 0 \u53ea\u9700\u8981\u8ba1\u7b97 T0 \u548c T4 \u7684\u6295\u5f71\u3002<\/li>\n<li>\u5982\u679c\u662f MoE\uff0cRank 0 \u5c31\u5728\u672c\u5730\u7b97\u8fd9\u4e24\u4e2a Token \u7684\u4e13\u5bb6\u9009\u62e9\uff08Gate\uff09\uff0c\u7136\u540e\u6839\u636e TP \u7b56\u7565\uff08\u867d\u7136\u8fd9\u91cc\u53eb CP\uff0c\u4f46\u6743\u91cd\u901a\u5e38\u590d\u7528 TP \u7684\u5207\u5206\uff09\u8ba1\u7b97\u3002<\/li>\n<li><strong>\u5173\u952e\u70b9\uff1a<\/strong>\u4e0d\u9700\u8981\u901a\u4fe1\uff0c\u6216\u8005\u53ea\u9700\u8981\u5e38\u89c4\u7684 TP All-Reduce\u3002\u56e0\u4e3a Token \u4e4b\u95f4\u4e0d\u9700\u8981\u4e92\u76f8\u201c\u770b\u89c1\u201d\u3002<\/li>\n<\/ul>\n<p><strong>3. \u524d\u5411\u8ba1\u7b97\uff1aAttention \u5c42 (NSA) \u2014\u2014 \u6700\u590d\u6742\u7684\u90e8\u5206<\/strong><\/p>\n<p>Attention \u5fc5\u987b\u8981\u201c\u770b\u89c1\u201d\u4e4b\u524d\u7684 Token\u3002\u6bd4\u5982 T5 (\u5728 Rank 1) \u9700\u8981 Attend to T0~T4 (\u5206\u5e03\u5728 Rank 0, 1, 2, 3)\u3002<\/p>\n<p><strong>\u6b65\u9aa4 A: \u8ba1\u7b97 Q, K, V<\/strong><\/p>\n<ul>\n<li>Rank 0 \u672c\u5730\u8ba1\u7b97 T0, T4 \u7684 Q, K, V \u5411\u91cf\u3002<\/li>\n<li>\u5176\u4ed6 Rank \u540c\u7406\u3002\u6b64\u65f6 KV Cache \u8fd8\u662f\u6253\u6563\u5b58\u50a8\u7684\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 B: \u805a\u5408 KV (Gather &amp; Rerange)<\/strong><\/p>\n<ul>\n<li>\n<p>\u5728\u8ba1\u7b97 Attention score \u4e4b\u524d\uff0c\u8c03\u7528 cp_all_gather_rerange_output\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u901a\u4fe1\uff1a<\/strong>\u6240\u6709\u5361\u8fdb\u884c All-Gather\u3002<\/p>\n<ul>\n<li>\u77ac\u95f4\uff0cRank 1 \u62ff\u5230\u4e86 Rank 0, 2, 3 \u7684\u6240\u6709 K \u548c V\u3002<\/li>\n<li>\u73b0\u5728 Rank 1 \u62e5\u6709\u4e86\u5b8c\u6574\u7684 global KV\uff1a{K0..K7}, {V0..V7}\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u91cd\u6392 (Rerange)\uff1a<\/strong>\u7531\u4e8e All-Gather \u62ff\u5230\u7684\u6570\u636e\u662f\u6309 Rank \u62fc\u63a5\u7684\uff08\u5373 T0,T4, T1,T5&#8230;\uff09\uff0c\u5185\u5b58\u662f\u4e71\u5e8f\u7684\u3002\u9700\u8981\u6839\u636e Round-Robin \u89c4\u5219\uff0c\u5728\u5185\u5b58\u4e2d\u5c06\u5176\u8fd8\u539f\u4e3a\u903b\u8f91\u987a\u5e8f T0, T1, T2&#8230;\u3002<\/p>\n<ul>\n<li>\u6ce8\uff1aDeepSeek NSA \u9700\u8981\u7528\u5230\u5757\u7d22\u5f15\uff0c\u5fc5\u987b\u4fdd\u8bc1 KV \u5728\u903b\u8f91\u4e0a\u8fde\u7eed\u624d\u80fd\u8fdb\u884c top-k \u7b5b\u9009\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 C: \u8ba1\u7b97 Attention<\/strong><\/p>\n<ul>\n<li>Rank 1 \u4f7f\u7528\u672c\u5730\u7684 Q (Q1, Q5) \u53bb\u67e5\u8be2\u5b8c\u6574\u7684 Global KV (K0~K7, V0~V7)\u3002<\/li>\n<li>\u8ba1\u7b97\u51fa Attention Output (O1, O5)\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 D: \u4e22\u5f03 Global KV (Implicit)<\/strong><\/p>\n<ul>\n<li>\u8ba1\u7b97\u5b8c\u540e\uff0cGlobal KV \u4e0d\u9700\u8981\u4fdd\u5b58\uff08\u592a\u5927\u4e86\uff09\u3002<\/li>\n<li>Checkpointing \u6216 KV Cache Manager \u53ea\u4f1a\u4fdd\u7559 Rank 1 \u81ea\u5df1\u8d1f\u8d23\u7684\u90a3\u90e8\u5206 KV (K1, K5) \u843d\u76d8\u5230\u663e\u5b58 Cache \u6c60\u4e2d\uff08\u7528\u4e8e\u540e\u7eed Decode\uff09\u3002<\/li>\n<li><strong>\u7ed3\u679c\uff1a<\/strong>Rank 1 \u73b0\u5728\u624b\u91cc\u6709\u4e86 Context \u540e\u7684\u7ed3\u679c [O1, O5]\u3002<\/li>\n<\/ul>\n<p><strong>4. \u8f93\u51fa\u9636\u6bb5<\/strong><br \/>\n\u8ba1\u7b97\u4e00\u76f4\u6d41\u8f6c\u5230\u6700\u540e\u4e00\u5c42\u3002<\/p>\n<ul>\n<li>Rank 0 \u6709 Logits[0], Logits[4]<\/li>\n<li>Rank 1 \u6709 Logits[1], Logits[5]<\/li>\n<li>\u2026<br \/>\n\u6700\u7ec8\u5728\u91c7\u6837\uff08Sampling\uff09\u4e4b\u524d\uff0c\u6216\u8005\u5728\u6700\u540e\u4e00\u5c42\uff0c\u901a\u5e38\u4f1a\u518d\u505a\u4e00\u6b21 Gather \u6216\u8005\u76f4\u63a5\u5728\u5206\u5e03\u5f0f\u7684 Logits \u4e0a\u505a Argmax\uff08\u53d6\u51b3\u4e8e\u91c7\u6837\u7b56\u7565\uff09\uff0c\u5c06\u7ed3\u679c\u62fc\u56de [Token 0 ~ Token 7] \u7684\u987a\u5e8f\u8fd4\u56de\u7ed9\u7528\u6237\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. \u6838\u5fc3\u6539\u52a8\u603b\u7ed3 \u5728\u6b64\u4e4b\u524d\uff0cDeepSeek v3.2 \u7684 CP \u5b9e\u73b0\uff08\u5373 Native Sparse At [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35],"tags":[41,37,42],"_links":{"self":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/652"}],"collection":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":0,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}