We present QUOKA: Query-oriented KV selection for efficient attention, a training-free and hardware agnostic sparse attention algorithm for accelerating transformer inference under chunked prefill. While many queries focus on a smaller group of keys in the attention operator, we observe that queries with low cosine similarity with respect to the mean query interact more strongly with more keys and have the greatest contribution to final attention logits. By prioritizing these low cosine similarity queries, the behavior of full attention during the prefill stage can be closely approximated. QUOKA leverages this observation, accelerating attention by (1) first retaining a small set of representative queries and (2) then subselectin the keys most aligned with those queries. Through experiments on Needle-In-A-Haystack, LongBench, RULER, and Math500, we show that, while realizing a 3x reduction in time-to-first-token, 5x speedup in attention on Nvidia GPUs and up to nearly a 7x speedup on Intel Xeon CPUs, QUOKA achieves near-baseline accuracy, utilizing 88% fewer key-value pairs per attention evaluation.


翻译:本文提出QUOKA:一种面向查询的高效注意力键值选择方法,这是一种无需训练且与硬件无关的稀疏注意力算法,用于加速分块预填充场景下的Transformer推理。尽管注意力算子中的许多查询仅聚焦于较小的键集合,我们观察到与平均查询余弦相似度较低的查询会与更多键产生更强交互,并对最终注意力对数做出最大贡献。通过优先处理这些低余弦相似度查询,可以紧密逼近预填充阶段完整注意力的行为。QUOKA利用这一观察,通过(1)首先保留少量代表性查询,(2)进而筛选与这些查询最匹配的键,实现注意力加速。通过在Needle-In-A-Haystack、LongBench、RULER和Math500上的实验表明,QUOKA在实现首token生成时间降低3倍、Nvidia GPU上注意力计算加速5倍、Intel Xeon CPU上最高近7倍加速的同时,保持接近基线模型的精度,且每次注意力计算使用的键值对数量减少88%。

0
下载
关闭预览

相关内容

基于大语言模型的时序知识图谱推理模型蒸馏方法
专知会员服务
36+阅读 · 2025年1月10日
Llama-3-SynE:实现有效且高效的大语言模型持续预训练
专知会员服务
36+阅读 · 2024年7月30日
【AAAI2024】SeTformer: 视觉与语言处理的理想选择"
专知会员服务
21+阅读 · 2024年1月13日
搜索query意图识别的演进
DataFunTalk
13+阅读 · 2020年11月15日
Query 理解和语义召回在知乎搜索中的应用
DataFunTalk
25+阅读 · 2020年1月2日
推荐|caffe-orc主流ocr算法:CNN+BLSTM+CTC架构实现!
全球人工智能
19+阅读 · 2017年10月29日
YesOfCourse团队在Kaggle文本匹配竞赛中获得优异成绩
中国科学院网络数据重点实验室
10+阅读 · 2017年6月15日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员