Auto-sync: 2026-04-16 17:30

This commit is contained in:
2026-04-16 17:30:41 +08:00
parent b2250c60b2
commit c999498de4
662 changed files with 3797 additions and 21340 deletions

View File

@@ -1,23 +0,0 @@
# KV Cache
## Metadata
- **Type**: Concept
- **Category**: AI/LLM/Inference Optimization
## Definition
KV CacheKey-Value Cache是 Transformer 模型推理优化中的关键技术。KKey和 VValue是由每个 token 的向量化后通过线性变换得到的两类向量用于注意力机制计算。KV Cache 将这些历史 K/V 保存下来,使得后续步骤不需要重复计算,从而加速推理。
## Details
- **K 和 V 的来源**: 每个 token 的向量化结果通过线性变换得到
- **作用**: 避免重复计算,提高推理效率
- **局限性**: KV Cache 随上下文长度、层数、头数、维度线性增长,是推理中的主要显存开销之一
- **优化方案**: vLLM 的 PagedAttention 将 KV Cache 切分为固定大小的块管理
## Related Concepts
- [[vLLM]]
- [[PagedAttention]]
- [[LLM]]