Files
myWiki/concepts/keydiff.md

46 lines
1.6 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: "KeyDiff"
created: 2026-06-18
updated: 2026-06-18
type: concept
tags: ["kv-cache", "attention", "intra-head-eviction"]
sources: []
---
# KeyDiff
## 定义
KeyDiff (Park et al., 2025) 是一种 [[heuristic-metric]],利用 Key 向量的**几何特征**(相邻位置 Key 向量之间的差分模式)来评估 KV Cache token 的重要性。它是 LU-KV 实验中使用的第二种 intra-head 指标π_2
## 核心机制
与传统方法依赖注意力权重不同KeyDiff 通过分析 Key 向量本身的结构变化来识别关键 token
1. 计算相邻位置 Key 向量之间的差异
2. Key 向量变化剧烈的 token 位置往往对应语义转折/关键信息点
3. 基于差分模式评分,保留高分 token
## 与 SnapKV 的对比
| 维度 | SnapKV (π_1) | KeyDiff (π_2) |
|------|-------------|--------------|
| 评分来源 | 注意力权重 | Key 向量几何 |
| 视角 | Query-Key 交互 | Key 内部分布 |
| 对注意力模式假设 | 依赖 | 不依赖 |
| 与 Oracle 对齐度 | 各 head 不同 | 各 head 不同 |
LU-KV 实验表明,两种指标在不同 head 中的 [[optimality-gap]] 模式不同——这正是 LU-KV "指标无关"设计的价值:无论选用哪种指标,都能找到最优预算配置。
## 相关概念
- [[heuristic-metric]] — KeyDiff 是启发式指标的一种
- [[snapkv]] — 常用的注意力权重指标
- [[intra-head-eviction]] — KeyDiff 属于头内驱逐方法
- [[tang-lukv|LU-KV]] — 可兼容 KeyDiff 作为 intra-head scoring 方法
## 参考
- KeyDiff (Park et al., 2025)
- [[tang-lukv|LU-KV]] (Tang et al., ICML 2026)