Long-context decoding in LLMs is IO-bound: each token re-reads an ever-growing KV cache. Prior accelerations cut bytes via compression, which lowers fidelity, or selection/eviction, which restricts what remains accessible, and both can degrade delayed recall and long-form generation. We introduce MAC-Attention, a fidelity- and access-preserving alternative that accelerates decoding by reusing prior attention computations for semantically similar recent queries. It starts with a match stage that performs pre-RoPE L2 matching over a short local window; an amend stage rectifies the reused attention by recomputing a small band near the match boundary; and a complete stage fuses the rectified results with fresh attention computed on the KV tail through a numerically stable merge. On a match hit, the compute and bandwidth complexity is constant regardless of context length. The method is model-agnostic and composes with IO-aware kernels, paged-KV managers, and MQA/GQA. Across LongBench v2 (120K), RULER (120K), and LongGenBench (16K continuous generation), compared to the latest FlashInfer library, MAC-Attention reduces KV accesses by up to 99%, cuts token generation latency by over 60% at 128K, and achieves over 14.3x attention-phase speedups, up to 2.6x end-to-end, while maintaining full-attention quality. By reusing computation, MAC-Attention delivers long-context inference that is both fast and faithful. Code is available here: https://github.com/YJHMITWEB/MAC-Attention.git


翻译:大语言模型中的长上下文解码受限于IO瓶颈:每个词元都需要重新读取不断增长的KV缓存。现有加速方案通过压缩减少字节数会降低保真度,通过选择/淘汰机制则会限制可访问内容,两者均可能损害延迟召回和长文本生成质量。本文提出MAC-Attention,一种保留保真度与可访问性的替代方案,通过复用语义相近的近期查询的注意力计算结果来加速解码。该方案包含三个阶段:匹配阶段在短局部窗口内执行RoPE前的L2匹配;修正阶段通过重计算匹配边界附近的小范围注意力来校正复用结果;补全阶段通过数值稳定的合并操作,将修正结果与基于KV尾部新计算的注意力进行融合。当匹配命中时,计算量和带宽复杂度与上下文长度无关。该方法具有模型无关性,可与IO感知内核、分页KV管理器及MQA/GQA组合使用。在LongBench v2(120K)、RULER(120K)和LongGenBench(16K连续生成)基准测试中,与最新FlashInfer库相比,MAC-Attention最多减少99%的KV访问量,在128K上下文长度下词元生成延迟降低超过60%,注意力阶段加速比达14.3倍以上,端到端加速比达2.6倍,同时保持全注意力的计算质量。通过复用计算,MAC-Attention实现了兼具速度与保真度的长上下文推理。代码开源地址:https://github.com/YJHMITWEB/MAC-Attention.git

0
下载
关闭预览

相关内容

TransMLA:多头潜在注意力(MLA)即为所需
专知会员服务
23+阅读 · 2025年2月13日
赛尔笔记 | Attention!注意力机制可解释吗?
哈工大SCIR
23+阅读 · 2019年9月27日
用Attention玩转CV,一文总览自注意力语义分割进展
Attention!注意力机制模型最新综述(附下载)
数据派THU
36+阅读 · 2019年4月14日
深度学习中Attention Mechanism详细介绍:原理、分类及应用
深度学习与NLP
10+阅读 · 2019年2月18日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 3月2日
VIP会员
相关主题
最新内容
重新思考无人机时代的生存能力
专知会员服务
2+阅读 · 今天7:44
装甲突击旅:现代战争思考、战斗与组织
专知会员服务
2+阅读 · 今天7:28
在人工智能加速决策环境中拓展OODA循环
专知会员服务
3+阅读 · 今天7:18
军事欺骗:供作战战术指挥官使用的工具
专知会员服务
3+阅读 · 今天7:03
综述 | 世界动作模型:少做梦,多行动
专知会员服务
5+阅读 · 6月23日
美以伊冲突:无人机与人工智能的运用
专知会员服务
10+阅读 · 6月23日
《特种部队在透明战场中的生存力》最新报告
专知会员服务
5+阅读 · 6月23日
相关VIP内容
TransMLA:多头潜在注意力(MLA)即为所需
专知会员服务
23+阅读 · 2025年2月13日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员