长上下文场景下块稀疏注意力的分布式计算方案
作者:
作者单位:

作者简介:

通讯作者:

中图分类号:

基金项目:

国家重点研发计划 (2024YFB4505701)


Distributed Computing Scheme with Block Sparse Attention in Long-context Scenarios
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    大语言模型的注意力机制在处理长序列时面临严峻的计算与显存挑战, 现有解决方案主要从算法优化和序列并行两个维度展开. 在算法层面, 块稀疏注意力机制通过在掩码矩阵中引入块稀疏性质降低计算复杂度, 其中Atrous稀疏和垂直-斜线稀疏是两种经典的稀疏模式; 在序列并行层面, 环形注意力通过高效扩展设备数量支持处理任意长度的序列. 然而, 当二者结合时, 环形注意力仍然采用密集注意力的序列切分方式, 导致大量无效的通信开销与计算开销, 难以实现预期加速效果. 本文针对Atrous和垂直-斜线两种经典的稀疏模式, 提出了定制化的序列切分方案以及高效简明的分布式计算方案: 对于Atrous稀疏模式, 采用分组计算策略, 将数据与设备均匀划分为相同数量的组, 在不同组内执行独立的环形注意力大幅提升计算效率; 对于垂直-斜线稀疏模式, 采用分解计算方案, 将其拆分为斜线稀疏和垂直稀疏两个子任务, 其中斜线稀疏部分实现无通信开销的本地计算, 垂直稀疏部分通过去除无关键值块的计算通信开销实现性能加速. 实验结果表明, 新的分布式优化方案在Atrous稀疏设置下实现了3–10.9倍的性能提升, 在垂直-斜线稀疏设置下实现了3–10.5倍的性能提升.

    Abstract:

    The attention mechanism in large language models faces severe computational and memory challenges when processing long sequences. Existing solutions are mainly developed from two perspectives: algorithmic optimization and sequence parallelism. At the algorithmic level, block sparse attention reduces computational complexity by introducing block sparsity into the mask matrix, among which Atrous sparsity and vertical-slash sparsity are two classical sparsity patterns. At the sequence-parallel level, ring attention enables efficient scaling across devices to support arbitrary long-context processing. However, when these two approaches are combined, ring attention still adopts a dense sequence partitioning strategy, which introduces substantial redundant communication and computation overhead and prevents the expected acceleration. To address this issue, customized sequence partitioning schemes and efficient distributed computing solutions are proposed for Atrous sparsity and vertical-slash sparsity. For Atrous sparsity, a grouped computing strategy is adopted, where data and devices are evenly divided into the same number of groups, and independent ring attention is executed within each group to significantly improve computational efficiency. For vertical-slash sparsity, a decomposition-based computing strategy is employed, in which the sparsity pattern is decomposed into slash sparsity and vertical sparsity subtasks. The slash sparsity subtask is processed through communication-free local computation, while the vertical sparsity subtask achieves performance acceleration by eliminating the computation and communication overhead of non-critical key-value blocks. Experimental results demonstrate that the proposed distributed optimization achieves 3–9 times performance improvement under Atrous sparsity and 3–10.9 times improvement under vertical-slash sparsity.

    参考文献
    相似文献
    引证文献
引用本文

詹红瑞,戴子健,白有辉,许胤龙,李诚.长上下文场景下块稀疏注意力的分布式计算方案.计算机系统应用,2026,35(7):111-119

复制
分享
相关视频

文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2025-11-20
  • 最后修改日期:2025-12-12
  • 录用日期:
  • 在线发布日期: 2026-05-22
  • 出版日期:
文章二维码
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京市海淀区中关村南四街4号,邮政编码:100190
电话:010-62661041 传真: Email:csa@iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号