2607.02980-hils-attention-infinite-context

Hierarchical Sparse Attention Done Right: Toward Infinite Context Modeling

HiLS-Attention 用 landmark token 将每个 chunk 压缩为加权 key 与熵偏置,再通过分层 softmax 让 chunk 选择分数接受语言模型损失监督;只用 8K 长度训练的 345M 模型在 4M RULER 单针检索上仍得 96 分,且在 512K 单 H800、batch size 1 和同一 Triton 基线下,prefill 与 decode 分别快 13.5 倍和 15.7 倍。结论限于作者的小模型、单流与长度外推设置,当前实现缺少 context parallelism,远程检索仍随序列与 chunk 数量乘积增长,生产级 serving 对照和多 seed 统计也未完成。

Authors Xiang Hu, Xinyu Wei, Hao Gu, Minshen Zhang, Tian Liang, Huayang Li, Lei Zhu (祝磊), Yan Wang (王琰), Sirui Han (韓斯睿), Yushi Bai (白雨石), Kewei Tu (屠可伟), Haitao Mi, Leo Liang

已审阅 Archived 2026-07-09 09:57 Updated 2026-07-21 14:18 Reviewed 2026-07-21 14:18 Source

Source

  • Workflow version: v2.1
  • Material type: research-paper
  • Analysis modules: experiment, system, theory, docs
  • Canonical source: https://arxiv.org/abs/2607.02980
  • Title: Hierarchical Sparse Attention Done Right: Toward Infinite Context Modeling
  • arXiv: 2607.02980
  • arXiv HTML: 2607.02980v1
  • PDF: 2607.02980 PDF
  • TeX Source: 2607.02980 source
  • Code/Project: Tencent-Hunyuan/HiLS-Attention
  • OpenReview / Review page: 未发现可可靠匹配当前 2607.02980 的公开审稿页。
  • Authors: Xiang Hu, Xinyu Wei, Hao Gu, Minshen Zhang, Tian Liang, Huayang Li, Lei Zhu, Yan Wang, Sirui Han, Yushi Bai, Kewei Tu, Haitao Mi, Leo Liang
  • Responsible organization: Tencent HY Team / ShanghaiTech University / The Hong Kong University of Science and Technology / University of California, San Diego
  • Submitted: 2026-07-03
  • Published / updated: 2026-07-03
  • Current version read: v1, submitted 2026-07-03
  • Version / revision read: arXiv v1;以官方 HTML、PDF 与 TeX source 为主,官方代码仓库作为实现补充。
  • Accessed: 2026-07-21
  • Key figure decision: include
  • Key figure rationale: Figure 3 对比精确 chunk mass、压缩 chunk key 和分层 softmax,直接展示 HiLS 如何在避免 full QK 的同时让选择分数进入最终 attention weight。
  • Review status: page-type=not-found; match-confidence=high; observed-at=2026-07-21; venue-status=arXiv preprint
  • Subjects: Computation and Language (cs.CL); Artificial Intelligence (cs.AI)
  • Comments: preprint

作者与关系

  • Xiang Hu:Tencent HY Team;历史机构:Tencent AI Lab;Ant Research。
  • Xinyu Wei:ShanghaiTech University。
  • Hao Gu:The Hong Kong University of Science and Technology。
  • Minshen Zhang:University of California, San Diego;历史机构:ShanghaiTech University;Alibaba Ant Group。
  • Tian Liang:Tencent HY Team;历史机构:Tencent AI Lab;Tsinghua Shenzhen International Graduate School;Wuhan University。
  • Huayang Li:Tencent HY Team;历史机构:Tencent AI Lab;Nara Institute of Science and Technology。
  • Lei Zhu:Tencent HY Team;历史机构:Tencent Hunyuan Frontier Lab;Tencent AI Lab;Huawei Noah's Ark Lab;City University of Hong Kong。
  • Yan Wang:Tencent HY Team;历史机构:Tencent AI Lab;miHoYo。
  • Sirui Han:The Hong Kong University of Science and Technology。
  • Yushi Bai:Tencent HY Team;历史机构:Tsinghua University;Z.ai
  • Kewei Tu:ShanghaiTech University。
  • Haitao Mi:Tencent HY Team;历史机构:Tencent AI Lab;Tencent America。
  • Leo Liang:Tencent HY Team。

关系摘要:

  • 论文形成 Tencent HY Team 主线,连接上海科技大学、HKUST 和 UCSD。Xiang Hu / Xinyu Wei / Hao Gu / Minshen Zhang 在标题页带 core-contributor 标记。
  • Xiang Hu 与 Kewei Tu 已在 HSA / length generalization / FlashMHF 线索中合作;Minshen Zhang 的主页记录了 Ant Group 期间把 Hierarchical Sparse Attention 集成到 SGLang 的工程经历。
  • Tian Liang、Yan Wang、Xiang Hu、Haitao Mi 和本地已归档 FlashMemory-DeepSeek-V4 重叠,说明 Tencent long-context 线同时推进模型内 sparse attention 和 serving 侧 KV residency。
  • Yushi Bai 连接 IndexCache / GLM-5.2 线索,使本论文与 GLM-5.2 的 IndexShare 形成作者和主题关系。

阅读目标与判断边界

