dpsk-cost-model / deepseek_cost.md
Ligeng Zhu
Add GB300 NVL72 serving cost estimate
4fdb2fb
|
Raw
History Blame Contribute Delete
19.1 kB

DeepSeek decode cost on B200 + 50 GB/s InfiniBand

本文估算 {deepseek-v4-pro, deepseek-v4-flash, deepseek-r1}B200 GPU + 每卡 50 GB/s InfiniBand 上、decode throughput 打满时的输出 token 成本。

结论先放前面。按常规 decode 平均 KV 长度约 5k,即 DeepSeek 官方 V3/R1 线上统计口径附近:

Model 主要瓶颈 饱和 decode 吞吐, 每张 B200 Decode cost
deepseek-v4-pro MoE all-to-all network 5,445 tok/s $0.306 / M output tok
deepseek-v4-flash MoE all-to-all network 13,518 tok/s $0.123 / M output tok
deepseek-r1 MoE all-to-all network, compute close 4,235-4,454 tok/s $0.374-$0.394 / M output tok

如果 50 GB/s 是理论带宽、实际只到 30 GB/s,那么上面的 network-bound 成本约乘以 50 / 30 = 1.667

Model 30 GB/s 实效带宽成本
deepseek-v4-pro $0.510 / M output tok
deepseek-v4-flash $0.206 / M output tok
deepseek-r1 $0.624-$0.656 / M output tok

如果换成 GB300 NVL72,关键不是单卡算力,而是 MoE all-to-all 能否留在单个 72-GPU NVLink domain 里。若可以留在 rack 内,并先按同样 $6 / GPU-hour 归一化:

Model, 5k KV on GB300 NVL72 主要瓶颈 吞吐, 每张 GB300 Decode cost
deepseek-v4-pro compute 12,605 tok/s $0.132 / M output tok
deepseek-v4-flash compute 49,014 tok/s $0.034 / M output tok
deepseek-r1 compute 6,158 tok/s $0.271 / M output tok

如果实际 GB300 租金是 P 美元/GPU-hour,上表成本需要再乘以 P / 6。如果 MoE all-to-all 仍然跨 rack 走外部网络,成本会重新退回对应 effective network bandwidth 的 network-bound 结果。

如果是 1M context decode,V4 的 CSA/HCA attention 仍然可控,但 R1/MLA 会被 attention FLOPs 打穿:

Model, 1M context 主要瓶颈 吞吐, 每张 B200 Decode cost
deepseek-v4-pro compute 4,403 tok/s $0.379 / M output tok
deepseek-v4-flash compute 11,818 tok/s $0.141 / M output tok
deepseek-r1 compute 39.6 tok/s $42.0 / M output tok

0. Sources used

本估算主要参考:

1. Scope and assumptions

只算 decode 输出 token 的 GPU 租金成本,不含:

  • prefill 成本;
  • KV cache on-disk storage / SSD / CPU / DRAM;
  • IB 交换机、NVSwitch、机房、电力、运维;
  • 空载、调度碎片、请求不均衡;
  • MTP/speculative decoding 的接受率收益;
  • 量化到 FP4/NVFP4 后可能带来的额外收益。

输入条件:

B200 price = $6 / GPU-hour
IB bandwidth = 50 GB/s per GPU

这里的 50 GB/s 是 NDR 400 Gb/s InfiniBand 的理论线速口径。实际 serving 里能吃到多少,取决于消息大小、GPU Direct RDMA/NCCL/DeepEP 实现、PCIe/NUMA/NIC 绑定、交换机拓扑、拥塞和多租户干扰。一个实用的经验口径是:

Scenario Effective bandwidth Multiplier vs 50 GB/s
理想大包 RDMA microbench 45-49 GB/s 1.02-1.11x
调好的 GPU Direct / NCCL 大包通信 40-47 GB/s 1.06-1.25x
非拥塞、拓扑较好的真实训练或 serving 通信 35-43 GB/s 1.16-1.43x
MoE all-to-all / dispatch-combine serving 路径 30-40 GB/s 1.25-1.67x
多租户、拥塞或拓扑/绑定未调好 20-30 GB/s 1.67-2.50x

