avatar
Articles
19
Tags
6
Categories
0
Home
Archives
Tags
Categories
List
  • Music
  • Movie
Link
About
scmmm's blogPagedAttention Back to Home
Home
Archives
Tags
Categories
List
  • Music
  • Movie
Link
About

PagedAttention

Created2026-07-21|Updated2026-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
cover of next post
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 阶段,输入长度变为 ...
avatar
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
PagedAttention2026-07-21
FlashAttention 原理
FlashAttention 原理2026-07-20
面试积累 - FFN 层激活函数
面试积累 - FFN 层激活函数2026-07-20
LLM学习计划
LLM学习计划2026-07-20
Hello World
Hello World2026-07-20
© 2020 - 2026 By scmmm