本笔记关注:

  1. HiLS 如何从 naive Block Sparse Attention 的 chunk mass 推导出可训练的 chunk summary。
  2. 它相对 Native Sparse Attention、DashAttention、InfLLM v2、HSA-UltraLong、MiniMax Sparse Attention、DeepSeek Sparse Attention 的关键差异。
  3. 345M / 1.4B / 7B 实验是否足以支撑“native sparse attention 可替代 full attention”的判断。
  4. 它和本地已归档 long-context training / serving / sparse attention 论文的关系。

判断边界:

  • 当前论文是 arXiv preprint,未找到公开审稿;结论主要来自作者实验和开源代码。
  • 7B 实验是从 OLMo3-1025-7B base checkpoint 继续训练,不能直接代表 closed frontier model 的完整训练路线。
  • 推理效率实验为 345M、single H800、batch size 1、同一 Triton kernel infrastructure 下的 apples-to-apples 对照;它说明算法成本曲线,不等价于多租户 serving 吞吐结论。
  • 论文没有支持 context parallelism,真正 1M 以上训练仍待系统验证。

论文脉络

1. 研究问题、背景和价值

长上下文大语言模型 (Large Language Model, LLM) 的瓶颈同时来自三类成本:

  • full attention 在序列长度 LL 上有 O(L2)O(L^2) token-pair 计算。
  • decode 阶段需要随上下文长度增长读取 Key-Value cache (KV cache,注意力历史键值缓存)。
  • dense attention 的位置编码和注意力分布在训练长度外常出现 length extrapolation 退化。

chunk-wise sparse attention 的基本思路是:保留本地 Sliding-Window Attention (SWA,滑动窗口注意力),同时从远程历史中选择少量 chunk。若每步只激活固定数量 token,prefill 和 decode 成本可以接近常数预算。但这一路线的核心难点是 chunk selection:选错 chunk 时,模型会丢失远程证据;选择器若依赖 full QK 计算,又会保留二次成本。

HiLS 的研究问题可以写成一句话:如何让 chunk selector 同时具备高表达能力、native sparse training 能力、LM loss 端到端监督能力,以及训练长度外的稳定泛化能力。

2. 已有解决方案与不足

已有路线大致分为三类:

  1. 精确 full attention 与系统并行:Ring Attention、DeepSpeed Ulysses 和 FlashAttention 改善显存、通信和 kernel 常数,但核心 token-pair 可见性仍接近 dense。
  2. 非参数 chunk summary:Native Sparse Attention (NSA)、MoBA、DashAttention / InfLLM v2 等用 mean-pooled key 或轻量门控估计 chunk relevance。它们便于 sparse training,但 mean pooling 只能表达近似均匀 logit 分布,对 needle-like token 和多跳变量追踪不稳定。
  3. 参数化 summary 或 distillation:Landmark Attention 使用 landmark token,但训练仍需要 dense attention;SeerAttention 和 DeepSeek Sparse Attention 可从 full attention / dense indexer 蒸馏选择信号,但 full QK 或 teacher 路径保留高成本。HSA 系列支持 sparse training 和强外推,但以 cross-attention module / NoPE-SWA hybrid 形式引入较多额外结构。

论文指出:现有 chunk selector 常把 chunk score 只用于 hard top-KK 选择,选择后 score 被丢弃,下一 token prediction 的语言建模损失无法直接更新 selector 的分数质量。

3. 作者可能的思考路径

一个自然起点是 naive Block Sparse Attention (BSA,块稀疏注意力)。对 query ii,若能先计算 full attention logits,再把每个 chunk 的 attention mass 相加,就能得到精确 chunk ranking:

Zi,c=jTcexp(si,j),si,j=qikjd. Z_{i,c}=\sum_{j\in\mathcal{T}_c}\exp(s_{i,j}), \quad s_{i,j}=\frac{\mathbf q_i^\top \mathbf k_j}{\sqrt d}.

naive BSA 的问题在于它要先完成全量 QK 才知道哪些 chunk 重要,节省不了训练计算。作者于是追问:能否只用一个 chunk summary key kc\mathbf k'_c 近似 logZi,c\log Z_{i,c}

这个问题的关键是 LogSumExp。若 chunk 内 logits 近似均匀,logZi,c\log Z_{i,c} 近似 mean logit 加 logS\log S;若单个 token 主导,它近似 max logit。mean pooling 只覆盖前一种形态,max pooling 只覆盖后一种形态。一个更通用的 summary 需要同时表达“相关 token 的加权语义”和“chunk 内注意力分布的熵”。

这就导向了论文的核心 idea:用 landmark token 产生每个 chunk 自己的 learnable query qc\mathbf q'_c,在 chunk 内做一次小 attention,得到加权 key summary kc\mathbf k'_c 和 entropy bias bcb'_c;然后把 chunk score 放进最终 attention weight,让 LM loss 直接监督它。

4. 核心假设或切入点

HiLS 的核心假设有三层:

  1. chunk mass 的 LogSumExp 可以用 chunk 内 landmark-induced attention 的一阶近似表达。
  2. chunk retrieval score 需要参与 forward attention mass,而只参与 hard routing 会让 selector 缺少 LM loss 监督。
  3. 压缩后的 chunk representation 可以减少长上下文中的 token-level noise accumulation,因此在部分 retrieval / variable tracking 任务上可能超过 full attention。

5. 方法 / 系统 / 理论框架