因此本文主表仍保留 50 GB/s 理论上限,同时用 30 GB/s 作为 conservative serving estimate;如果是专用且调优较好的集群,可以把 40 GB/s 作为 optimistic serving estimate。

成本换算:

cost_per_M = price_per_hour * 1e6 / (throughput_tok_s_per_gpu * 3600)
           = 6 * 1e6 / (throughput * 3600)
           = 1666.667 / throughput

所以只要拿到每卡 decode 吞吐 T

T = 5,000 tok/s  ->  $0.333 / M output tok
T = 10,000 tok/s ->  $0.167 / M output tok
T = 20,000 tok/s ->  $0.083 / M output tok

2. Model constants

2.1 DeepSeek-R1, approximated by V3 architecture

R1 推理结构按 V3/R1 同架构估算:

hidden size h = 7168
layers = 61
MoE layers = 58
activated params = 37B
attention heads = 128
MLA KV compressed dimension d_c = 512
MLA RoPE dimension d_R = 64
routed experts per token = 8
shared expert = 1
decode effective experts E = 9

V3 PDF 的 decoding 部分把 shared expert 当作 routed expert 处理,所以每个 token 在 decode 中等价选择 9 个 experts。网络主表用 58 个 MoE 层;为了给调度和非 MoE 层边际开销留余量,也列一个 61 层保守口径。

2.2 DeepSeek-V4-Pro

来自 V4 PDF:

total params = 1.6T
activated params = 49B
layers = 61
hidden size h = 7168
all Transformer blocks use MoE
routed experts = 384
routed experts activated per token = 6
shared expert = 1
decode effective experts E = 7
expert intermediate dimension = 3072

attention heads n_h = 128
attention head dim c = 512
CSA compression m = 4
CSA sparse top-k = 1024
HCA compression m' = 128
sliding window n_win = 128
CSA indexer heads n_I = 64
CSA indexer dim c_I = 128

V4-Pro 前 2 层是 HCA,后续 59 层 CSA/HCA interleaved。本文按:

CSA layers = 30
HCA layers = 31

如果 interleaving 起始相反,attention FLOPs 会有很小变化;在 5k context 下主瓶颈是 MoE 网络,不影响主结论。

2.3 DeepSeek-V4-Flash

来自 V4 PDF:

total params = 284B
activated params = 13B
layers = 43
hidden size h = 4096
all Transformer blocks use MoE
routed experts = 256
routed experts activated per token = 6
shared expert = 1
decode effective experts E = 7
expert intermediate dimension = 2048

attention heads n_h = 64
attention head dim c = 512
query compression d_c = 1024
CSA compression m = 4
CSA sparse top-k = 512
HCA compression m' = 128
sliding window n_win = 128
CSA indexer heads n_I = 64
CSA indexer dim c_I = 128

V4-Flash 前 2 层是 pure sliding-window attention,后续 41 层 CSA/HCA interleaved。本文按:

SWA layers = 2
CSA layers = 21
HCA layers = 20

3. Network-bound estimate

这是常规 5k KV decode 的主瓶颈。

V4 PDF 的 EP 通信讨论给出一个很有用的简化:每个 token-expert pair 的 MoE compute 是 6 * h * d FLOPs,通信是 3 * h bytes。其中:

dispatch activation = h bytes       # FP8
combine output      = 2h bytes      # BF16
total               = 3h bytes

于是每张 GPU 的 network-bound decode 吞吐近似为:

T_net = B / (L_moe * E * 3 * h)

B     = per-GPU IB bandwidth in bytes/s
L_moe = number of MoE layers
E     = active experts including shared expert
h     = hidden size

3.1 V4-Pro

B = 50e9 bytes/s
L_moe = 61
E = 6 routed + 1 shared = 7
h = 7168

T_net = 50e9 / (61 * 7 * 3 * 7168)
      = 5,445 tok/s/GPU

cost = 1666.667 / 5445
     = $0.306 / M output tok

3.2 V4-Flash

B = 50e9 bytes/s
L_moe = 43
E = 7
h = 4096

T_net = 50e9 / (43 * 7 * 3 * 4096)
      = 13,518 tok/s/GPU

cost = 1666.667 / 13518
     = $0.123 / M output tok

3.3 DeepSeek-R1

MoE-only 58 层口径:

