Language models struggle to generalize beyond pretraining context lengths, limiting long-horizon reasoning and retrieval. Continued pretraining on long-context data can help but is expensive due to the quadratic scaling of Attention. We observe that most tokens do not require (Global) Attention over the entire sequence and can rely on local context. Based on this, we propose L2A (Learning To Attend), a layer that enables conditional (token-wise) long-range memory access by deciding when to invoke global attention. We evaluate L2A on Qwen 2.5 and Qwen 3 models, extending their effective context length from 32K to 128K tokens. L2A matches the performance of standard long-context training to within 3% while skipping Global Attention for $\sim$80% of tokens, outperforming prior baselines. We also design custom Triton kernels to efficiently implement this token-wise conditional Attention on GPUs, achieving up to $\sim$2x improvements in training throughput and time-to-first-token over FlashAttention. Moreover, L2A enables post-training pruning of highly sparse Global Attention layers, reducing KV cache memory by up to 50% with negligible performance loss.


翻译:暂无翻译

0
下载
关闭预览

相关内容

《语言模型的推理时间学习算法》162页博士论文
专知会员服务
13+阅读 · 2025年11月23日
EMNLP2024|从知识图谱中习得大语言模型的规划能力
专知会员服务
31+阅读 · 2024年11月27日
Llama-3-SynE:实现有效且高效的大语言模型持续预训练
专知会员服务
36+阅读 · 2024年7月30日
Stabilizing Transformers for Reinforcement Learning
专知会员服务
60+阅读 · 2019年10月17日
强化学习三篇论文 避免遗忘等
CreateAMind
20+阅读 · 2019年5月24日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
长文本表示学习概述
云栖社区
15+阅读 · 2019年5月9日
近期语音类前沿论文
深度学习每日摘要
14+阅读 · 2019年3月17日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
半监督多任务学习:Semisupervised Multitask Learning
我爱读PAMI
18+阅读 · 2018年4月29日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
VIP会员
相关VIP内容
相关资讯
强化学习三篇论文 避免遗忘等
CreateAMind
20+阅读 · 2019年5月24日
Transferring Knowledge across Learning Processes
CreateAMind
29+阅读 · 2019年5月18日
长文本表示学习概述
云栖社区
15+阅读 · 2019年5月9日
近期语音类前沿论文
深度学习每日摘要
14+阅读 · 2019年3月17日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
半监督多任务学习:Semisupervised Multitask Learning
我爱读PAMI
18+阅读 · 2018年4月29日
相关基金
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员