Mixture-of-Top-$k$ Attention: Efficient Attention via Scalable Fast Weights
Qishuai Wen ⋅ Zhiyuan Huang ⋅ meng xianghan ⋅ Wei He ⋅ CHUNGUANG LI
Abstract
The vanilla self-attention in Transformers can be viewed as a two-layer fast-weight MLP, where the weights are dynamically induced by inputs and the hidden dimension is equal to the sequence length $N$. As the context length grows, the expressive capacity of such an $N$-width MLP increases, but it becomes unscalable for extremely long sequences. Recently, this fast-weight perspective has motivated the Mixture-of-Experts (MoE) attention mechanism, which partitions the sequence into rigid blocks, treats them as fast-weight experts, and sparsely routes the tokens to these experts. In this paper, we elevate this perspective into a unifying framework for efficient attention, interpreting existing methods as making fast weights scalable via routing and/or compression, and organizing them into a five-dimensional taxonomy. Then, we propose \textbf{Mi}xture-of-\textbf{T}op-$k$ \textbf{A}ttention (\textbf{MiTA}), which uses a small set of landmark queries to collect top-$k$ attended key-value pairs as query-aware and deformable routed experts, while compressing the $N$-width MLP into a narrower shared expert. Consequently, MiTA improves the flexibility of prior MoE attention (from rigid to deformable fast-weight experts) and the scalability of prior top-$k$ attention (from query-specific sets to reusable top-$k$ sets). Extensive experiments on vision tasks demonstrate that MiTA achieves superior effectiveness and efficiency, and reveal intriguing properties such as an emergent token-pruning effect and strong generalization from standard attention. Code is available at \href{https://github.com/QishuaiWen/MiTA}{https://github.com/QishuaiWen/MiTA}.
Successful Page Load