Prefill-Decode Resource Divergence(Prefill vs Decode 资源分歧)

定义

LLM 推理的两个阶段——Prefill 和 Decode——对硬件资源的需求正交:Prefill 是 compute-bound,Decode 是 memory-bandwidth-bound。Reasoning-centric 工作负载(OSL ≫ 10k)将 >99% wall-clock time 花在 decode,使系统长期处于低 arithmetic intensity 的低效状态。

两阶段特性对比

DimensionPrefillDecode
Compute TypeMatrix-Matrix (GEMM) + tiled attentionMatrix-Vector (GEMV)
Attention KernelFlashAttention / FlashAttention-2 / FlashAttention-3(IO-aware prefill;H100 FP8)FlashDecoding / FlashDecoding++
Arithmetic IntensityHigh(reuse weights across all tokens)极低(每 token 读全部 weights + KV)
BottleneckCompute (FLOPS)Memory Bandwidth + Capacity
SM OccupancyHighLow / Variable
HBM BW UtilizationLow (≈20-30%)High (≈85% for 8B)
Latency ProxyTTFTTPOT
Reasoning Share<1%>99%

核心矛盾

同一加速器(如 H200)无法同时最优化两个阶段:

  • Prefill 需要高 TFLOP tensor cores,HBM 带宽不是瓶颈
  • Decode 需要高 HBM 带宽和容量,tensor cores 大量闲置

推理模型的出现使这一矛盾尖锐化:

  • Standard chat(OSL ≈ 500):prefill 占比尚可
  • Reasoning(OSL ≫ 10k):>99% 时间在 decode 的低效 regime

实测数据(H200)

Small Model (8B)

  • Prefill: HBM BW util ≈30%, high SM occupancy
  • Decode: HBM BW util ≈85%, variable SM occupancy
  • 两者呈”两台不同机器”的行为

Frontier Model

  • 405B Decode: HBM BW util ≈65% (weights reads dominate)
  • 671B Decode: HBM BW util ≈50-60% (sync/routing latency, 非 bandwidth bound)
  • 大模型 decode 的 low BW util 说明瓶颈已从纯带宽转向 sync 开销

Reasoning 的乘数效应

KV Cache 增长

  • KV cache 线性增长 with OSL
  • Decode KV 是 persistent(prefill KV 是 transient)
  • 8B: 20M token aggregate output → 2 TB KV demand
  • 405B: 1.05 MB/token → batch=1K with long context = 100% saturation

Agentic AI 进一步放大

Agent 工作负载将推理从单条长链变为多步有状态执行:

  • Planner / executor / verifier / retrieval / tool calls 各维护 KV state
  • Fan-out × branching depth × tool interaction → multiplicative memory demand
  • CPU-GPU tight coupling:CPU 维持 agent environments, tool execution, per-agent state
  • 瓶颈从 isolated GPU → system-wide(HBM + host DRAM 同时受压)

硬件解耦方向

论文提出将 prefill 和 decode 物理解耦到不同硬件:

Prefill Tier

  • 高 TFLOP accelerators(compute-optimized)
  • Moderate HBM bandwidth 即可
  • 可以接受 cost-optimized memory subsystem

Decode Tier

  • Memory-centric hierarchy
  • HBM → DDR/LP → CXL → NVMe tiered KV placement
  • 3D-stacked memory(如 D-Matrix SRAM-based)缓解 KV read bandwidth
  • HBF (High-Bandwidth Flash):增容但有 read/write asymmetry + power 挑战

3D-stacked AI chip 视角(Voxel 论文)

Voxel 在 3D-Stacked AI Chip 上量化了两阶段对设计旋钮的不同响应:

设计旋钮Prefill(compute/NoC-bound)Decode(memory-bound)
DRAM 带宽扩 BW 收益有限显著降 latency,~10 TBps 后平台
NoC 带宽低于 32 B/cycle 显著拖慢不敏感
Per-core SRAM大 SRAM 收益有限(FLOPS 已饱和)大 SRAM 利于 prefetch,BW 饱和后递减
Compute paradigmcompute-shift 相对 SPMD 46.73% 提升paradigm 差异仍存在但 NoC 非主瓶颈
Core 数量过多 core 加剧 bank 冲突同上,能效可能下降

绑定互连

  • NVLink + optical interconnects 跨 tier 低延迟
  • Explicit KV placement, migration, proactive eviction

与现有概念的关联

这一发现为以下已有 wiki 概念提供了实证基础:

相关概念

2026-09-24:弹性边界

Crossflow 显示静态 P/D 分池跟不上相位比波动(分钟 peak-to-mean 最高 4.7×;agentic 小时比中位 24.5×)。角色固定、边界用 decode 租约弹性化后,吞吐 geomean +16.2–17.4%。

Encode 第三轴(MLLM EPD,2026-09-29)

文本侧 Prefill/Decode 正交之外,EAServe 指出 MLLM Encode 再引入短前向、批–延迟敏感的第三轴:入口饥饿与 encode GPU 空转并存;仅加微批会淹没下游(Table 1)。Encode-aware 调度把入口利用率拉到约 80%,P99 TTFT(image, Λ=2)相对 Dynamo 233.8→10.8 s。

并行度也随阶段分歧(2026-10-07)

并行策略三分账(Dell,8×A100):prefill 下 TP8 约 40% TTFT 耗在 NCCL,PP 更优;decode 下 PP 气泡主导,TP 更优;decode 有效 NVLink 带宽仅 ~150 GB/s(理论 25%),延迟受限。PD 分离后两侧应各选并行度。

具身 VLA:瓶颈看动作张量形状(2026-10-07)

VLA 负载刻画(ASPLOS’27):batch-1 闭环下,去噪动作头 GEMM 落在 RTX 4090 屋脊点(163.9 FLOP/B)下方,骨干与视频 DiT 在上方——资源分歧由 动作张量维度 而非 prefill/decode 阶段决定;自回归 OpenVLA 的 6 次 cached decode 仍占 E2E 67%。

同一阵列按阶段换形状与量化(2026-10-08)

DynaCore 不拆两类芯片,而是让脉动阵列在 prefill(方阵、W8A8)与 decode(扁平 1×1024 + Split-K、W4A16)间逐批切换;vs FIGLUT TTFT 3.50×、TPOT 36.55×,精度相对 FP16 平均掉 0.07%。

Citations

[1] Understanding_Inference_Scaling_for_LLMs.pdf [2] arXiv:2609.31551 — EAServe [3] arXiv:2610.05305 — Parallelism compute–comm trade-offs [4] arXiv:2610.05062 — VLA workload characterization [5] arXiv:2610.07443 — DynaCore