deepseek_v32部署

deepseek_v32部署
gogongxtDeepSeek-V3.2 部署最佳实践指南
1. 硬件环境
| 项目 | 规格 |
|---|---|
| GPU | NVIDIA H200 |
| 部署拓扑 | 2P1D 离线分离部署 |
| Prefill 实例 | 2 × 单机八卡(共 16 卡) |
| Decode 实例 | 2 机 16 卡(跨节点 TP=16) |
| 总 GPU 数 | 4 台机器,32 张 H200 |
2. 环境变量配置
所有实例(Prefill 和 Decode)均需设置以下环境变量:
1
2
3
4
5
6
7
8
9
export NVSHMEM_BOOTSTRAP_UID_SOCK_IFNAME=eth0
export NVSHMEM_IB_TRAFFIC_CLASS=98
export NVSHMEM_IB_GID_INDEX=3
export SGLANG_DP_ATTENTION_HANDSHAKE_PORT_DELTA=30
export SGLANG_DISAGGREGATION_WAITING_TIMEOUT=80
export SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT=80
export SGLANG_DG_CACHE_DIR=/workspace/cache/deep_gemm_h200
export MC_IB_TC=98
export NCCL_IB_TC=98关键环境变量说明
| 变量 | 作用 |
|---|---|
NVSHMEM_BOOTSTRAP_UID_SOCK_IFNAME |
NVSHMEM 通信使用的网络接口 |
NVSHMEM_IB_TRAFFIC_CLASS /
NVSHMEM_IB_GID_INDEX |
InfiniBand 流量分类和 GID 索引,确保 IB 传输优先级 |
SGLANG_DP_ATTENTION_HANDSHAKE_PORT_DELTA |
DP Attention 节点间握手端口偏移量,避免端口冲突 |
SGLANG_DISAGGREGATION_WAITING_TIMEOUT |
分离部署等待超时(秒) |
SGLANG_DISAGGREGATION_BOOTSTRAP_TIMEOUT |
分离部署引导超时(秒) |
SGLANG_DG_CACHE_DIR |
DeepGemm 编译缓存目录,避免重复 JIT 编译 |
MC_IB_TC / NCCL_IB_TC |
Mooncake 和 NCCL 的 IB 流量分类,与 NVSHMEM 保持一致 |
几个设置成TC=98 表示使用 InfiniBand
的高优先级流量类别,确保 KV
Transfer(Mooncake)和集合通信(NCCL)优先于其他流量
3. Prefill 实例启动
两个 Prefill 实例启动命令完全一致,分别在两台独立的单机八卡机器上执行。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
python3 -m sglang.launch_server \
--model-path deepseek-v3.2 \
--host 0.0.0.0 \
--port 8055 \
--trust-remote-code \
--served-model-name DeepSeek-V3.2 \
\
`# ===== PD分离配置 =====` \
--disaggregation-mode prefill \
--disaggregation-ib-device mlx5_0,mlx5_1,mlx5_2,mlx5_5,mlx5_6,mlx5_7,mlx5_8,mlx5_9 \
--disaggregation-transfer-backend mooncake \
\
`# ===== 并行策略 =====` \
--tensor-parallel-size 8 \
--data-parallel-size 8 \
--enable-dp-attention \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
\
`# ===== MoE 配置 =====` \
--moe-a2a-backend deepep \
--deepep-mode normal \
--ep-num-redundant-experts 0 \
--load-balance-method round_robin \
--enable-expert-distribution-metrics \
\
`# ===== 内存与调度 =====` \
--mem-fraction-static 0.8 \
--max-running-requests 512 \
--chunked-prefill-size 65536 \
\
`# ===== (EAGLE) =====` \
--speculative-algorithm EAGLE \
--speculative-num-steps 1 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 2 \
\
`# ===== Attention 与tool =====` \
--attention-backend nsa \
--tool-call-parser deepseekv32 \
--reasoning-parser deepseek-v3 \
\
`# ===== debug =====` \
--log-requests \
--log-requests-level 0 \
--collect-tokens-histogram \
--enable-metrics \
--enable-cache-report \
--gc-warning-threshold-secs 0.1Prefill 参数要点
| 参数 | 值 | 说明 |
|---|---|---|
--deepep-mode |
normal |
Prefill 使用 normal 模式,吞吐优先 |
--load-balance-method |
round_robin |
Prefill 侧使用轮询负载均衡 |
--chunked-prefill-size |
65536 |
分块预填充大小,平衡延迟与吞吐 |
--max-running-requests |
512 |
Prefill 并发请求上限 |
--enable-expert-distribution-metrics |
- | 启用专家分布监控,辅助调优 |
4. Decode 实例启动
Decode 实例跨两个节点部署,TP=16,DP=16,两个节点需分别启动。
节点 0(node-rank 0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
python3 -m sglang.launch_server \
--model-path deepseek-v3.2 \
--host 0.0.0.0 \
--port 8055 \
--trust-remote-code \
--served-model-name DeepSeek-V3.2 \
\
`# ===== PD分离配置 =====` \
--disaggregation-mode decode \
--disaggregation-ib-device mlx5_0,mlx5_1,mlx5_2,mlx5_5,mlx5_6,mlx5_7,mlx5_8,mlx5_9 \
--disaggregation-transfer-backend mooncake \
\
`# ===== 多节点配置 =====` \
--dist-init-addr 10.93.161.35:19378 \
--nnodes 2 \
--node-rank 0 \
\
`# ===== 并行策略 =====` \
--tensor-parallel-size 16 \
--data-parallel-size 16 \
--enable-dp-attention \
--moe-dense-tp-size 1 \
--enable-dp-lm-head \
\
`# ===== MoE 配置 =====` \
--moe-a2a-backend deepep \
--deepep-mode low_latency \
--ep-num-redundant-experts 0 \
--prefill-round-robin-balance \
\
`# ===== 内存与调度 =====` \
--mem-fraction-static 0.8 \
--max-running-requests 1024 \
\
`# ===== (EAGLE) =====` \
--speculative-algorithm EAGLE \
--speculative-num-steps 1 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 2 \
\
`# ===== Attention 与 tool =====` \
--attention-backend nsa \
--tool-call-parser deepseekv32 \
--reasoning-parser deepseek-v3 \
\
`# ===== CUDA Graph =====` \
--cuda-graph-bs 1 2 3 4 5 6 8 10 12 16 24 32 64 \
\
`# ===== debug =====` \
--log-requests \
--log-requests-level 0 \
--collect-tokens-histogram \
--enable-metrics \
--enable-cache-report \
--gc-warning-threshold-secs 0.1节点 1(node-rank 1)
1
2
3
4
5
6
7
python3 -m sglang.launch_server \
\
`# ===== 别的都一样,多节点配置不同 =====` \
--dist-init-addr 10.93.161.35:19378 \
--nnodes 2 \
--node-rank 1 \
\Decode 参数要点
| 参数 | 值 | 说明 |
|---|---|---|
--deepep-mode |
low_latency |
Decode 使用低延迟模式,降低 Token 生成延迟 |
--prefill-round-robin-balance |
- | Decode 侧轮询从多个 Prefill 实例接收 KV |
--max-running-requests |
1024 |
Decode 并发请求上限,高于 Prefill 以支撑更多并发 decode |
--cuda-graph-bs |
1 2 3 4 5 6 8 10 12 16 24 32 64 |
CUDA Graph 捕获的 batch size 列表,减少 decode 阶段 kernel launch 开销 |
--dist-init-addr |
10.93.161.35:19378 |
多节点分布式初始化地址(节点 0 的 IP:Port) |
--nnodes |
2 |
Decode 跨 2 个节点 |
--node-rank |
0 / 1 |
节点序号 |
5. Prefill vs Decode 关键配置对比
| 配置项 | Prefill | Decode |
|---|---|---|
--disaggregation-mode |
prefill |
decode |
--tensor-parallel-size |
8 | 16 |
--data-parallel-size |
8 | 16 |
--deepep-mode |
normal(吞吐优先) |
low_latency(延迟优先) |
--max-running-requests |
512 | 1024 |
--load-balance-method |
round_robin |
- |
--prefill-round-robin-balance |
- | 启用 |
--chunked-prefill-size |
65536 | - |
--enable-expert-distribution-metrics |
启用 | - |
--cuda-graph-bs |
- | 1 2 3 4 5 6 8 10 12 16 24 32 64 |
| 多节点 | 单节点 | 双节点(--nnodes 2) |
6. 部分参数解析
6.1 DP Attention + DeepEP
--enable-dp-attention:对 MoE 的 Attention 部分做数据并行,每个 DP rank 独立处理不同请求的 attention,提高吞吐--moe-dense-tp-size 1:MoE 中 dense 层(shared expert)的 TP 大小为 1,配合 DP Attention 实现细粒度并行--enable-dp-lm-head:LM Head 也做数据并行,减少通信开销--moe-a2a-backend deepep:使用 DeepEP 做 All-to-All 通信,比默认 NCCL 更高效
6.2 NSA(Native Sparse Attention)
--attention-backend nsa:DeepSeek-V3.2 原生稀疏注意力,仅计算重要 token 的 attention,大幅降低长序列显存和计算开销
6.3 EAGLE 推测解码
--speculative-algorithm EAGLE:使用 EAGLE 算法进行推测解码--speculative-num-steps 1+--speculative-num-draft-tokens 2:保守配置,每次推测 2 个 token--speculative-eagle-topk 1:Top-1 采样,减少推测开销
7. 大规模部署中的EP参数
在sglang的实现中,针对attention和FFN的参数是分开的,也就是dp控制的是attention部分,ep控制的是ffn moe部分
MoE 专家并行(EP)中的三个核心步骤:
- Dispatch (分发): 将 token 发送到其对应的专家所在的 GPU
- 根据 top-k 门控结果确定每个 token 需要去哪些专家
- 执行 All-to-All 通信将 token 路由到目标 rank
- Compute (计算): 在本地 GPU 上执行专家计算
- 由
--moe-runner-backend控制具体计算后端
- 由
- Combine (聚合): 将计算结果发回原始 token 所在的 GPU
- 执行反向 All-to-All 通信
- 按 top-k 权重合并结果
开启EP时有两个参数很重要:
--moe-a2a-backend控制 MoE (Mixture of Experts) 的 All-to-All 通信后端,即专家并行中 token 在不同 GPU 之间分发和聚合的通信实现--moe-runner-backend控制 MoE 专家计算的核心 GEMM 实现,即路由专家的上投影(gate/up)、下投影(down)等矩阵乘法的计算内核。
参数--moe-a2a-backend设置:
| 后端 | 说明 |
|---|---|
none |
默认值,不使用专用 A2A 后端(使用基础 TP 模式) |
deepep |
DeepSeek 团队的高性能 EP 实现,支持 low_latency 和 normal 两种模式 |
mooncake |
月之暗面的 EP 实现,使用 RDMA 优化 |
... |
其它实现 |
- 纯TP非EP下,不需要moe-a2a,不需要这个,就是none
- 开启EP下,可以选择deepep和mooncake,一般用deepep
参数--moe-a2a-backend设置:
| 后端 | 说明 | 适用场景 |
|---|---|---|
auto |
默认值,自动选择 | - |
triton |
Triton 实现的 fused MoE | bf16 模型默认 |
deep_gemm |
DeepSeek 的 DeepGEMM | FP8 + 开启EP |
flashinfer_trtllm |
FlashInfer TRT-LLM kernels | FP8/FP4 on Blackwell(sm100) |
cutlass |
CUTLASS 实现 | 通用实现 |
| … | … | … |
- 如果是bf16模型,一般就是用fused moe,当然fused moe算子也有fp8的实现
- 如果是deepseek这种fp8,在开启EP下,就是用deep_gemm,不开EP,就是用fp8的fused moe算子
sglang的A2A和矩阵计算的对应关系如下:
| 场景 | A2A Backend | Runner Backend | 实际使用 |
|---|---|---|---|
| 纯 TP + bf16 | none |
auto → triton |
Fused MoE (Triton) |
| 纯 TP + FP8 (sm100) | none |
auto → flashinfer_trtllm |
FlashInfer TRT-LLM |
| EP + FP8 + deepep | deepep |
deep_gemm |
DeepGEMM |
| EP + FP8 + deepep | deepep |
auto |
DeepGEMM (low_latency) 或 Triton (normal) |
评论
匿名评论隐私政策




