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 的低效状态。
两阶段特性对比
| Dimension | Prefill | Decode |
|---|---|---|
| Compute Type | Matrix-Matrix (GEMM) + tiled attention | Matrix-Vector (GEMV) |
| Attention Kernel | FlashAttention / FlashAttention-2 / FlashAttention-3(IO-aware prefill;H100 FP8) | FlashDecoding / FlashDecoding++ |
| Arithmetic Intensity | High(reuse weights across all tokens) | 极低(每 token 读全部 weights + KV) |
| Bottleneck | Compute (FLOPS) | Memory Bandwidth + Capacity |
| SM Occupancy | High | Low / Variable |
| HBM BW Utilization | Low (≈20-30%) | High (≈85% for 8B) |
| Latency Proxy | TTFT | TPOT |
| 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 paradigm | compute-shift 相对 SPMD 46.73% 提升 | paradigm 差异仍存在但 NoC 非主瓶颈 |
| Core 数量 | 过多 core 加剧 bank 冲突 | 同上,能效可能下降 |
绑定互连
- NVLink + optical interconnects 跨 tier 低延迟
- Explicit KV placement, migration, proactive eviction
与现有概念的关联
这一发现为以下已有 wiki 概念提供了实证基础:
- Disaggregated Inference — Prefill/Decode 解耦是该概念的阶段层变体
- Heterogeneous Inference — 不同阶段用不同硬件是异构推理的核心动机
- Inference Capacity Trap — Decode 阶段是 capacity trap 的主战场
- Reasoning Cliff — Decode 的 KV 线性增长导致 cliff
- Parallelism Transition Point — 不同阶段的 optimal parallelism 不同(prefill: DP; decode: TP)
- DSpark Speculative Decoding — decode 步 speculative 提高有效 τ(DeepSeek-V4 生产 +57–85% tok/s/user)
- FlashDecoding++ — GPU kernel 层:异步 partial softmax + flat GEMM + 启发式 GEMV/GEMM dataflow(相对 FlashDecoding ~1.37×)
- FlashAttention — IO-aware 精确 attention 起源(NeurIPS 2022)
- FlashAttention-2 — prefill/训练 IO-aware attention(相对 FA ~2×,73% A100 峰值)
- FlashAttention-3 — Hopper 异步 + FP8(740 TFLOPs/s,相对 FA2 1.5–2×)
- 3D-Stacked AI Chip — 3D 堆叠缓解 BW wall,prefill/decode 对 DRAM/NoC/SRAM 响应不同
- WaferLLM System — 晶圆级 mesh:decode GEMV + KV shift vs GPU PagedAttention
- Linear Attention Evolution — 2026-07 Kimi K3 引入 KDA(O(1) 状态)替代 O(N) KV cache,从根本上改变 decode bandwidth 格局
- Moonshot AI Kimi K3 — K3 是首个用 KDA+MLA 混合架构大规模验证”decode 不再是 O(N) bandwidth-bound”的模型
- MOCAP Prefill Pipelining — prefill-only WSC:chunked pipeline 专攻长上下文 prefill
- GEMM vs GEMV in LLM Inference — 算子形状、算术强度、Roofline、Prefill/Decode 对应
- SSD and NVMe Storage System — KV spill 至 NVMe tier 的延迟与带宽
相关概念
- Disaggregated Inference — 模块层和阶段层的解耦推理
- Heterogeneous Inference — 异构硬件针对不同推理阶段
- Inference Capacity Trap — Decode 阶段的 KV 饱和问题
- Reasoning Cliff — KV 增长的时序行为
- FlashDecoding++ — decode kernel 层(attention/flat GEMM)
- FlashAttention — IO-aware 精确 attention 起源
- FlashAttention-2 — prefill/训练 attention kernel
- Superscalar CPU Research (2023-2026) — Constable/Prophet 与 memory-bound decode
- Constable Load Elimination — KV cache likely-stable load
- FlashAttention-3 — Hopper prefill/训练 + FP8
- WaferLLM System — WSE-2 上 MeshGEMV/decode 与 KV shift
- Kv Cache — KV cache 是 decode 阶段的核心资源
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%。
decode 能耗按字节记账(2026-10-22)
Token-Energy Law:dense decode 每 token 板级能耗 = 常数 + 权重字节/有效 batch 项 + KV 字节×(历史+1) 项 + 每 token 耗时项;GH200/GB300 留出验证误差 ≤3.73%。batch 摊薄的只有权重项,KV 项随上下文线性增长,与本页「decode 吃带宽」的判断一致。
算子级共执行与 MoE 相位跷跷板(2026-11-03)
ConfluxServe 让同一 batch 内 prefill/decode 用不同 SP:线性共批、attention 分路径,goodput 1.26–1.62×。PDScope 在 CPU–GPU MoE 卸载上拆相位策略,prefill 2.5–10.3×、decode 2.1–6.1×。
GPU vs WSE 的 PD 形态(2026-11-02)
GPU–WSE Complementarity:同一分层基准下 GPU 更擅 prefill,WSE decode 单步约数十 µs 且跨长度较稳,GPU decode 随上下文从数十升至数百 ms;PD 模型中位误差 8.2%。
2026-11-10:再拆 decode 的代价
SiliconForge 把 decode 内部分成 attention(读增长 KV)与 FFN(流权重/专家),与 prefill 一并作为三个角色。映射固定时内存带宽翻倍使 TPOT −39–49%,FLOPs 翻倍最多 −1.8%;评测部署里内存读占 TPOT 的 57–95%。AFD 每个 MoE 层每步把激活跨池交换两次(DeepSeek-V3 为 116 次)。独立优化后,SLO goodput/kW 未见稳健的 AFD 部署级优势。
2026-11-11:AFD 在 NVL72 上的实测幅度
FastAFD 给出 decode 内再拆之后、相对调优 wide EP 的实测:标准 decode Sall 从持平到 1.17×,取决于专家是否够重、overlap 能否盖住 FFN。投机解码放大 overlap gain,轻专家 MiniMax 从持平升到 1.08×。文中把 Sall 写成 batch、overlap 与把 GPU 分给专家的成本三项乘积。
2026-11-12:智能体任务会把最佳 PD 比推到相反两端
Evolving Infra 在同一套 36–256×GB300 上对照:OSWorld 计算机使用任务每步追加截图,planner 收敛到 8P1D;Putnam 数学任务偏长 decode,只留 1–2 个 prefill 节点;Claude Code 夹着子智能体与暂停。负载从 Putnam 切到 OSWorld 时,在线拆分相对 Dynamo 均值 E2E 2.15×、P95 TTFT 3.58×。256 卡上静态 PD 的 P95 TTFT 从 36 卡的 142 s 升到 418 s,在线系统维持 10–14 s。
2026-11-13:decode 里稠密层与注意力不同速扩展
TKNP 在 Llama 3.1 405B、32K、batch 128 上测到注意力约占单层 decode 分项延迟的 70%,MLP / 投影相对平稳,并据此把节点内 TP 留给稠密层、把跨节点并行留给请求本地注意力。SlackTier 则把 Engram 查找嵌进 decode CUDA graph 的旁路流,按各层窗口决定表的存储层级。
2026-11-16:换模型与恢复前缀都会改写 prefill 账
ShadowPrefill 测量到切换调用的前缀命中从 80–89% 降到 44–65%,时延升到同模型的 1.5–3.2×;用正常流量的 SLO 空隙给「这次没选中」的模型做影子 prefill 后,切换 TTFT 降低 44.1%/47.0%。Host-Tier KV 说明在静态图 NPU 上,从宿主恢复与 prefill/decode 抢同一条引擎线程,fork 工作流的 P99 会因此升高 16–18%。
2026-11-17:消费级 MoE 按阶段改布局,decode 短 kernel 在卡内做空间流水
Tideway 给 prefill 扫描和 decode 驻留各准备一套内存布局,并在阶段切换时收回借出的 VRAM;TraceLab 上 TTFT 平均 2.40×,decode 吞吐平均 1.61×。SubGPU Pipelining 针对 decode 一层内数十个短 kernel 的带宽突发,把算子图绑到互不相交的 SM 池;硅上 36 层迭代从 14.970 ms 降到 13.424 ms(−10.33%)。
2026-11-18:只比 decode 的单芯片,以及只评 chunked prefill 的 ITL 加速器
Exstill 的 B300 对照只覆盖 decode,prefill 在预硅设计与 GPU 两侧都排除;12 用户时每路 50 µs 对 5.35 ms。LWS 的评测落在单条长上下文的 chunked prefill,批量服务与自回归 decode 明确不在范围。
2026-11-19:Chimera 在 Alveo U280 上针对 batch 1 decode 做计算–访存–布局协同设计,同板 Llama-3.2-1B W4 相对 FlexLLM 为 2.08×;能量对照也限定在 batch 1、上下文最长 4K。
2026-11-20:HETEROVLM 按权重复用把 encoder / prefill / attention 放在 Versal AIE,把小步 decode 放到紧挨 DDR 的 PL GEMV,并在 VC1902 上给出多请求与抢占的板上数字;XM-Sparse 针对长上下文 decode 的 HBM 容量,把热 KV 取回与 K-index 预取分成两套 I/O。
2026-11-23:用光学再生把 decode 的历史 KV 流量减半,以及把激活尾数留到 prefill 当场选
OptiDecode 在 decode 阶段缓存激活并用自由空间光学按 HBM 取回速率再生历史 KV;相对等带宽的理想 GPU KV 读取基线,30B–175B 稠密 MHA 在 32K 上下文下达到 1.92–1.99×。Kameleo 的吞吐数字落在 prefill 的 MXU 周期,注意力 GEMM 保持满尾数。
2026-11-24:投机解码里 prefill 仍可能压过 decode 收益,以及归队智能体的 TTFT
FOREST 在 GLM-4.5-Air 上相对 A800 投机解码端到端 5.5×,但 Llama 3.1-405B 上四卡 A800 仍快 1.32×,作者归到计算密集的 prefill;更长的生成更能摊掉这段开销。TripleKV 则表明,智能体从工具返回时的 TTFT 会被 L3 读取拉长,把 SSD 读藏进工具执行后,P95 TTFT 最高降 49%。
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
- arXiv:2610.28576 — Token-Energy Law
- arXiv:2610.39222 — GPU–WSE Complementarity
- arXiv:2610.37810 — ConfluxServe
- arXiv:2610.39216 — PDScope
- arXiv:2611.08299 — SiliconForge / Should You Split Decode
- arXiv:2611.07149 — FastAFD
- arXiv:2611.12304 — Evolving Infra
- arXiv:2611.13293 — Decode Token Parallelism (TKNP)
- arXiv:2611.13413 — SlackTier
- arXiv:2611.13176 — SHADOWPREFILL
- arXiv:2611.15126 — Host-Tier KV on ATOM+
- arXiv:2611.14848 — Tideway
- arXiv:2611.14904 — SubGPU Pipelining
- arXiv:2611.18859 — Exstill
- arXiv:2611.18523 — LWS / Mutable Inference
- arXiv:2611.21677 — Chimera
- arXiv:2611.23878 — HETEROVLM
- arXiv:2611.22280 — XM-Sparse
- arXiv:2611.19279 — OptiDecode
- arXiv:2611.25971 — Kameleo
- arXiv:2611.27701 — FOREST
- arXiv:2611.25112 — TripleKV