HyperAttention: Long-context Attention in Near-Linear Time

计算机科学 加速 背景(考古学) 推论 散列函数 时间复杂性 算法 基质(化学分析) 秩(图论) 矩阵完成 理论计算机科学 二次方程 并行计算 数学 人工智能 复合材料 几何学 古生物学 量子力学 组合数学 高斯分布 生物 物理 计算机安全 材料科学
作者
In‐Su Han,Rajesh Jayaram,Amin Karbasi,Vahab Mirrokni,David P. Woodruff,Amir Zandieh
出处
期刊:Cornell University - arXiv [Cornell University]
被引量:8
标识
DOI:10.48550/arxiv.2310.05869
摘要

We present an approximate attention mechanism named HyperAttention to address the computational challenges posed by the growing complexity of long contexts used in Large Language Models (LLMs). Recent work suggests that in the worst-case scenario, quadratic time is necessary unless the entries of the attention matrix are bounded or the matrix has low stable rank. We introduce two parameters which measure: (1) the max column norm in the normalized attention matrix, and (2) the ratio of row norms in the unnormalized attention matrix after detecting and removing large entries. We use these fine-grained parameters to capture the hardness of the problem. Despite previous lower bounds, we are able to achieve a linear time sampling algorithm even when the matrix has unbounded entries or a large stable rank, provided the above parameters are small. HyperAttention features a modular design that easily accommodates integration of other fast low-level implementations, particularly FlashAttention. Empirically, employing Locality Sensitive Hashing (LSH) to identify large entries, HyperAttention outperforms existing methods, giving significant speed improvements compared to state-of-the-art solutions like FlashAttention. We validate the empirical performance of HyperAttention on a variety of different long-context length datasets. For example, HyperAttention makes the inference time of ChatGLM2 50\% faster on 32k context length while perplexity increases from 5.6 to 6.3. On larger context length, e.g., 131k, with causal masking, HyperAttention offers 5-fold speedup on a single attention layer.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
滴滴叭叭完成签到,获得积分10
刚刚
刚刚
刚刚
ljh完成签到 ,获得积分10
1秒前
尼古拉斯铁柱完成签到 ,获得积分10
1秒前
1秒前
凡一发布了新的文献求助10
1秒前
2秒前
小鱿鱼关注了科研通微信公众号
2秒前
xing完成签到,获得积分10
2秒前
李青梅完成签到,获得积分20
3秒前
YQ完成签到,获得积分10
3秒前
chewy应助pps采纳,获得10
3秒前
多情的凝海完成签到,获得积分10
3秒前
4秒前
Eliauk完成签到,获得积分10
4秒前
kitsch完成签到 ,获得积分10
4秒前
Nealk发布了新的文献求助10
5秒前
5秒前
秋风应助何晓阳采纳,获得20
5秒前
lv完成签到,获得积分10
5秒前
liu发布了新的文献求助10
5秒前
5秒前
大模型应助Syy采纳,获得10
6秒前
匡文发布了新的文献求助10
6秒前
Jackey完成签到,获得积分10
6秒前
6秒前
6秒前
柠檬侠发布了新的文献求助10
6秒前
隐形的落雁完成签到,获得积分20
7秒前
Lizhe发布了新的文献求助10
7秒前
O基米德完成签到 ,获得积分10
7秒前
7秒前
在水一方应助shaozi采纳,获得10
7秒前
8秒前
Chris完成签到,获得积分10
8秒前
寸阴若岁完成签到,获得积分10
8秒前
1234发布了新的文献求助10
8秒前
科研通AI6.4应助mirror采纳,获得10
8秒前
星之卡比完成签到 ,获得积分10
9秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
HYDROLYSE ACIDE DE QUELQUES DIOXASPIROCYCLANES 1000
Navigating Normative Orders. Interdisciplinary Perspectives 800
1 Peter and Christ's Descent to the Dead in Its Early Christian Reception 700
Essentials of Carbohydrate Chemistry and Biochemistry, 4th Edition 600
Organizational Behavior 510
Management and the Arts 510
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7741364
求助须知:如何正确求助?哪些是违规求助? 9290009
关于积分的说明 20198127
捐赠科研通 7319659
什么是DOI,文献DOI怎么找? 3306689
关于科研通互助平台的介绍 2458933
邀请新用户注册赠送积分活动 2317041