Yifan Zhang, Zhiheng Chen, Ye Qiao, Sitao Huang
University of California, Irvine
2025 preprint
Presenter: wzw
Date: 2026-03-24
prefill 是 compute-bound,decode 是 memory-bound,static attention 很难兼顾两者。DPR 在运行时交换 attention logic,保留 TLMM + weight buffering 为 static。768-token TTFT 从 11.10 s 降到 8.80 s。Prefill: 处理整段 prompt,attention 更像 matrix-matrix,主要吃 compute / LUT / URAM。Decode: 一次一个 token,attention 退化成 vector-matrix,主要吃 KV-cache DDR bandwidth。TLMM 和 on-chip weights 更难做大。
Prefill attention 的复杂度近似随序列长度 quadratic 增长。Decode attention 的计算不大,但 KV-cache 流量随历史长度线性增长。
Table Lookup Linear, RMSNorm, 其他 element-wise operators。Prefill RM 偏 compute-heavy,Decode RM 偏 KV-cache-centric。static region + reconfigurable partition (RP)。prefill attention RM,进入生成阶段后切到 decode attention RM。PS 通过 PCAP 下发 partial bitstream,只重配置 dynamic region。
Linear projections 在两个阶段都用 TLMM,权重常驻片上。Prefill attention: 类 FlashAttention block processing,重点是 Q reuse 和 token-level parallelism。Decode attention: L=1,没有 Q reuse,退化成面向 K/V cache 的 memory-bound 流程。TLMM 做 projection,dynamic region 里是 prefill attention RM。Q 复用。partial reconfiguration,换成 decode attention RM。KV-cache-centric decode 数据流,重点拉高 DDR 有效带宽。Q 直接旁路进片上 buffer,输出先本地缓存再回写。
Prefill attention 更像 compute-bound kernel。Decode attention 更像 memory-bound kernel。
RP size / PE count / parallelism。$$r_{proj} + \max(r_{atten}^{pre}, r_{atten}^{dec}) \le R_{total}$$
Equivalent Total 106% 成立的前提。$$T_{pre} = \frac{P_{proj}L}{f_{pre}(r_{proj})} + \frac{P_{atten}L^2}{g_{pre}(r_{atten}^{pre})} + T_{weights}$$
$$T_{dec} = \frac{D_{proj}}{f_{dec}(r_{proj})} + \frac{D_{atten}L}{g_{dec}(r_{atten}^{dec})} + T_{weights}$$
prefill 随 L^2 变坏,更该优化 compute。decode 随 L 受带宽支配,更该优化 KV-cache access。
prefill attention 一结束,attention 模块已经可以被换出。reconfiguration ≈ 45 ms,
剩余 projection + FFN ≈ 31 ms @ 128 tokens,
有效重配置开销下降约 75%。KV260BitNet 0.73BVitis HLS 2024.1 + Vivado 2024.1TeLLMedecode throughput、TTFT / prefill time、resource breakdown
768 tokens 从 11.10 s 降到 8.80 s,大约 20%-25% 改善。2048-token 时 PD-Swap 还能保持 >10 token/s,TeLLMe 约 5 token/s。102K LUT, 176K FF, 124.5 BRAM, 62 URAM, 750 DSP25 -> 27.8 token/s
5.2 -> 5.67 token/Jprefill/decode asymmetry 从调度问题提升成了运行时硬件形态切换问题。TLMM 和线性层保持 static。TLMM / projection 留在 static,attention 放到 RP。HP-port remapping、DSE、overlapped reconfiguration。BitNet 0.73B。context-aware reconfigurationKV-cache hierarchy