术语预备:

  • BSA (Block Sparse Attention,块稀疏注意力):按 chunk 选择远程 token,再叠加本地窗口。
  • LM loss (Language Modeling loss,语言建模损失):next-token prediction 的训练目标。
  • NIAH (Needle-in-a-Haystack,针在 haystack 中检索):在长上下文中插入少量目标事实并要求末尾问答。
  • HoPE (High-frequency rotary Position Embedding,保留训练范围内高频 RoPE、其余维度使用 NoPE 的位置编码)。
  • Q-Cal (Query Calibration,query 校准):低秩模块,用于把 token-level query 调整成 chunk-level mass 估计 query。
  • GQA (Grouped-Query Attention,分组查询注意力):多个 query heads 共享同一个 KV head。

5.1 LogSumExp 一阶近似

论文先对 chunk 内 LogSumExp 在 qc\mathbf q'_c 处做一阶 Taylor expansion:

logjTcexp(qkjd)qkcd+bc. \log \sum_{j \in \mathcal{T}_c} \exp\left(\frac{\mathbf q^\top \mathbf k_j}{\sqrt d}\right) \approx \frac{\mathbf q^\top \mathbf k'_c}{\sqrt d} + b'_c.

其中:

sj=(qc)kjd,pj=exp(sj)kTcexp(sk), s_j=\frac{(\mathbf q'_c)^\top \mathbf k_j}{\sqrt d}, \quad p_j=\frac{\exp(s_j)}{\sum_{k\in\mathcal{T}_c}\exp(s_k)},
kc=jTcpjkj,bc=jTcpjlogpj. \mathbf k'_c=\sum_{j\in\mathcal{T}_c}p_j\mathbf k_j,\quad b'_c=-\sum_{j\in\mathcal{T}_c}p_j\log p_j.

这里 kc\mathbf k'_c 是 chunk 内 key 的加权平均,bcb'_c 是 entropy bias。均匀分布时 bcb'_c 接近 logS\log S;单点主导时接近 00。这补齐了 mean / max summary 难以统一处理的两种 logit 分布。

5.2 Landmark token 产生 chunk summary

HiLS 在每个 chunk 后追加 landmark token,用 landmark token 的 query 作为 qc\mathbf q'_c。每个 chunk 用一次 intra-chunk attention 产生 kc,bc\mathbf k'_c,b'_c,再对 query ii 计算 chunk score:

s^i,c=qikcd+bc. \hat{s}_{i,c}=\frac{\mathbf q_i^\top \mathbf k'_c}{\sqrt d}+b'_c.

选择 top-KK chunk:

Ii={cCirank(s^i,c)<K}. \mathcal I_i=\{c\in\mathcal C_i\mid \operatorname{rank}_{\downarrow}(\hat{s}_{i,c})<K\}.

在论文主要配置中,chunk size S=64S=64,top-K=32K=32,远程 budget 为 32×64=204832\times64=2048 tokens;本地 SWA window 为 512512 tokens。

Figure 3: HiLS-Attention 的压缩 chunk 检索与分层注意力
Figure 3: HiLS-Attention 概览。Naive BSA 用精确 chunk mass 选择 top-KK,但需要 full QK;HiLS 用 compressed chunk keys 估计 chunk-mass surrogate,并把 attention 分解为 inter-chunk softmax 与 intra-chunk softmax。Image Source: arXiv TeX source data/HiLS-Attn.png via 2607.02980 source.

5.3 Hierarchical softmax 让 selector 被 LM loss 训练

对被选 chunk 内 token jj,HiLS 将 attention weight 分成两部分:

wi,jexp(si,j)Zi,c(j)intra-chunk×Z^i,c(j)Z^iinter-chunk surrogate, w_{i,j} \approx \underbrace{\frac{\exp(s_{i,j})}{Z_{i,c(j)}}}_{\text{intra-chunk}} \times \underbrace{\frac{\hat Z_{i,c(j)}}{\hat{\mathcal Z}_i}}_{\text{inter-chunk surrogate}},

其中 Z^i,c=exp(s^i,c)\hat Z_{i,c}=\exp(\hat s_{i,c})Z^i\hat{\mathcal Z}_i 合并 selected chunks 的 surrogate mass 与本地 SWA mass。这样,chunk score 会影响最终 token weight,梯度能从 LM loss 回传到 landmark representation 和 Q-Cal 参数。

5.4 Q-Cal、HoPE、GQA 与 kernel

Q-Cal 用低秩增量把 token-level query 调成 chunk-score query:

Δqi=WupWdownhi,q^i=qi+Δqi. \Delta\mathbf q_i=\mathbf W^{\mathrm{up}}\mathbf W^{\mathrm{down}}\mathbf h_i,\quad \hat{\mathbf q}_i=\mathbf q_i+\Delta\mathbf q_i.

HoPE 的作用是降低 RoPE 在训练长度外对 chunk compression 的扰动。作者认为,RoPE 全维旋转会让 chunk 内不同位置的 key 被聚合时混入位置旋转噪声;HoPE 保留训练范围内的 RoPE 维度,其余维度转为 NoPE,提供更稳定的语义子空间。

GQA 下,一个 KV head 对应多个 query heads。HiLS 先按 query head 计算 chunk score,再在 group 内取 max 聚合,保证只要任一 head 需要某 chunk,该 chunk 就会被选中。

kernel 侧,NSA 常按单个 query token 加载 selected chunks,Tensor Core GEMM 形状依赖 GQA group size GG。HiLS 把相邻 MM 个 query tokens 和 query heads 一起打包,对它们 selected chunk 的 union 做 one-load-multiple-compute,使 Tensor Core 维度变成 M×GM\times G。在作者的 chunk-overlap 实验中,64K 上下文时最后 M=16M=16 个 query 的 visible historical chunks 为 10321032,实际加载 union 约 102.1102.1 个 chunk,占比 9.9%9.9\%;平均 92.8%92.8\% chunk 在前一个 block 已出现,支持复用假设。

6. 结论链条

论文的证据链是:

  1. 理论上,用 landmark-induced kc\mathbf k'_c 与 entropy bias bcb'_c 近似 full-attention chunk mass 的一阶形式。
  2. 机制上,把 Z^i,c\hat Z_{i,c} 放进 forward attention weight,使 chunk selector 接受 LM loss 监督。
  3. 实验上,小模型显示 HiLS 在 in-domain retrieval 与长外推上明显超过 mean-pooled sparse attention;1.4B 从头训练显示 sparse training 不损伤短上下文平均能力;7B OLMo3 迁移显示少量 CPT 能把 full-attention checkpoint 转为 HiLS。
  4. 系统上,H800 single-stream latency 显示长上下文 prefill / decode 成本曲线从 full attention 的二次 / 线性增长,转向固定远程 budget 加本地窗口。

关键实验/定理

定理结果:Proposition 3.1 给出 chunk LogSumExp 的局部一阶线性化

  • 设置:把一个 chunk 内精确 attention mass 的对数视为 query 的函数,并在 landmark query 处做一阶 Taylor 展开。
  • 结果:展开式可写为当前 query 与 landmark 加权 key 的内积,再加上 landmark attention 分布的熵偏置;均匀分布时偏置接近 chunk 大小的对数,单 token 主导时偏置接近零。
  • 证据定位:Section 3, Proposition 3.1、Equations 5–6,证明见 Appendix B。
  • 对照是否可比:这是局部解析等式的一阶近似推导,不涉及经验 baseline;近似中心由 landmark query 决定,论文没有给出远离展开点时的全局误差界或 chunk 排序保持保证。
  • 支持的最窄结论:Proposition 3.1 说明加权 key 与熵偏置构成 chunk LogSumExp 在 landmark query 附近的一阶表示,为 selector 形式提供推导依据;它不能单独保证任意 query、长度或分布下的检索准确率。

结果 1:345M 8K scratch training 中,HiLS 在 PPL 和 RULER 外推上同时强于多数 sparse baselines

  • 设置:345M decoder-only Transformer,GPT-2 Medium 类配置,8K context 从头训练 30K steps,约 30B tokens;训练数据基于 OLMo/Dolma pretraining corpora,混入 5% RULER-style synthetic examples。
  • Baseline:Full-Attn RoPE / HoPE、SWA-RoPE、NSA-RoPE、DashAttention-RoPE、HSA-UltraLong、Naive-BSA-HoPE、InfLLM v2 参考结果。所有 sparse baselines 统一 512 SWA window、chunk size 64、top-K=32K=32
  • 指标:perplexity (PPL);RULER 的 Single Needle (S-N)、Multi-Key Multi-Query (MK-MQ)、Variable Tracking (VT)。
  • 结果:
Model 8K PPL 32K PPL 128K PPL 512K PPL RULER 8K S-N/MK-MQ/VT RULER 512K S-N/MK-MQ/VT
Full-Attn RoPE 4.96 >102>10^2 - - 100 / 97 / 34 0 / 0 / 0
Full-Attn HoPE 4.95 6.42 >102>10^2 - 100 / 98 / 36 0 / 0 / 0
NSA-RoPE 5.01 7.62 11.75 19.14 49 / 17 / 16 0 / 0 / 0
HSA-UltraLong 8.81 5.84 4.99 4.54 87 / 79 / 23 65 / 42 / 8
Naive-BSA-HoPE 4.94 3.94 8.67 OOM 100 / 97 / 23 -
HiLS-Attn-HoPE 4.94 4.34 4.71 5.95 100 / 95 / 72 99 / 91 / 66

超长外推中,8K 训练的 HiLS 在 1M / 2M / 4M RULER 上分别达到 S-N/MK-MQ/VT = 100/97/5397/87/5096/89/43

  • 证据定位:Section 5.1, 345M PPL 与 RULER 主结果表Figure 1 的超长外推结果。
  • 对照是否可比:多数 345M sparse baseline 共用训练 token、8K context、512-token 本地窗口、64-token chunk 和 top-32 远程 chunk;HSA-UltraLong 多 12.7% 参数,InfLLM v2 的 head dimension 不匹配,位置编码与 selector 结构也不同。
  • 支持的最窄结论:在作者的 345M、含 5% RULER-style 合成数据与 8K 训练设置中,HiLS 的 8K PPL 接近 full attention,并在最高 4M 的三项 RULER 外推上保留非零且显著更高的成绩;该结果不能证明自然长文档任务或更大模型上的同等外推。
  • 解读:HiLS 的短上下文 PPL 接近 full attention,同时在 RULER VT 上大幅高于 full attention 和 mean-pooled sparse methods。Naive BSA 说明 full-attention-derived chunk mass 在训练长度附近可用,但外推不稳;HiLS 的端到端 hierarchical softmax 给 selector 直接训练信号,外推更稳定。

结果 2:256K context 继续训练后,HiLS 在 1M 长度仍保留 retrieval 能力

  • 设置:从 8K 345M checkpoints 出发,用 256K context 继续训练 10B tokens;RoPE base 分别设置为 10710^710410^4
  • Baseline:Full-Attn RoPE、Full-Attn HoPE,与 HiLS-Attn-HoPE 同训练设置。
  • 指标:PPL 与 RULER。
  • 结果:RoPE base 10710^7 下,HiLS 在 1M PPL 为 8.08,Full-Attn RoPE 为 8.61。RULER 1M 上,Full-Attn RoPE 为 2/0/0,HiLS 为 96/5/46。RoPE base 10410^4 下,HiLS 在 1M RULER 为 96/64/22,Full-Attn HoPE 已为 0/0/0
  • 证据定位:Section 5.2, 256K continued-training PPL 与 RULER 表
  • 对照是否可比:345M checkpoints 使用相同 256K context 和 10B-token continued-training budget;不同位置编码与 RoPE base 会改变外推条件,表内没有多 seed 方差。
  • 支持的最窄结论:在两组指定 RoPE base 下,HiLS 经过 256K continued training 后于 1M 保留更强单针与变量追踪成绩;Multi-Key Multi-Query 对 RoPE base 敏感,结论不支持位置设置无关的稳定外推。
  • 解读:HiLS 的外推收益在更长训练长度下更明显。MK-MQ 在 RoPE base 10710^7 下仍弱,说明位置编码和 retrieval pattern 迁移仍敏感。

结果 3:1.4B 从头训练 300B tokens 后,HiLS 的短任务平均分略高,RULER 外推稳定

  • 设置:1.4B 模型,300B-token training,8K context,final checkpoint 143K steps;Full-Attn RoPE 与 HiLS-Attn HoPE 对比。
  • Baseline:Full-Attn RoPE。
  • 指标:LAMBADA、HellaSwag、PIQA、WinoGrande、OpenBookQA、ARC、RULER、PPL。
  • 结果:下游短任务平均分 HiLS 为 49.06,Full-Attn 为 48.65。附录 per-step RULER 最终 512K 上,Full-Attn 为 0/0/0,HiLS 为 92/99/60
  • 证据定位:Section 6.1, 1.4B downstream 结果 与 Appendix H 的 per-step PPL / RULER 表。
  • 对照是否可比:HiLS 与 full attention 使用相同模型规模、8K context、300B tokens 和下游评测;单次训练、5% 合成 RULER 数据和短任务输入长度限制了统计与任务外推。
  • 支持的最窄结论:在这一对 1.4B 单次训练中,HiLS 的短任务平均分与 full attention 接近,并在 512K 合成 RULER 上保留明显更高成绩;0.41 分的短任务均值差缺少显著性证据。
  • 解读:在 1.4B 规模上,native sparse training 没有明显牺牲短上下文能力,并保留长外推优势。由于多数短任务平均输入很短,这组结果主要说明“不损短能力”,长上下文判断仍以 RULER 为主。

结果 4:7B OLMo3 CPT 中,50B tokens 可把 full-attention checkpoint 转为 HiLS

  • 设置:从 OLMo3-1025-7B base 开始,原模型为 MHA,每 4 层中 3 层 4K SWA + 1 层 full attention;作者把 full-attention layers 替换为 HiLS,并把 SWA window 从 4K 降到 512。full-parameter CPT 使用 50B tokens、8K sequences、global batch size 512、13K steps;另有 landmark-token tuning 只训新增参数 5B tokens。
  • Baseline:Olmo3-Base、LMK token tuning、Olmo3-512swa-CPT、HiLS-Attn RoPE / HoPE / NoPE。
  • 指标:RULER、general downstream tasks、PPL、LongBench-v1。
  • 结果:
Method RULER avg General avg 8K PPL 256K PPL LongBench overall
Olmo3-Base 3.75 43.88 3.997 14.554 29.0
LMK token tuning 6.50 43.18 3.470 7.770 28.8
Olmo3-512swa-CPT 33.50 43.24 3.234 12.760 28.0
Olmo3-512swa-CPT + YaRN 32K - - - - 31.7
HiLS-Attn-HoPE-Q-Cal 97.42 43.35 3.236 3.095 33.2
HiLS-Attn-RoPE-Q-Cal 38.67 41.68 3.242 6.546 30.0
HiLS-Attn-NoPE-Q-Cal 43.33 41.62 3.248 73.896 33.2
  • 证据定位:Section 6.2, OLMo3 CPT 结果,包括 RULER、general tasks、PPL 与 LongBench-v1 表。
  • 对照是否可比:各 CPT 变体从同一 OLMo3-1025-7B base 出发并使用相同 50B-token budget;Olmo3-Base 未接受这段训练,LMK token tuning 只训练新增参数 5B tokens,YaRN 对照的训练与推理 recipe 不完全一致。
  • 支持的最窄结论:在作者的 7B OLMo3 迁移设置中,HiLS-HoPE-Q-Cal 同时取得最高 RULER 平均分、接近 512SWA-CPT 的短任务均值、更低长长度 PPL 和更高 LongBench overall;该结果不能等同于从头训练的 7B 稀疏模型或 frontier-scale 迁移。
  • 解读:HoPE-Q-Cal 是最均衡配置:短任务平均与 512swa-CPT 接近,LongBench 明显更好,PPL 在长长度上大幅低于 baseline。NoPE 的 LongBench 也高,但 PPL 在 64K 以上崩坏,说明它的生成式语言建模稳定性不足。

结果 5:H800 SGLang latency 显示 16K 后 HiLS 成本曲线优于 full attention

  • 设置:345M architecture,SGLang inference engine,单张 NVIDIA H800,batch size 1,bf16;chunk size 64、top-k=32k=32、512-token SWA;full-attention baseline 使用同一 Triton attention-kernel infrastructure,未使用 vendor-optimized paged-attention implementation。
  • Baseline:Full attention。
  • 指标:warm-run prefill latency;CUDA graphs 下 median per-token decode latency。
  • 结果:约 16K 处 prefill 达到 parity;512K context 上,HiLS prefill 为 5.0s,full attention 为 67.0s,速度比 13.5x;decode 为 5.5ms/token 对 85.9ms/token,速度比 15.7x。
  • 证据定位:Section 7.1, Figure 6
  • 对照是否可比:两者使用相同 345M architecture、H800、bf16、batch size 1 与 Triton infrastructure,能比较作者 kernel 路径的成本曲线;full attention 未采用 vendor-optimized paged attention,且没有多请求 batching、KV offload 或跨卡设置。
  • 支持的最窄结论:在这一单流同基础设施基准中,HiLS 从约 16K 开始取得 prefill 延迟优势,并在 512K 达到 13.5 倍 prefill 和 15.7 倍 decode 加速;结果不能外推为生产吞吐或尾延迟收益。
  • 解读:这组实验支撑算法成本曲线判断。局限是 batch size 1、345M、小模型、同一 Triton baseline,未覆盖 paged attention、multi-request batching、KV offload 或生产 tail latency。

结果 6:ablation 显示 Q-Cal、landmark token 和 HoPE 都关键

  • 设置:345M 8K training ablations。
  • Baseline:HiLS-Attn-HoPE with Q-Cal r=64r=64
  • 指标:PPL 和 RULER。
  • 结果:去掉 Q-Cal 后,512K PPL 从 5.95 变成 16.93,512K RULER 从 99/91/66 变成 39/1/0。LMK-Attn 形式 512K PPL 为 14.10,RULER 为 3/1/0。mean pooling 512K PPL 为 8.00,RULER 为 24/2/1。HoPE 明显优于 RoPE 和 NoPE 的组合。
  • 证据定位:Section 5.3, 345M ablation PPL 与 RULER 表
  • 对照是否可比:消融共享 345M、8K training、chunk budget 与主训练 recipe,并分别替换 Q-Cal、landmark summary、pooling 和位置编码;组合组件之间存在交互,单项结果不能直接相加为独立贡献。
  • 支持的最窄结论:在作者的 345M 配置中,移除 Q-Cal、改用简单 landmark attention 或 mean pooling 都显著降低 512K PPL / RULER,HoPE 组合表现最佳;消融确认组件在该 recipe 中必要,尚未解释 Q-Cal 的作用机制。
  • 解读:LM loss 端到端监督本身仍需要足够表达力和位置编码配合。Q-Cal 的机制仍缺少理论解释;论文只给经验结果。

实验设置与 baseline 审计

维度 记录
模型与初始化 345M / 1.4B 从头训练;7B 从 OLMo3-1025-7B base CPT。345M 使用 GPT-2 Medium-like decoder;7B 使用 OLMo3 MHA + 3:1 SWA/full-attn pattern 改造。
数据与任务 OLMo/Dolma pretraining corpora;345M 和 7B 训练流混入 5% RULER-style synthetic examples;256K CPT 使用 allenai/dolma3_longmino_mix-50B-1025;LongBench-v1、RULER、OpenCompass-style short tasks。
RL / 训练配置 未涉及 RL。
系统配置 latency: SGLang inference engine,单 H800,bf16,batch size 1,Triton kernels,CUDA graphs decode。训练硬件未完整披露。
框架基座 / paper base 训练 / evaluation 代码开源于 Tencent-Hunyuan/HiLS-Attention;7B base 为 OLMo3-1025-7B;inference benchmark 使用 SGLang;OpenCompass 用于短任务评测;RULER / LongBench 用于长上下文评测。
框架版本与证据来源 GitHub README 披露 PyTorch 2.8.0 + CUDA 12.8 wheel;SGLang 版本未披露;OpenCompass 版本未披露;OLMo3 checkpoint 来源披露为 allenai_olmo3_1025_7b_checkpoint
框架改动范围 新增 HiLS attention modules、landmark token、Q-Cal、PPL/RULER/LongBench evaluation scripts、DCP/HF conversion scripts。论文描述了 sparse attention kernel design;完整 kernel 性能复现仍依赖仓库实现。
技术报告训练配置 345M: 30K steps / 30B tokens / 8K / batch 128 / AdamW / lr 3×1043\times10^{-4} constant。7B CPT: 50B tokens / 8K / batch 512 / 13K steps / warmup 1K to 2×1042\times10^{-4} then cosine to 2×1052\times10^{-5}
训练硬件与拓扑 未披露。
并行方式与框架 未披露训练并行度;论文说明当前 HiLS 不支持 context parallelism。
训练数据规模与组成 345M 约 30B tokens;1.4B 300B tokens;7B CPT 50B tokens;RULER synthetic examples 5%。
训练过程与超参 chunk size 64、top-K=32K=32、SWA window 512;LoRA-Q bottleneck 345M/1.4B/7B 分别为 64/128/256。
训练时间 / GPU hours / 成本 未披露。
未披露项 训练硬件、训练并行度、seed 数、误差线、full code release 对齐到论文结果的 commit、SGLang 版本、多请求 serving 设置。
评测协议 PPL computed on last 512 tokens;RULER 包含 S-N、MK-MQ、VT;LongBench-v1 max length 65,536 with middle truncation;OpenCompass 短任务使用不同 few-shot 设置。
统计报告 未报告多 seed、置信区间或显著性检验;chunk overlap 给 error bars / standard deviation across HiLS layers and heads。
Baseline 是否 tuned sparse baselines 统一 chunk/topK/window,位置编码和 extra MLP 有部分公平性控制;各 baseline 的最佳调参深度不完全清楚。
Baseline 是否 compute-matched sparse baselines 在同 attention budget 下比较;full attention 和 sparse attention 训练 token / steps matched。HSA-UltraLong 有 12.7% extra params,不完全 parameter-matched。
Baseline 是否 implementation-matched 345M 实验尽量同训练 recipe;InfLLM v2 head dimension 不匹配,仅作为参考;latency baseline 同 Triton infrastructure。
Baseline 是否覆盖强替代方案 覆盖 NSA、DashAttention、InfLLM v2、HSA-UltraLong、SWA、Naive BSA、YaRN;未系统比较通用 sparse-attention serving、RetrievalAttention/RazorAttention/StreamingLLM/H2O、DeepSeek DSA 生产路线、MiniMax MSA 公开模型。
Baseline 是否存在弱化风险 7B OLMo3 baseline 使用 512SWA-CPT 和 YaRN,但 full-attention long-context CPT 的更强 recipe 不一定充分;latency full attention 未用 vendor-optimized paged attention。
结论边界 论文有力支持 HiLS 在作者设定下的 native sparse training 与 length extrapolation;对生产多租户 serving、1M+ 训练和 frontier-scale 模型仍需外部复验。
  • 系统条件:延迟测试使用 345M architecture、单 H800、bf16、batch size 1、SGLang 路径、Triton kernels 与 CUDA graphs decode,chunk size 64、top-32、SWA window 512;训练硬件、并行拓扑和 SGLang 版本未披露。
  • 指标定义:prefill latency 是完整输入的 warm-run 时间,decode latency 是 CUDA graphs 下的单 token 中位数;PPL 只在序列最后 512 tokens 上计算,RULER 分别报告单针、多键多问和变量追踪分数。
  • 成本归因:长长度加速来自固定远程 token budget、本地窗口和相邻 query 的 selected-chunk union kernel 复用;单 H800 与同 Triton 基线控制了部分实现差异,full attention 未使用 vendor-optimized paged attention,生产吞吐仍受 batching、KV 管理和并行系统影响。
  • 假设:Proposition 3.1 依赖 chunk LogSumExp 在 landmark query 处的一阶可微展开,并假定 landmark attention 的加权 key 与熵能概括对后续 query 有用的 chunk mass;top-k 之外的 chunk 不进入 token attention,也不接收该步梯度。
  • 适用域:理论式只描述展开点附近的局部近似,论文未证明全局误差界或 chunk 排序保持;实验覆盖作者的 345M、1.4B 与 OLMo3-7B 配置、最高 256K continued training 和最高 4M 合成外推,尚未覆盖 1M 训练、frontier-scale 模型或任意自然长文档分布。
  • 适用版本:论文结论对应 arXiv v1(2026-07-03);实现字段核对 Tencent-Hunyuan/HiLS-Attention 在 2026-07-21 的公开状态,README 提及 PyTorch 2.8.0 与 CUDA 12.8 wheel,论文没有固定结果 commit。

证据链强度评估

强证据

  • 机制推导清楚:从 chunk mass 的 LogSumExp 到 landmark-induced weighted key 和 entropy bias,再到 hierarchical softmax。
  • 345M 小模型用多种 sparse baseline 和 RULER 暴露 chunk selection 质量差异,适合观察 selector 本身。
  • 7B OLMo3 CPT 证明 full-attention checkpoint 可迁移到 HiLS,且 LongBench / PPL / RULER 多指标方向一致。
  • GitHub 仓库公开训练、CPT、PPL、RULER、LongBench 和 OpenCompass evaluation 脚本。

中等强度证据

  • 1.4B 从头训练 300B tokens 的下游平均分接近 full attention,但短任务输入太短,主要证明短能力保留。
  • H800 latency 显示清晰成本曲线,但 batch size 1 和同 Triton baseline 限制了生产推论。
  • chunk overlap 经验支持 one-load-multiple-compute kernel,但只在作者 checkpoint 和 pretraining sequences 上测量。

需要谨慎的推论

  • “toward infinite context” 是路线判断。当前实现仍有 O(L2/S)O(L^2/S) retrieval term,论文建议用 approximate nearest-neighbor search 降到近似 O(Llog(L/S))O(L\log(L/S)),但尚未实证。
  • HiLS 当前不支持 context parallelism,因此真正超长训练能力尚未验证。
  • unselected chunks 没有梯度更新,极端任务中 selector 可能固化盲点。
  • Q-Cal 为什么改善外推仍未解释,当前是经验性组件。
  • 公开审稿缺失,多 seed / 置信区间缺失,外部复现仍待完成。

本地讨论补充

1. 讨论收敛点

  • 本轮初读的核心判断是:HiLS 的贡献重点在 selector 进入 forward attention mass 后获得 LM loss 监督。它把“选哪些 chunk”从外部路由问题变成 attention probability factorization 的一部分。
  • 它和 DeepSeek DSA / MiniMax MSA / FlashMemory 的差异在层级上很明确:HiLS 主要处理训练时 native sparse attention 和 chunk summary 表达;DSA/MSA 更偏具体 selector / production model 路线;FlashMemory 处理已选 sparse chunks 的 KV residency / prefetch。

2. 修正后的理解

  • 论文标题中的 “infinite context modeling” 应理解为训练路线:固定远程 token budget + 可外推 selector + 后续 ANN retrieval。当前实验已经到 4M RULER 外推,但没有完成真正 infinite-context training system。
  • HiLS 的强项来自“压缩后选择”的 inductive bias。作者认为 token-level irrelevant mass 在 full attention 中会随长度累计成噪声,chunk compression 可以部分抵消噪声并保留 shared semantic signals。

3. 后续复验指标

  • 在公开 checkpoint 上复验 RULER 4M、LongBench-v1、PPL last-512,并记录 seed / prompt variance。
  • 对比 vendor-optimized full attention、paged attention、programmable sparse serving 和批量 decode throughput。
  • 测试 needle retrieval、multi-hop QA、code repo navigation、agent trajectories,区分 selector miss、compression error 和位置编码外推错误。
  • 实作 context parallelism 后复测 256K / 1M training,而只依赖外推。

主要启发

  • sparse attention 的质量瓶颈常在 selector learning signal。把 routing score 放进 forward probability mass,比只用 hard top-KK routing 更容易获得 next-token loss 监督。
  • chunk summary 需要表达 LogSumExp 的两种极端:均匀 mass 与单点主导。weighted key + entropy bias 是一个简洁的工程近似。
  • 长上下文效率需要同时看训练、prefill、decode、KV residency 和 kernel tile utilization。HiLS 解决 attention form 与 kernel packing;FlashMemory 与通用 serving stack 处理另一层问题。
  • 位置编码会进入 chunk compression 语义质量。HoPE 的收益提示 long-context sparse attention 设计不能只看 selector,还要看 representation 在训练长度外是否稳定。

局限

  1. context parallelism 尚未支持,超长训练能力仍需系统实现和验证。
  2. unselected chunks 不接收梯度,selector 在稀有依赖或低频多跳关系上可能形成盲点。
  3. Q-Cal 的有效机制尚未解释,当前依赖 ablation 经验。
  4. 训练硬件、并行度、seed、统计显著性、外部复现和强 serving baseline 不完整。
  5. latency 实验是 345M / single H800 / batch size 1,不能直接外推到生产多 batch、多租户和跨节点 serving。

跨论文关系

  • Ring AttentionDeepSpeed Ulysses:这些论文保持 exact / dense attention 语义,通过 context parallelism / sequence parallelism 扩展训练;HiLS 改变 attention form,通过 native sparse training 降低有效 token-pair 预算。二者分别代表“保精确语义的系统扩展”和“学习稀疏可见性的模型结构扩展”。
  • FlashAttention-2:FlashAttention-2 优化 exact attention kernel 的 tiling 和 work partitioning;HiLS 在算法层减少可见 tokens,并用相邻 query union 设计改善 sparse kernel 的 Tensor Core 利用率。
  • DeepSeek-V3.2 / DSA:DSA 用 lightning indexer 做 fine-grained token selection,并通过 dense indexer warm-up / sparse continued pre-training 进入 DeepSeek production line;HiLS 用 landmark summary + hierarchical softmax 让 chunk selector 直接受 LM loss 监督。两者都追求 trainable sparse attention,但监督路径不同。
  • DeepSeek-V4:V4 的 CSA/HCA 组合是 production-scale million-token compressed attention 系统;HiLS 提供可迁移到 full-attention checkpoint 的 native sparse attention 机制。二者在 chunk compression、top-k sparse selection、SWA local branch 和 long-context efficiency 上互补。
  • FlashMemory-DeepSeek-V4:FlashMemory 预测未来哪些 CSA chunks 需要驻留 GPU,解决 KV residency;HiLS 学习每个 query 应该读取哪些 chunk,解决 attention selector。作者上有 Xiang Hu、Tian Liang、Yan Wang、Haitao Mi 重叠,构成 Tencent long-context sparse attention / memory line。
  • MiniMax Sparse Attention:MSA 采用 GQA-based block sparse attention、Index Branch 和 KL alignment,面向 MiniMax-M3 production model;HiLS 以 LogSumExp surrogate 和 LM loss 端到端优化为核心,强调训练时 native sparse attention 和 length extrapolation。
  • Lightning AttentionDynamic Linear Attention:这些方法用 recurrent / linear memory 降低复杂度;HiLS 保留 softmax attention 结构,只在远程 chunk 维度稀疏化。两条路线的取舍是 memory compression state 与 sparse random access。
  • IndexCacheGLM-5.2:Yushi Bai 连接两条研究线。HiLS 学习 chunk hierarchy 与 token selection;IndexCache 复用已有 DSA selector 的跨层结果;GLM-5.2 将后者固化为 FSSS IndexShare。
  • 归档记录:content/utility/papers-index.md 已加入 HiLS-Attention;本笔记的 跨论文关系 已连接 DeepSeek-V4 / DSA / FlashMemory、MiniMax Sparse Attention、Ring Attention、Ulysses 和 Lightning Attention。