Files
myWiki/concepts/kv-cache-eviction.md

51 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "KV Cache Eviction"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: ["llm-inference", "kv-cache", "memory-optimization"]
sources: []
---
# KV Cache Eviction
## 定义
KV Cache EvictionKV 缓存驱逐)是在不显著损失模型性能的前提下,选择性删除 [[kv-cache]] 中重要性较低的 token 对 (k, v),以降低内存占用并加速推理的技术。
## 两阶段范式
现代 KV Cache Eviction 方法通常采用两阶段范式:
1. **[[intra-head-eviction]]**在每个注意力头内设计评分指标如注意力累积分数、Key 向量几何特征),选出高分 token
2. **[[cross-head-budget-allocation]]**:在不同头之间分配差异化预算,利用各头对信息密度的异质性
## 主要方法
| 方法 | 策略类型 | 评分依据 |
|------|---------|---------|
| [[snapkv]] | Intra-head | 累积注意力分数 + 观察窗口 |
| [[keydiff]] | Intra-head | Key 向量几何特征(差分) |
| [[pyramidkv]] | Cross-head | 静态金字塔形(信息漏斗假说) |
| [[adkv]] | Cross-head | 动态全局 Top-K注意力熵 |
| [[tang-lukv|LU-KV]] | Cross-head | 全局组合优化 + 长期边际效用 |
## 核心挑战
传统方法依赖**瞬时启发式指标**instantaneous heuristic metrics存在根本缺陷
- 假设注意力分数在不同 head 间可比(实际分数尺度差异大)
- 高分 head ≠ 长期信息保真度高
- 忽略 [[optimality-gap]]:启发式指标与 [[oracle-importance]] 的差距
## 相关概念
- [[long-horizon-utility]] — 超越瞬时分数,评估 token 的未来贡献
- [[marginal-utility]] — 预算分配的边际收益视角
- [[global-combinatorial-optimization]] — 全局最优预算分配的形式化
## 参考
- H2O (Zhang et al., 2023)
- [[tang-lukv|LU-KV]] (Tang et al., ICML 2026)