B = 50e9 bytes/s
L_moe = 58
E = 8 routed + 1 shared = 9
h = 7168

T_net = 50e9 / (58 * 9 * 3 * 7168)
      = 4,454 tok/s/GPU

cost = 1666.667 / 4454
     = $0.374 / M output tok

保守 61 层口径:

T_net = 50e9 / (61 * 9 * 3 * 7168)
      = 4,235 tok/s/GPU

cost = 1666.667 / 4235
     = $0.394 / M output tok

因此 R1 在这个假设下给:

deepseek-r1 decode cost ~= $0.37-$0.39 / M output tok

3.4 Bandwidth sensitivity

Model 50 GB/s cost 40 GB/s cost 35 GB/s cost 30 GB/s cost
V4-Pro $0.306/M $0.383/M $0.437/M $0.510/M
V4-Flash $0.123/M $0.154/M $0.176/M $0.206/M
R1, 58 MoE layers $0.374/M $0.468/M $0.535/M $0.624/M
R1, 61 conservative layers $0.394/M $0.492/M $0.562/M $0.656/M

这张表也是最重要的 sanity check:如果 IB 带宽不变,B200 的更高算力不会线性转化成 decode 降本,因为 MoE all-to-all 已经是主要瓶颈。

4. Compute-bound sanity check at 5k context

为了确认上面的 network bound 是否真的卡住,需要估算 compute upper bound。这里取 B200 dense 峰值,并假设有效 MFU 为 30%:

FP8 dense peak  = 4.5 PFLOP/s
BF16 dense peak = 2.25 PFLOP/s
FP4 dense peak  = 9.0 PFLOP/s
MFU = 30%

effective FP8  = 1.35 PFLOP/s
effective BF16 = 0.675 PFLOP/s
effective FP4  = 2.70 PFLOP/s

4.1 R1 compute at KV length S

R1/V3 MLA 的每 token decode FLOPs 近似分成两部分。

第一部分是 active params 的 GEMM:

F_fixed = 2 * activated_params
        = 2 * 37B
        = 74 GFLOPs/token

第二部分是 MLA attention 随 KV 长度增长的部分:

F_attn = L * 2 * S * n_h * (2 * d_c + d_R)

L   = 61
S   = average KV length
n_h = 128
d_c = 512
d_R = 64

S = 4989

F_attn = 61 * 2 * 4989 * 128 * (2 * 512 + 64)
       = 84.8 GFLOPs/token

F_total = 74.0 + 84.8
        = 158.8 GFLOPs/token

其中 fixed GEMM 近似按 FP8,attention core 近似按 BF16:

T_compute = 1 / (F_fixed / effective_FP8 + F_attn / effective_BF16)
          = 1 / (74e9 / 1.35e15 + 84.8e9 / 0.675e15)
          = 5,544 tok/s/GPU

对比 network bound:

T_net = 4,235-4,454 tok/s/GPU

所以 R1 在 5k KV 下是 network-bound,但 compute 已经比较接近。

4.2 V4 compute at KV length S

V4 的 attention 不再是 V3/R1 的全量 MLA,而是 CSA/HCA hybrid attention。简化估算如下。

固定 active-param GEMM:

V4-Pro:
F_fixed = 2 * 49B = 98 GFLOPs/token

V4-Flash:
F_fixed = 2 * 13B = 26 GFLOPs/token

CSA core attention 每层:

F_CSA_core_per_layer = 4 * n_h * c * (min(S / m, top_k) + n_win)

这里 4 来自 QK 和 PV 两次乘法,各自约 2 * n_h * c * entries

HCA core attention 每层:

