DeepSeek-V4.1-Flash 在 H20-3e 上的 PD 分离服务优化

概述

Ant International AI Infra 团队针对 DeepSeek-V4.1-Flash,在 H20-3e 上做了分离式服务的优化。做法包括调整 prefill 与 decode 的并行度、让 BCG 配合 prefill CP 并支持有界 SWA 重放,同时对 Indexer 内核做了加速。最终配置与 TP4 相比,平均端到端延迟下降 65.5%,输出吞吐提升 2.91 倍。

节点内的 PD 部署里,prefill 和 decode 各自占用 4 张 GPU,KV cache 经 NVLink 传输。平均端到端延迟由 13.63s 降到 4.70s,输出吞吐从 847 tokens/s 升到 2,465 tokens/s。

Compared with TP4, the final PD configuration has 0.34× mean end-to-end latency, 0.16× mean time to first token, and 2.91× output throughput.

测量设置

请求由路由器分发给 prefill 和 decode 两个阶段,worker 之间通过 Mooncake NVLink 直接传递 KV 状态。基线方案在两个 worker 上都跑 TP4 attention 和 EP4 MoE,prefill scoring 用的是 eager BF16 Torch。

1. Prefill CP 与 Decode DP

prefill 阶段用交错上下文并行(Interleaved CP4),decode 阶段则对 attention 和 LM head 采用数据并行(DP4)。这一步把平均 TTFT 从 12.04s 压到 5.16s。

2. FP8 DeepGEMM 用于 Prefill Indexer

预填充阶段,Indexer 调用 DeepGEMM 的 fp8_mqa_logits 完成评分;键值先经 FP4 缩放与裁剪,再转成 E4M3。

Torch scores in BF16; DeepGEMM scores in E4M3 after scaling and clamping the FP4 keys

3. Breakable CUDA Graphs 用于 Prefill

prefill 侧借助 Breakable CUDA Graphs 捕获图安全片段并加以重放,再叠上有界 SWA 重放,小内核的启动开销因此减少。

Triton reduces the work for candidate publishing and fuses KV-slot writeback into one launch

4. Tensor-Parallel MoE

MoE 改用 TP 方式,把专家分片铺到所有 rank 上,从而避开 EP 下专家负载不均衡的问题。

Verify queries switch from one load and dequantization each to one shared BF16 key tile

从 prefill 时间线的对比看,TP 模式速度更快。

Both colocated configurations split prefill tokens; decode switches from splitting heads to splitting query rowsExpert-parallel prefill timeline showing 770.7 ms for five requests and 16,119 tokens.Tensor-parallel prefill timeline showing 656.5 ms for five requests and 16,104 tokens.

5-7. 其他优化

其余几项还包括:把 Indexer score tile 调大、将 prefill selection 与 writeback 融合、复用 paged K-tile,对性能再做细调。