Paper: 2612.06276 — Not Every Token Deserves Softmax
Authors: Aviv Bick, Arshia Afzal, Roger Waleffe, Aakash Lahoti, Mostofa Patwary, Mohammad Shoeybi, Bryan Catanzaro, Eric P. Xing, Albert Gu
Categories: cs.LG
Reading scope: Full original arXiv HTML (https://arxiv.org/html/2612.06276, 1,688,652 bytes, Sections 1–9 and Appendices A.1–A.7 read thoroughly). Figures in the arXiv HTML are rendered inline via LaTeX/TikZ rather than standalone image files, so all quantitative claims are drawn directly from Tables 1–16 and the paper’s prose.
The Problem
Imagine feeding a 64,000-token report—or an essay hiding a random UUID passkey or structured database field—into a language model and asking for that exact key at the end. Today’s sequence models force a blunt architectural choice on how to remember those 64,000 tokens (Section 1 and Section 2.1):
- Softmax Transformers compare every query against every past key through an exponential kernel. Because that kernel does not factorize, the model must keep every single token in a KV cache—234.9 million stored scalars at just 8K context in a 2B model (Table 1 and Table 14). Recall is sharp, but memory traffic chokes long-context decoding.
- Linear attention and state-space models (SSMs) such as GLA, Mamba-2, and Gated DeltaNet (GDN) use kernels that factorize, folding the entire past into a fixed-size recurrent state. Decoding stays fast and constant-memory, but exact lookup of arbitrary buried strings breaks down.
- Layer-interleaved hybrids (such as 1 softmax layer for every 4 or 6 recurrent layers) compromise at the layer boundary. Yet every designated attention layer still caches 100% of its tokens (37.5M–45.7M scalars at 8K for a 2B hybrid), while recurrent layers cache none.
- Training-free KV-cache eviction (StreamingLLM, H2O, SnapKV, AdaKV) tries to trim a trained Transformer after the fact, but permanently discards evicted tokens that the model was trained assuming it could still read.
Earlier mechanistic work (Bick et al., 2025c) pointed to why the layer boundary is the wrong cut: exact retrieval inside Transformers runs through only a handful of heads and, within them, only a small fraction of tokens. Keeping every token in 1 out of 6 layers wastes cache on filler words while starving other layers of exact lookup. If only a small fraction of tokens ever need the exponential kernel, why decide memory allocation per layer instead of per token?
The Explanation
The authors introduce Attention Routing Kernels (Ark), a single homogeneous layer block that replaces hand-tuned layer ratios with a learned per-entry router (Section 3). For every token, inside every layer and every grouped-query KV group, the router decides at write time—before any future query arrives—which of two memories will hold that token:
Incoming token x_t (per layer & KV group, at write time)
|
+--> Router r(x_t) = 1 (~10% of entries) --> Packed KV cache (exponential kernel)
| [exact key, value, pos, log-decay]
+--> Router r(x_t) = 0 (~90% of entries) --> Fixed-size recurrent state (linear kernel)
[folded via 1+elu feature map]
Every query q_t reads BOTH memories under ONE shared denominator & ONE shared decay gate
How Token-Level Routing Works—and Why Nothing Gets Thrown Away
Unlike post-hoc KV eviction, tokens denied a KV-cache slot in Ark are not discarded: they are folded into a fixed-size normalized linear-attention state (Section 3.1). Both branches share the exact same scalar data-dependent temporal decay gate (Section 2.1), so a token’s positional weighting is identical regardless of which memory holds it. The authors deliberately drop RoPE because rotating non-negative linear-attention features can introduce negative similarity scores and destabilize the shared denominator.
When a future query arrives, it reads both the packed KV cache (via the exponential kernel) and the recurrent state (via the 1 + elu linear kernel), combining their outputs under one unified normalization denominator (Section 3.1 and Section 4.3). Because exact retrieval over a few keys and lossy compression over the rest make different demands on keys and queries, Ark adds lightweight low-rank adapters (QK LoRA) to the linear branch’s queries and keys before applying separate QK-RMSNorm to each branch (Section 3.3). Surprisingly, short convolutions—a fixture of Mamba and GLA—hurt recall substantially here (dropping 400M FDA accuracy from 71.9% to 37.4% or 28.2%, Table 8), so Ark omits them.
Training the Router Without Quadratic Overhead
How do you teach a write-time router which tokens future queries will need, without evaluating full quadratic softmax attention over every query? Section 3.2 solves this with two clean tricks:
- Sampled-query softmax distillation: For each sequence, sample just 10 query positions uniformly at random and compute the full decayed softmax attention distribution over their causal history as a teacher. Compare that teacher via KL divergence against a soft mixture of the exponential and linear distributions weighted by the router’s continuous scores. Because queries are sampled uniformly, this gives an unbiased estimate of the full objective at linear-in-length cost (
O(|Q| T)). In Table 10’s ablation, zero sampled queries collapses the router to compressing 99.76% of tokens (FDA plunges to 2.0%), whereas even a single sampled query per sequence (|Q| = 1) prevents collapse and recovers 68.8% FDA accuracy (|Q| = 10hits 71.9%). Gradients are cleanly decoupled: the auxiliary loss trains only the router (backbone activations detached), while the language-modeling loss trains only the backbone. - Pooled one-sided budget penalty: To stop the router from keeping 100% of tokens in KV cache, Ark penalizes any shortfall below a target compression rate (default 90% linear / 10% KV) using an adaptive penalty weight updated via exponential moving average. Crucially, the budget is pooled across all layers and KV groups of a sequence, not enforced per layer—allowing the router to concentrate KV memory in retrieval-heavy heads while leaving other layers almost purely recurrent.
Turning 10% Retention into Real GPU Speed
Sparsity on paper often evaporates on GPUs unless memory layout matches the hardware. Section 4 builds custom Triton kernels so the two branches execute independently with exact equivalence (no approximation):
- Packed exponential attention (Section 4.1): A prefix scan packs retained keys and values into a contiguous buffer alongside their original sequence positions and cumulative log-forget gates. Because packed keys remain sorted by position, future-only tiles are skipped completely, and temporal decay across skipped tokens reduces to a single subtraction of stored cumulative log-gates.
- Log-space chunkwise linear recurrence (Section 4.2): Rather than packing the ~90% linear tokens, a chunkwise recurrence sweeps the full timeline in log space—masking retained entries to negative infinity so they contribute zero key weight while keeping their forget gates active—and stores per-feature normalized value means alongside log-masses for numerical stability.
- Zero-write recurrent decay on retained decode steps (Section 4.4): During autoregressive decoding, when a new token is routed to the KV cache (
r = 1), the existing recurrent state still decays by the forget gatef_t. Becausef_tmultiplies both the state numerator and denominator equally, it cancels out completely in the stored normalized value mean. The decode kernel therefore updates only a small vector ofd_klog-masses and skips writing the entired_k x d_vstate matrix! Analytically (Section 4.5), Ark’s logical decode memory traffic drops below full attention after just ~136 tokens on the 2B model at 10% retention.
Quality, Memory, and Speed Across 400M–2B Models
All models are trained from scratch on SlimPajama: 400M (15B tokens, 2K context), 800M (32B tokens, 4K context), and 2B (200B tokens, 8K context), compared against RoPE, NoPE, and Forgetting (FoX) Transformers, MLA, and GLA / GDN 1
and 1 layer hybrids (Section 5, Tables 1–6):- Drastically smaller memory footprint (Table 1 and Table 14, 8K context, 2B scale): Ark stores 25.3M total elements (
1.8Mrecurrent state +23.5MKV cache), roughly 89% less than RoPE/NoPE Transformers (234.9M), 45% less than 1 hybrids (45.7M), and 33% less than 1 hybrids (37.5M; 25%–53% less across all scales). - Competitive language modeling and open-book QA (Tables 4 and 5, 2B): On five zero-shot commonsense benchmarks, Ark averages 53.4%, beating the RoPE Transformer (52.7%), NoPE (49.7%), GLA 1 (51.5%), and GLA 1 (52.1%), and landing within 1.0 point of GDN 1 (54.4%) using 45% less memory. On open-book document QA (TriviaQA, DROP, NQ@512–2048), Ark averages 39.5%, ahead of both GLA hybrids (36.3% / 37.1%), NoPE (36.3%), and FoX (38.9%), and within 1.4 points of GDN 1 (40.9%).
- Strong tracking/QA, with an honest gap on multi-key 8K needles (Tables 2 and 3, 2B): On RULER and BABILong, Ark leads on frequent-word extraction at 8K (60.3% vs. GDN 1’s 44.7%), SQuAD-QA across 2K–8K (42.6% / 38.6% / 30.3%), and BABILong across 2K–8K (35.7% / 30.9% / 23.8%). However, GDN 1 and 1 still win on harder multi-key and multi-value needles at 8K (for example, NIAH-MK2 at 8K: GDN 1 hits 84.4% vs. Ark’s 15.6%; NIAH-MV at 8K: 75.8% vs. 41.5%). The authors attribute this to Ark’s simple scalar forget gate compared with GDN’s delta-rule transition.
- Crushing training-free KV eviction at equal memory (Table 6 and Table 15): Even when compared against the per-column upper bound across four eviction policies (StreamingLLM, H2O, SnapKV, AdaKV) applied to RoPE, NoPE, and FoX at matched memory, Ark wins on nearly every benchmark—nearly doubling 800M FDA accuracy (81.3% vs. 41.9%), scoring 99.6% vs. 25% on 800M NIAH-3 at 4K, and reaching 88.4% vs. 37% on 2B NIAH-3 at 4K.
- Real H100 throughput gains (Section 5.2, Figure 7, Table 16, 2B BF16, single H100 80GB, batch 8): At 64K prompt length (256 generated tokens), Ark decodes 3.8x faster than FlashAttention-4 and 1.8x faster than the Hybrid GLA 1 baseline (faster than both at every tested prompt length). On prefill (batch 8), FlashAttention-4 leads on short prompts, Ark overtakes it at 8K, and reaches 1.98x FlashAttention-4 and 1.20x Hybrid GLA 1 at 64K.
The Counterintuitive Twist: Both Memories Are Essential—and Dumping Everything Into KV Cache Hurts
Does the trained 400M Ark model really rely on the ~10% of tokens it routes to KV cache? Section 6 and Section 7 run three sharp causal checks that expose how the dual memory actually works:
- Content-aware selection beats 4.6x more random cache (Table 11): At ~10% KV budget, Ark’s learned router hits 70.1%–75.2% on UUID NIAH-3 where periodic and random selection score below 7%. Even when random routing is handed 4.6x more KV cache (48.5% of tokens), it still trails Ark’s 10.6% learned router on UUID NIAH-3 (31.0% vs. 70.1% at 2K) and FDA extraction (49.6% vs. 71.9%).
- Forcing all tokens into the recurrent state preserves commonsense but wipes out retrieval (Table 12): Overriding the router at inference so every token goes to the recurrent state keeps 94%–101% of accuracy on PIQA, WinoGrande, and ARC-e—proving commonsense tasks barely touch the KV cache—while collapsing FDA from 71.9% to 0.0% and LAMBADA from 31.5% to 0.6%.
- The surprise—forcing all tokens into the KV cache (
All-KV) halves retrieval instead of restoring it (Table 12): Overriding the router so every token stays in exact softmax KV cache cuts SWDE from 53.8% to 27.8% (52% retained) and FDA from 71.9% to 35.7% (50% retained). The recurrent state is not a mere lossy fallback; the trained model depends on each memory handling its own role! And when the authors leave all other routing untouched and reroute only the answer tokens from the KV cache to the recurrent state (Table 13), mean retrieval accuracy collapses roughly sixfold, from 52.1% to 8.4% (FDA drops from 71.9% to 4.8%).
Core Concepts
1. Per-Entry Kernel Routing with Shared Normalization
Every token in every KV group is assigned at write time to either the exponential kernel (KV cache) or the linear kernel (recurrent state), and every query merges both readouts under one shared denominator and one shared scalar forget gate. On a 64K document containing a buried UUID passkey, the router can park the rare passkey tokens in the exact KV cache while folding surrounding prose into the fixed-size state—so neither memory has to approximate the other’s job. Without the shared normalizer and decay, the two branches would drift out of scale and disagree on positional distance.
2. Sampled-Query Distillation + Pooled Budget Constraint
Training a causal router requires teaching it what future queries will miss if a token is compressed, without paying quadratic attention cost at every training step. Sampling just 10 queries per sequence to compute exact softmax KL targets costs O(|Q| T) yet prevents router collapse (Table 10), while pooling the 90% compression target across all layers and KV groups lets the model spend KV budget wherever retrieval heads emerge rather than enforcing rigid layer ratios.
3. Position-Aware Packing and Log-Space State Updates
Hardware speed comes from separating the two branches cleanly: retained keys are packed densely with absolute timestamps and cumulative log-forget values so Triton kernels skip future tiles and compute arbitrary-gap decay by subtraction, while the linear branch tracks normalized value means and log-masses so retained decode steps skip writing the recurrent matrix altogether (Section 4.4).
The Insight
Exact attention and fixed-size recurrence do not need to be separated at the layer boundary—they can share a single unified attention equation routed per token and KV group. When a model learns during pretraining which ~10% of tokens warrant exact KV storage and folds the remaining 90% into a recurrent state rather than discarding them, it matches strong layer-wise hybrids with 25%–53% less memory and unlocks multi-fold long-context decoding speedups—while showing that which entries stay in the KV cache matters far more than how many.
A Critical Reading
The empirical and systems engineering work is thorough—three scales up to 2B / 200B tokens, strong RoPE/NoPE/FoX/MLA/GLA/GDN baselines, four equal-memory KV-eviction baselines, custom H100 Triton benchmarks, and causal rerouting audits. Several real limitations remain grounded in the paper itself (Section 9 and Tables 3, 8, 16):
- Irrevocable write-time routing (acknowledged in Section 9): Because
r(x_t)is decided when tokentis written, before future queries arrive, any token whose relevance only becomes clear later in a conversation or prompt cannot be promoted back out of the recurrent state into the KV cache. - Linear KV growth still exists—and budget is soft (Section 3.2 and Section 9): A fixed 10% target cuts KV-cache growth by 10x, not to
O(1). Moreover, the budget penalty is a soft training-time constraint with no hard inference cap, so unusually dense inputs could retain more than 10% of tokens (measured retention on 400M is 10.6%, Table 11). - Simple scalar decay trails GDN on multi-key 8K retrieval (Table 3 and Section 9): Ark lags GDN 1 sharply on multi-key and multi-value 8K RULER tasks (e.g., 15.6% vs. 84.4% on NIAH-MK2 8K). The authors hypothesize that swapping Ark’s scalar forget gate for a richer delta-rule recurrence would close that gap, but that combination is untested here.
- Sensitivity to block details and scale ceiling (Table 8 and Section 5): Ark’s accuracy drops steeply if you omit
QK-RMSNorm(FDA 71.9% to 47.2%) or add standard SSM short convolutions (FDA 71.9% to 28.2%–37.4%). All training runs stop at 2B parameters / 8K training length (throughput is benchmarked up to 64K at fixed 10% retention); how learned write-time routing behaves at 7B–70B+ scale, under multi-turn chat, or with instruction/reasoning post-training remains open.
What You Can Use
Return to the opening problem of serving long-context LLMs without paying full KV-cache bandwidth or losing exact recall.
- Stop treating post-hoc KV eviction as equivalent to native sparse memory: Table 6 and Table 15 show that training a full-cache Transformer and evicting 90% of tokens at inference severely degrades hard retrieval (e.g., 4K UUID needle recall drops to 25%–37% vs. Ark’s 88.4%–99.6%). If you control pretraining or continued pretraining, folding non-retained tokens into a recurrent state while training a lightweight write-time router outperforms eviction at identical memory.
- If you build hybrid long-context architectures, pool budgets globally and skip short convolutions in routed blocks: Instead of hand-tuning 1 or 1 attention-to-SSM layer schedules, pooling a soft compression budget across all layers and KV groups lets retrieval heads self-organize—and only 1 to 10 sampled teacher queries per sequence are needed to supervise the router cheaply. Keep in mind Ark’s current sweet spot: long-context single-pass QA, aggregation, and throughput-bound decoding where 10% retention suffices, whereas ultra-dense multi-key retrieval still benefits from delta-rule recurrent updates.
论文: 2612.06276 — Not Every Token Deserves Softmax
作者: Aviv Bick, Arshia Afzal, Roger Waleffe, Aakash Lahoti, Mostofa Patwary, Mohammad Shoeybi, Bryan Catanzaro, Eric P. Xing, Albert Gu
分类: cs.LG
阅读范围: 通读 arXiv 原文完整 HTML(https://arxiv.org/html/2612.06276,1,688,652 字节,正文第 1–9 节及附录 A.1–A.7 未截取片段)。原文图表以内联矢量/公式形式渲染,未提供独立位图文件,本文所有定量结果均直接核对自正文第 2–7 节、附录 A 与表 1–16。
问题
设想把一份 64,000 词元的超长报告——或者一篇藏着随机 UUID 密钥和表格字段的长文章——塞进语言模型,让它在末尾精准答出那个关键字段。 现有的序列建模架构,在“怎么记住这 64,000 个词”上几乎都在做一道粗糙的二选一(第 1 节与第 2.1 节):
- 标准 Softmax Transformer 用指数核把当前查询和过去每个键逐一比对。 由于指数核没法分解,模型只能把每一个词元都塞进 KV 缓存——哪怕只是 2B 参数模型、8K 上下文,缓存里也要存下 2.349 亿个标量(表 1 与表 14)。 精确召回是保住了,但解码时的显存带宽直接成了死穴。
- 线性注意力与状态空间模型(SSM)(如 GLA、Mamba-2、Gated DeltaNet / GDN)把核函数做成可分解内积,整段历史压进一个固定大小的循环状态。 解码恒定显存、快如闪电,可一碰上精确抄写任意密钥或冷门字段就糊成一团。
- 按层混排的混合架构(比如每 4 层或 6 层循环层夹 1 层注意力层)在层边界上妥协。 但每一层注意力依然要缓存 100% 的词元(2B 混合模型在 8K 下仍占 3,750 万到 4,570 万个元素),而循环层一个词都不留。
- 免训练的推理期 KV 驱逐(StreamingLLM、H2O、SnapKV、AdaKV)试图在模型训完后硬删缓存,可被删掉的词元直接灰飞烟灭,而模型预训练时一直以为这些词元还在。
先前的机理研究(Bick 等人,2025c)其实已经点破了症结:Transformer 里的精确检索只靠极少数注意力头,而且在这些头里,真正需要被精确捞出来的词元也只占极小一部分。 按“整层”去切分,等于在注意力层里给大量废话词白白交缓存房租,又在其他层里彻底断绝精确查找。 既然不是每个词都配享用指数核,为什么不把选择权从“按层”下放到**“按词”**?
翻译
作者提出 Attention Routing Kernels(Ark),用同一种匀质模块取代手工配比的混合层(第 3 节)。 在每一层、每一个分组查询(GQA)键值组里,都装上一个轻量的写时路由器:每来一个词元,在未来查询还没出现之前,路由器当场决定把它送进两块记忆中的哪一块:
新词元 x_t 抵达(每层、每个 KV 组,写时一次性拍板)
|
+--> 路由器 r(x_t) = 1(约 10% 词元)--> 紧缩 KV 缓存(指数核精确检索)
| [存键、值、原位置、累计对数遗忘门]
+--> 路由器 r(x_t) = 0(约 90% 词元)--> 固定大小循环状态(线性核压缩保存)
[经 1+elu 特征映射折入状态]
后续每个查询 q_t 在【同一个共享归一化分母 + 同一个标量遗忘门】下同时读取两块记忆
按词分流怎么跑:不进缓存的词并没有被扔掉
跟推理期 KV 驱逐最大的不同在于,Ark 没给 KV 槽位的词元并没有被丢弃,而是全部折叠进了固定大小的归一化线性注意力状态(第 3.1 节)。 两条支路共用同一个数据相关的标量时间衰减遗忘门(第 2.1 节),所以不管一个词进了缓存还是进了循环状态,它的位置衰减权重完全一致。 作者刻意不用旋转位置编码(RoPE),因为旋转非负线性特征可能产生负相似度,导致共享归一化分母失稳。
等到后续查询到来时,它同时读取紧缩 KV 缓存(指数核)和循环状态(1 + elu 线性核),并在同一个分母下把两边加权合并(第 3.1 节与第 4.3 节)。
由于“对少数关键点做精确查找”和“把绝大多数词压进固定状态”对查询和键的几何要求截然不同,Ark 专门给线性支路的查询与键加上了轻量低秩适配器(QK LoRA),再对两条支路分别做 QK-RMSNorm 归一化,避免两边量纲打架(第 3.3 节)。
有意思的是,Mamba 和 GLA 几乎标配的短卷积放在 Ark 里反而严重拖累召回(400M 模型 FDA 准确率从 71.9% 暴跌到 37.4% 或 28.2%,表 8),所以 Ark 干脆去掉了短卷积。
不花平方复杂度,怎么教会路由器挑词?
路由器在写词那一刻还看不见未来的提问,怎么知道哪些词以后会被精确查找? 第 3.2 节用两个巧妙设计绕过了平方级开销:
- 抽样查询蒸馏完整 Softmax 教师:每条训练序列只均匀随机抽取 10 个查询位置,只对这 10 个查询算出完整带衰减的 Softmax 注意力分布当作教师,再用路由器连续打分把指数分布和线性分布软混合,最小化两者之间的 KL 散度。
因为是均匀抽样,它是全序列目标的无偏估计,开销从长度平方降为线性(
O(|Q| T))。 表 10 的消融非常有说服力:如果不抽查询(|Q| = 0),路由器只剩压缩惩罚,直接把 99.76% 的词全压进状态,FDA 召回跌到 2.0%;可只要每条序列抽哪怕 1 个查询(|Q| = 1),就能刹住坍缩,FDA 立刻拉回 68.8%(抽 10 个达到 71.9%)。 同时梯度彻底解耦:辅助损失只更新路由器(主干特征截断梯度),语言建模损失只更新主干。 - 全网池化的单侧预算约束:为防止路由器偷懒把所有词全塞进 KV 缓存,Ark 对低于目标压缩率(默认 90% 进循环状态 / 10% 留缓存)的序列施加单侧惩罚,并用指数滑动平均动态调节惩罚权重。 最妙的一笔在于,预算不是死板地分摊给每一层,而是把整条序列所有层、所有 KV 组的词元合在一个大池子里考核——这样模型可以自由把 KV 槽位堆给真正负责检索的注意力头,而让其他层几乎纯靠循环状态运行。
把 10% 留存率变成实打实的 H100 加速
论文里的稀疏度经常一上 GPU 就化为乌有。 第 4 节专门写了全套 Triton 算子,把双分支拆开独立并行计算,且数学上与原公式完全等价:
- 紧缩指数注意力(第 4.1 节):前缀扫描把保留下来的键和值打包进连续缓冲区,同时记下它们的原始位置和累计对数遗忘值。 因为保留键依然按时间有序排列,完全落在未来的分块直接跳过,跨过被压缩词元的时间衰减只是一次累计对数遗忘门相减,空隙不花一分额外算力。
- 对数空间分块线性循环(第 4.2 节):约 90% 的词走线性支路,干脆不分拣打包,直接全序列分块扫描,在核函数内部把留给缓存的词对数权重设为负无穷(贡献清零但保留遗忘门)。 为防止长上下文溢出,循环状态存的是逐特征归一化的值均值和累计对数质量。
- 解码期留存步的零写回巧算(第 4.4 节):自回归解码时,如果新词元被送进 KV 缓存(
r = 1),旧循环状态依然要乘以遗忘门f_t。 可分子和分母同时乘以f_t,在存储的归一化值均值里直接约掉了! 因此这一步解码核函数只需更新极小的对数质量向量,完全跳过写回整个d_k x d_v状态矩阵。 理论算下来(第 4.5 节),在 2B 模型、10% 留存率下,只要上下文超过约 136 个词元,Ark 的解码访存量就已经低于标准全注意力。
400M 到 2B 的质量、显存与吞吐实测
作者在 SlimPajama 上从零训练了三档模型:400M(15B 词元,2K 长度)、800M(32B 词元,4K 长度)和 2B(200B 词元,8K 长度),全面对比 RoPE / NoPE / FoX Transformer、MLA 以及 GLA / GDN 的 1
与 1 混合架构(第 5 节,表 1–6):- 显存大幅瘦身(表 1 与表 14,2B 模型 8K 上下文):Ark 总计仅存 2,530 万个元素(180 万循环状态 + 2,350 万 KV 缓存),比 RoPE/NoPE Transformer(2.349 亿)省了 约 89%,比 1 混合模型(4,570 万)省 45%,比 1 混合模型(3,750 万)省 33%(全规模相对混合架构节省 25%–53%)。
- 语言建模与开放文档问答稳居第一梯队(表 4 与表 5,2B):在五项零样本常识基准上,Ark 平均 53.4%,超过 RoPE Transformer(52.7%)、NoPE(49.7%)、GLA 1(51.5%)和 GLA 1(52.1%),仅落后 GDN 1(54.4%)1 个百分点,但显存少用 45%。 在真实文档问答(TriviaQA、DROP、NQ@512–2048)上平均 39.5%,胜过两档 GLA 混合以及 NoPE、FoX,距最佳的 GDN 1(40.9%)仅差 1.4 分。
- 追踪与聚合亮眼,但在 8K 多键大海捞针上留有明显短板(表 2 与表 3,2B):在 RULER 与 BABILong 上,Ark 在 8K 高频词提取(60.3% 对 GDN 1 的 44.7%)、SQuAD 问答(2K/4K/8K 为 42.6% / 38.6% / 30.3%)及 BABILong(35.7% / 30.9% / 23.8%)均拿下领先。 但在高难度 8K 多键、多值大海捞针上,GDN 1 与 1 仍大幅领先(如 NIAH-MK2 8K:GDN 1 达 84.4%,Ark 仅 15.6%;NIAH-MV 8K:75.8% 对 41.5%)。 作者认为这源自 Ark 线性支路只用了最简标量遗忘门,而 GDN 用了表达力更强的 Delta 规则更新。
- 同显存下碾压免训练 KV 驱逐(表 6 与表 15):哪怕拿 StreamingLLM、H2O、SnapKV、AdaKV 四种驱逐策略在三种 Transformer 上按列取“单项最高分”拼出理论上界,Ark 在同等显存下几乎全线胜出——800M 的 FDA 准确率几乎翻倍(81.3% 对 41.9%),800M 4K 的 UUID 大海捞针(NIAH-3)高达 99.6% 对 25%,2B 4K 也达到 88.4% 对 37%。
- 单卡 H100 真实吞吐大提速(第 5.2 节、图 7、表 16,2B BF16,batch 8):在 64K 提示长度下解码 256 词元,Ark 达到 FlashAttention-4 的 3.8 倍、GLA 1 混合模型的 1.8 倍,且在所有测试长度下解码全胜。 预填充阶段,短提示下 FlashAttention-4 最快,Ark 在 8K 处反超,到 64K 时达到 FlashAttention-4 的 1.98 倍、GLA 1 的 1.20 倍。
最反直觉的机理发现:两块记忆各司其职,把词全塞回 KV 缓存反而把检索打对折
训好的 400M Ark 模型到底是不是真的靠那 10% 的缓存词在干活? 第 6 节与第 7 节的三组因果干预实验,把双记忆的分工扒得一清二楚:
- 挑得准,远比留得多重要(表 11):同为约 10% KV 预算,学习路由在 UUID 大海捞针(NIAH-3)上拿到 70.1%–75.2%,而等距保留和随机保留全都不到 7%。 就算把随机保留的 KV 预算放大 4.6 倍(留 48.5% 的词),在 2K UUID 检索(31.0% 对 70.1%)和 FDA 提取(49.6% 对 71.9%)上依然输给只留 10.6% 的学习路由。
- 全强制进循环状态:常识纹丝不动,检索彻底归零(表 12):推理时强行把所有词元压进循环状态,PIQA、WinoGrande、ARC-e 等常识任务保住了 94%–101% 的准确率——说明常识题压根不靠 KV 缓存;可检索任务直接崩盘,FDA 从 71.9% 掉到 0.0%,LAMBADA 从 31.5% 掉到 0.6%。
- 最出人意料的反转——全强制进 KV 缓存(
All-KV),检索不但没恢复,反而腰斩(表 12):如果反过来强行让每一个词都留在精确 Softmax 缓存里,SWDE 从 53.8% 跌到 27.8%(仅留 52%),FDA 从 71.9% 跌到 35.7%(仅留 50%)。 这说明循环状态绝不是缓存不够时的残次备胎,模型在训练中已经学会让两块记忆协同分工! 而如果保持其余 99% 以上的路由不变,只把上下文里出现答案的那几个词从 KV 缓存挪进循环状态(表 13),三项检索平均准确率立刻骤降约 六倍(从 52.1% 跌到 8.4%,FDA 从 71.9% 跌到 4.8%)。
核心概念
1. 共享归一化下的按词核路由
每一层、每个 KV 组在写入新词元时就决定它走指数核(进 KV 缓存)还是线性核(折进循环状态),后续每个查询在同一个归一化分母和同一个标量遗忘门下把两边合并读出。 放在 64K 报告找密钥的例子里,路由器把稀缺的密钥词元钉进精确缓存,把铺垫段落压进固定状态,两块记忆互不打架;少了共享分母和共享衰减,两路的权重尺度和位置感知就会脱节。
2. 抽样查询蒸馏 + 全网池化预算
想让写时路由器学会预判未来谁重要,又不能每步都算全序列平方注意力,作者只随机抽 10 个查询做完整 Softmax 的 KL 蒸馏(开销线性,抽 1 个就能防坍缩,表 10),同时把 90% 的压缩目标放进整条序列所有层和所有 KV 组的大池子里考核。 这让模型自己长出“哪些头多留缓存、哪些层几乎纯循环”的动态布局,省去人工调混合层比例的玄学。
3. 保位打包与对数空间状态更新
把省下来的 90% 显存真正兑现为 GPU 速度,靠的是两路彻底解耦的硬件友好布局:缓存支路把保留键紧缩打包并带上绝对位置与累计对数遗忘值,跳过未来分块且用一次减法算跨距衰减;线性支路在对数空间维护归一化均值与对数质量,让写入缓存的解码步直接约掉遗忘因子、免写整个状态矩阵(第 4.4 节)。
洞见
精确注意力和固定大小循环记忆不必按“整层”生硬割裂,它们可以在同一个统一注意力公式里按词元、按键值组动态分流。 当模型在预训练阶段就学会挑出那约 10% 值得进缓存的词元、同时把其余 90% 折进循环状态而非粗暴丢弃时,它不仅能以比混合架构少 25%–53% 的显存追平强基线并实现长上下文数倍解码加速,更揭示了一个关键事实:缓存里留的是哪些词,远比留了多少词重要得多。
博导审稿
这篇论文的架构直觉、算子实现和因果验证都非常扎实:400M/800M/2B 三档从零预训练(最高 200B 词元)、覆盖主流 Transformer 与 GLA/GDN 混合架构、同显存下对比四种免训练 KV 驱逐、给出真实 H100 Triton 吞吐基准,还用答案词定向改道坐实了双记忆分工。 但顺着原文第 9 节和各消融表细查,几个硬约束也很清楚:
- 写时路由不可反悔(第 9 节自承):路由器在词元刚出现时就要一次性拍板,此时根本看不到后面的用户提问。 如果某个词当时看起来平平无奇、直到几千字后突然变成关键线索,一旦折进循环状态就再也提不回精确 KV 缓存。
- 显存仍随长度线性增长,且预算只是软约束(第 3.2 节与第 9 节):10% 留存率把 KV 缓存增速压低到十分之一,但渐近上仍是线性增长,并非恒定显存。 同时压缩目标只是训练期的软惩罚,推理时没有硬上限,遇到高信息密度文本实际留存率可能超过 10%(如 400M 实测为 10.6%,表 11)。
- 最简标量衰减在 8K 多键检索上仍敌不过 GDN(表 3 与第 9 节):在 RULER 多键、多值 8K 任务上,Ark 明显落后 GDN 1(例如 NIAH-MK2 8K 为 15.6% 对 84.4%)。 作者推测把 Ark 的标量遗忘门换成 GDN 的 Delta 规则更新即可补齐短板,但这一组合尚未在文中实测。
- 模块细节较敏感,且尚未验至大参数与多轮推理(表 8 与第 5 节):去掉
QK-RMSNorm会让 FDA 从 71.9% 掉到 47.2%,加上 SSM 常见的短卷积更是掉到 28.2%–37.4%。 另外,本文训练上限为 2B 参数、8K 训练长度(64K 仅在固定 10% 留存率下测了吞吐),到了 7B–70B+ 规模、多轮对话或长思维链后训练下,写时路由能否保持同样稳定,仍有待验证。
启发
回到开头那个“既想要长上下文低显存高速解码,又不想丢精确召回”的工程难题:
- 别再把推理期 KV 驱逐当成原生稀疏记忆的平替:表 6 与表 15 给出了极强的反例——训完满缓存 Transformer 再在推理时硬删 90% 缓存,遇到 4K UUID 大海捞针会从接近满分跌到 25%–37%,而 Ark 在同等显存下能守住 88.4%–99.6%。 只要你掌控预训练或继续预训练流程,把未保留词元折进循环状态并同步学一个轻量写时路由器,收益远大于事后删缓存。
- 搭新一代长上下文混合架构时,试试全局池化预算与极简抽样蒸馏:不必再靠手工网格搜索 1 还是 1 的注意力层比例,把软压缩预算铺到全网所有层和 KV 组上,每条序列只需抽 1 到 10 个查询就能低成本训出按词路由,而且在双路路由模块里别惯性照搬 SSM 的短卷积。 同时认清当前适用边界:Ark 在长文档单次问答、聚合与带宽受限的 64K 解码上优势突出;如果你的业务重度依赖超密集多键键值表检索,短期内还需期待“Ark 按词路由 + Delta 规则循环更新”的结合体。