F_HCA_core_per_layer = 4 * n_h * c * (S / m' + n_win)

CSA lightning indexer 需要扫描压缩后的 blocks,近似:

F_CSA_index_per_layer = 2 * n_I * c_I * (S / m)

其中 indexer 按 FP4 估算,core attention 按 BF16 估算。

V4-Pro, S = 4989

CSA entries = min(4989 / 4, 1024) + 128
            = 1152

HCA entries = 4989 / 128 + 128
            = 167

F_fixed = 98.0 GFLOPs/token
F_core  = 10.4 GFLOPs/token
F_index = 0.61 GFLOPs/token
F_total = 109.0 GFLOPs/token

T_compute = 1 / (98e9 / 1.35e15
               + 10.4e9 / 0.675e15
               + 0.61e9 / 2.70e15)
          = 11,331 tok/s/GPU

对比:

T_net = 5,445 tok/s/GPU

所以 V4-Pro 在 5k KV 下明显 network-bound。

V4-Flash, S = 4989

F_fixed = 26.0 GFLOPs/token
F_core  = 2.23 GFLOPs/token
F_index = 0.43 GFLOPs/token
F_total = 28.66 GFLOPs/token

T_compute = 44,002 tok/s/GPU
T_net     = 13,518 tok/s/GPU

所以 V4-Flash 在 5k KV 下也明显 network-bound。

4.3 5k KV final by min(compute, network)

Model T_compute T_net Final T Cost
V4-Pro 11,331 5,445 5,445 $0.306/M
V4-Flash 44,002 13,518 13,518 $0.123/M
R1, 58 MoE layers 5,544 4,454 4,454 $0.374/M
R1, 61 conservative layers 5,544 4,235 4,235 $0.394/M

5. 1M context estimate

1M context 是 V4 论文重点场景。这里 V4 与 R1 的差异会非常大。

5.1 R1 at S = 1,000,000

R1 的 MLA attention FLOPs 随 S 线性增长:

F_fixed = 74 GFLOPs/token

F_attn = 61 * 2 * 1,000,000 * 128 * 1088
       = 16,990 GFLOPs/token

F_total = 17,064 GFLOPs/token

吞吐:

T_compute = 1 / (74e9 / 1.35e15 + 16990e9 / 0.675e15)
          = 39.6 tok/s/GPU

cost = 1666.667 / 39.6
     = $42.0 / M output tok

这说明 R1/V3 结构并不适合原样跑 1M context decode。

5.2 V4-Pro at S = 1,000,000

V4-Pro 的 CSA sparse top-k 会把 CSA core attention 限住:

CSA entries = min(1,000,000 / 4, 1024) + 128
            = 1152

HCA 仍随 S / 128 增长,indexer 随 S / 4 增长:

F_fixed = 98.0 GFLOPs/token
F_core  = 73.6 GFLOPs/token
F_index = 122.9 GFLOPs/token
F_total = 294.5 GFLOPs/token

T_compute = 4,403 tok/s/GPU
T_net     = 5,445 tok/s/GPU
Final T   = 4,403 tok/s/GPU

cost = 1666.667 / 4403
     = $0.379 / M output tok

5.3 V4-Flash at S = 1,000,000

F_fixed = 26.0 GFLOPs/token
F_core  = 22.6 GFLOPs/token
F_index = 86.0 GFLOPs/token
F_total = 134.6 GFLOPs/token

T_compute = 11,818 tok/s/GPU
T_net     = 13,518 tok/s/GPU
Final T   = 11,818 tok/s/GPU

cost = 1666.667 / 11818
     = $0.141 / M output tok

5.4 MFU sensitivity for V4 at 1M

1M context 下 V4 更偏 compute-bound,因此 MFU 对成本有影响:

Model MFU 20% MFU 30% MFU 40%
V4-Pro $0.568/M $0.379/M $0.306/M, network capped
V4-Flash $0.212/M $0.141/M $0.123/M, network capped

6. GB300 NVL72 estimate

GB300 NVL72 和前面的 B200 + IB 估计不是简单换一张更快的 GPU。它的核心变化是一个 rack 内有 72 张 Blackwell Ultra GPU,形成 72-GPU NVLink domain;如果 MoE all-to-all 可以留在 rack 内,通信带宽从外部 IB 的几十 GB/s 级别变成 NVLink 的 TB/s 级别。

这里先按 $6 / GPU-hour 做归一化,方便和 B200 表直接比较。实际 GB300 租金若为 P 美元/GPU-hour,则所有 GB300 成本乘以 P / 6

官方 rack 级算力换算成每 GPU dense peak:

GB300 NVL72 rack = 72 GPUs

FP8 sparse rack peak  = 720 PFLOP/s  -> dense ~= 360 PFLOP/s rack ~= 5.0 PFLOP/s/GPU
BF16 sparse rack peak = 360 PFLOP/s  -> dense ~= 180 PFLOP/s rack ~= 2.5 PFLOP/s/GPU
FP4 dense rack peak   = 1080 PFLOP/s -> dense ~= 15.0 PFLOP/s/GPU

MFU = 30%

effective FP8  = 1.50 PFLOP/s/GPU
effective BF16 = 0.75 PFLOP/s/GPU
effective FP4  = 4.50 PFLOP/s/GPU

NVLink 5 的 per-GPU bandwidth 按 1,800 GB/s 估算:

T_net_NVL = T_net_50GB * (1800 / 50)

所以 5k KV 常规 decode 下的 NVLink network upper bound 已经远高于 compute bound:

Model T_compute on GB300 T_net over NVLink Final T Cost at $6/GPU-hour
V4-Pro 12,605 196,020 12,605 $0.132/M
V4-Flash 49,014 486,648 49,014 $0.034/M
R1 6,158 152,460-160,344 6,158 $0.271/M

这意味着:如果 all-to-all 真的留在单个 NVL72 rack 内,GB300 会把常规 5k decode 从 network-bound 推到 compute-bound。

但这是一个很强的拓扑假设。DeepSeek V3/R1 官方 decode 配置是 EP144,而单个 NVL72 只有 72 张 GPU;R1 如果照搬 EP144 就会跨两个 rack,重新吃外部网络。要拿到上表结果,需要把专家并行、专家复制、路由 locality 或冗余方案改到单 rack 内可用。V4-Pro/Flash 的 72-GPU rack 内部署也需要保证 routed experts 和 shared expert 的通信不溢出到 rack 外。

如果 MoE all-to-all 仍然走外部网络,那么 GB300 的更高算力不会改变 network-bound 成本。比如 effective network bandwidth 只有 30 GB/s 时,5k KV 成本仍然是:

Model 30 GB/s external network cost at $6/GPU-hour
V4-Pro $0.510/M
V4-Flash $0.206/M
R1 $0.624-$0.656/M

1M context 下,如果 all-to-all 仍在 NVLink rack 内,V4 和 R1 仍然是 compute-bound:

Model, 1M context on GB300 NVL72 Final T Cost at $6/GPU-hour
V4-Pro 5,242 tok/s $0.318/M
V4-Flash 15,020 tok/s $0.111/M
R1 44.0 tok/s $37.8/M

因此 GB300 NVL72 的主要价值不是把跨 rack MoE 网络瓶颈变快一点,而是尽量把 MoE serving 的通信问题变成 rack 内 NVLink 问题。一旦 workload spill 到外部网络,成本模型要优先看 external effective bandwidth,而不是 GB300 的 tensor core 峰值。

7. Interpretation

几个直观结论:

  1. 在 5k KV 常规 decode 下,B200 的更强算力不是主要降本来源。50 GB/s IB 先成为 MoE all-to-all 的瓶颈。
  2. V4-Pro 的 active params 是 49B,大于 R1/V3 的 37B,但 V4-Pro 每 token routed experts 从 8 降到 6;按 shared expert 也计入通信,V4-Pro 是 7 experts,R1 是 9 experts。所以在同样 50 GB/s IB 下,V4-Pro decode 成本略低于 R1。
  3. V4-Flash 由于 hidden size、层数、active params 都明显更小,decode 成本约为 V4-Pro 的 40%,约为 R1 的三分之一。
  4. 1M context 是 V4 架构优势最明显的地方。V4-Pro/Flash 的 CSA/HCA 把 long-context attention 控制住,而 R1/MLA 的 attention FLOPs 随 context 线性增长,成本会到几十美元每百万 output tokens 的量级。
  5. 如果要让 B200 在常规 decode 上继续降本,关键不是再加 GPU peak FLOPs,而是降低 MoE 通信量、提高 effective IB bandwidth、做更好的 expert locality、用更 aggressive 的 quantization/combine 压缩,或者靠 MTP/speculative decoding 提高每次 forward 产出的有效 tokens。
  6. GB300 NVL72 的关键分界线是 MoE all-to-all 是否在 72-GPU NVLink domain 内完成;留在 rack 内时 5k KV decode 变成 compute-bound,跨 rack 时仍然是 external network-bound。