arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2611.37952cs.AIcs.CL
收藏

面向稀疏注意力的原生位置重索引

Native Position Reindexing for Sparse Attention

Tencent HY Team(腾讯HY团队);The Chinese University of Hong Kong(香港中文大学);Hong Kong University of Science and Technology (Guangzhou)(香港科技大学(广州));Nvidia Inc.(英伟达公司);Hong Kong University of Science and Technology(香港科技大学)

Lei Zhu, Zexuan Qiu, Zhiwei Li, Zhongwei Wan, Tong Che, Huayang Li, Tian Liang, Hao Gu, Zhijiang Guo, Irwin King, Leo Liang

AI总结:

该研究提出原生位置重索引方法,将位置编码与稀疏注意力协同设计,开发RiRoPE,在长上下文任务上显著优于基线,提升了长上下文建模性能。

摘要:

稀疏注意力通常沿用为密集注意力设计的位置编码,尽管它会改变每个查询的上下文。虽然稀疏注意力限制了被关注键的数量,但这些编码在训练期间对未覆盖或未见的原始序列长距离保留效果不佳。我们认为位置距离应与稀疏注意力协同设计,让长程交互与短程交互共享位置表示。为实现这一协同设计,我们将位置重索引原生集成到稀疏注意力训练中:在训练和推理时,每个查询选中的标记按原始顺序接收连续位置,将相对距离限制在注意力预算内而非完整序列长度。与StreamingLLM中的推理时重索引不同,原生训练让模型能适应这些依赖查询的位置,而非仅容忍它们。将此规则应用于旋转位置编码(RoPE)得到ReIndexing RoPE(RiRoPE)。一个挑战是依赖查询的旋转会阻碍旋转键的复用,抵消稀疏注意力的效率提升;我们通过结构感知旋转复用和融合内核解决该问题,这些内核保留张量核心矩阵乘法,无需实现每对旋转键。在匹配的OLMo-3-7B持续预训练中,RiRoPE在64K时的RULER指标比使用带YaRN的RoPE的稀疏注意力基线高6.14点(74.10→80.24),HELMET指标高4.40点(42.97→47.37)。在512K(训练长度的8倍)时,它无需进一步训练或位置重调,保留了约90%的64K RULER分数。原生训练在256K时比仅推理切换的RULER指标高21.24点。我们的工作推动了位置编码与稀疏注意力的协同设计,将稀疏性重新定义为不仅是计算约束,更是更好的长上下文建模的机会。

英文摘要:

Sparse attention typically inherits positional encodings designed for dense attention, despite changing each query's context. Although sparse attention bounds the number of attended keys, these encodings retain large original-sequence distances poorly covered or unseen during training. We argue that positional distances should instead be co-designed with sparse attention, letting long-range interactions share positional representations with short-range ones. To realize this co-design, we make position reindexing native to sparse-attention training: each query's selected tokens receive consecutive positions in their original order during both training and inference, limiting relative distances to the attention budget rather than the full sequence length. Unlike inference-time reindexing in StreamingLLM, native training lets the model adapt to these query-dependent positions rather than merely tolerate them. Applying this rule to rotary position encoding (RoPE) yields ReIndexing RoPE (RiRoPE). A challenge is that query-dependent rotations hinder reuse of rotated keys, erasing the efficiency gains of sparse attention; we address it with structure-aware rotation reuse and fused kernels that preserve tensor-core matrix multiplication without materializing per-pair rotated keys. With matched OLMo-3-7B continued pretraining, RiRoPE outperforms a sparse-attention baseline using RoPE with YaRN at 64K by 6.14 RULER points ($74.10 \to 80.24$) and 4.40 HELMET points ($42.97 \to 47.37$). At 512K---eight times the training length---it retains about 90\% of its 64K RULER score without further training or positional retuning. Native training also outperforms inference-only switching by 21.24 RULER points at 256K. Our work motivates co-designing positional encodings with sparse attention, reframing sparsity not merely as a computational constraint but as an opportunity for better long-context modeling.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