Articles
19
Tags
6
Categories
0
Home
Archives
Tags
Categories
List
Music
Movie
Link
About
scmmm's blog
PagedAttention
Back to Home
Home
Archives
Tags
Categories
List
Music
Movie
Link
About
PagedAttention
Created
2026-07-21
|
Updated
2026-07-21
|
Post Views:
Author:
scmmm
Link:
http://example.com/2026/07/21/PagedAttention/
Copyright Notice:
All articles on this blog are licensed under
CC BY-NC-SA 4.0
unless otherwise stated.
AIinfra,LLM
Next
FlashAttention 原理
在介绍FlashAttention之前,先介绍 LLM 推理的两个阶段,一个是 prefill 阶段,一个是 decode 阶段。 在 prefill 阶段,我们会把整段 prompt 交给 LLM ,此时模型得到 KV cache,输入是一个 $n*d$ 维度的向量, 显然,对于每一层都一样,我们通过 Roofline 模型计算计算强度 计算强度 = \frac{总计算量(FLOPS)}{总访存量(Byte)}以A100为例,显存宽带为 2 TB/s ,浮点性能为 312 TFLOPS ,当模型计强度超过 $\frac{312}{2}=156$ 的时候,性能受限于浮点性能,当低于这个数的时候,性能受限于宽带,这个值也叫做硬件平衡点。 在 prefill 阶段,假设输入为 [Batch_size,句子长度len,模型隐藏维度d] 每一层都输入一个完整的句子,可以得到计算强度为 计算强度 = \frac{len*d*d}{len*d+d*d}当 $len$ 较大的时候,计算强度 = $d$ ,此时远超硬件平衡点,故性能受限于浮点性能。 而在 decode 阶段,输入长度变为 ...
scmmm
B.S. in Biology & Computer Science, Shandong University,2022-2026
M.S. in Computer Science, ShanghaiTech University(Research conducted at ICT,CAS),2026-
Research Focus: AI for EDA
Articles
19
Tags
6
Categories
0
Follow Me
Recent Posts
PagedAttention
2026-07-21
FlashAttention 原理
2026-07-20
面试积累 - FFN 层激活函数
2026-07-20
LLM学习计划
2026-07-20
Hello World
2026-07-20
繁