HGA让大模型在单卡上轻松处理64K上下文,不改参数也不重训。
Hierarchical Global Attention (HGA)
- 分层路由:先用摘要选块,再精准选词,减少需加载的token数。
- 仅3%稀疏度下,注意力质量比全连接低0.02纳特以内。
- 无需重训练,直接部署于32GB显存单卡,支持超长上下文。
Hierarchical Global Attention (HGA) 是一种可直接替换预训练长上下文Transformer中密集因果注意力的方案。它保持原有检查点参数不变:$W_Q$、$W_K$、$W_V$ 和 $W_O$ 投影均未更改,不引入校准参数,也无需重新训练。在单张32GB显存的RTX 5090上,将Qwen3-30B-A3B-Instruct-2507-FP8模型应用HGA后,可直接运行64K token上下文,此时逐令牌存储键值对在该硬件上不可行。与以往稀疏注意力方法不同,HGA采用两级分层路由:首先利用紧凑的RoPE感知摘要检索相关段落,再对最相关的组进行路由,仅在最后执行精确的逐令牌注意力。该分层检索显著减少加载的令牌数量,同时保留对检索到令牌集的精确注意力,使基于主机内存或NVMe存储的完整历史键值对成为可行。完整的过往键值对存于主机内存或NVMe中,仅少量路由工作集被传入GPU内存进行注意力计算。因此,GPU内存消耗主要取决于模型权重和路由工作集,而非总上下文长度。在所有测试上下文长度(4K–64K token)下,路由注意力仅比密集注意力低约0.01–0.02纳特,而使用的稀疏度约为3%。这些结果表明,分层路由引入的近似误差极小,剩余的质量差距可能主要由长上下文位置编码引起,而非路由算法本身。
原文摘要 · Abstract (English)
Hierarchical Global Attention (HGA) is a drop-in replacement for dense causal attention in pretrained long-context transformers. HGA preserves the original checkpoint parameters: the pretrained $W_Q$, $W_K$, $W_V$, and $W_O$ projections remain unchanged, no calibration parameters are introduced, and no retraining is required. Applied to Qwen3-30B-A3B-Instruct-2507-FP8 on a single RTX~5090 (32GB), the patched model runs out of the box at a 64K-token context, where token-level K/V storage is not feasible on this hardware. Unlike previous sparse-attention methods, HGA performs hierarchical two-level routing. It first retrieves relevant chunks using compact RoPE-aware summaries and then refines the selection by routing only the most relevant groups before performing exact token-level attention. This hierarchical retrieval significantly reduces the number of fetched tokens while preserving exact attention over the retrieved token set, making RAM- and NVMe-backed storage practical. The full historical token K/V resides in host RAM or NVMe storage, while only a small routed working set is transferred to GPU memory during attention. Consequently, GPU memory consumption depends primarily on model weights and the routed working set rather than on the total context length. Across all tested context lengths (4K - 64K tokens), routed attention remains within approximately $0.01$--$0.02$ nats of dense attention while the sparsity used is just about 3%. These results suggest that the approximation introduced by hierarchical routing is small, and that the remaining quality gap is likely dominated by long-context positional encoding rather than by the routing algorithm itself.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。