Not Every Token Deserves Softmax

Avatar
Poster
Voice is AI-generated
Connected to paperThis paper is a preprint and has not been certified by peer review

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

Abstract

Softmax and linear attention sit at opposite ends of a memory tradeoff because they compare tokens with different kernels. The former uses an exponential kernel and caches every token, growing memory linearly with length; the latter uses a linear kernel, which factorizes so that the past compresses into a fixed-size recurrent state, at the cost of limited recall. In both cases the kernel is fixed, so neither adapts computation or memory to the input. We introduce Attention Routing Kernels (Ark), an architecture that chooses the kernel separately for each token, in every layer and KV group. A learned router sends each token to exactly one of two memories: tokens that need the exponential kernel stay in a KV cache, and the rest are folded into a fixed-size recurrent state. Every query reads both memories. The routing split governs cost: training combines a linear-time recurrent pass with pairwise attention over retained keys, while inference carries a fixed-size recurrent state plus the retained entries in the KV cache. Across 400M--2B parameters, Ark is competitive with Transformers and with hybrids that interleave softmax- and linear-attention layers, while storing about 90% and 25--53% less memory, respectively. Ark's smaller memory thus speeds up long-context decoding: at 64K, the 2B model is $1.8\times$ faster than a GLA hybrid and $3.8\times$ faster than FlashAttention-4. Code is available at https://github.com/goombalab/ark.

Follow Us on

0 comments

Add comment