MoBA: Block-Level Sparse Attention at 95% Sparsity, Near-Lossless and Already Serving Kimi

MoBA: Mixture of Block Attention for Long-Context LLMs

Enzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du, Tao Jiang, Chao Hong, Shaowei Liu, Weiran He, Enming Yuan, Yuzhi Wang, Zhiqi Huang, Huan Yuan, Suting Xu, Xinran Xu, Guokun Lai, Yanru Chen, Huabin Zheng, Junjie Yan, Jianlin Su, Yuxin Wu, Neo Y. Zhang, Zhilin Yang, Xinyu Zhou, Mingxing Zhang, Jiezhong Qiu

cs.LG, cs.AI, cs.CL

2025-02-18

Moonshot ports mixture-of-experts into attention: each query picks top-k blocks of context, hitting 95% sparsity with near-zero loss and a 6.5x prefill speedup at 1M tokens. Already serving Kimi.

What problem this solves

Attention scales quadratically with context length. Once a model has to ingest million-token inputs, which is the direction Kimi, Claude and Gemini are all pushing, the compute bill for full attention gets ugly.

The two existing escape routes each snag. Static sparse attention (sliding window, attention sinks) hard-codes where the model should look; it saves compute but the pattern is fixed and often breaks when the task changes. The other route replaces attention entirely with a linear approximation (Mamba, RWKV), which brings complexity down but whose behaviour on complex reasoning is still unsettled.

MoBA takes a third path: keep the standard Transformer and full softmax attention, but let the model learn where to look instead of prescribing it. "Less structure" is the slogan.

Method

The idea is to port mixture-of-experts (MoE) into attention. Slice a context of length N into n blocks of B = N/n tokens. For each query token, a gate scores every block by relevance:

si = <q, meanpool(K of block i)>

the inner product of the query with the mean-pooled keys of that block. Take the top-k blocks and run standard softmax attention only over them.

A few design choices matter:

Sliding window and attention sinks are both special cases of MoBA under particular gates, so the authors argue MoBA is strictly more expressive.

Results

A caveat up front: in evaluation MoBA switches back to full attention for generation, so the 6.5x speedup is a prefill number, not end-to-end.

SettingMetricMoBAFull attention
8K context, 81.25% sparsevalidation loss gapwithin 1e-3 of full(baseline)
32K context, 95.31% sparsetrailing lossslightly higher, gap narrows with scale(baseline)
Llama-8B-1MMMLU0.49030.4904
Llama-8B-1MRULER @128K0.78180.7849

In the scaling-law runs (568M to 2.1B params), at 8K context and 81% attention dropped, MoBA stays within 1e-3 of full attention. Push to 32K and 95.31% sparsity and the trailing-token loss runs slightly higher, but the gap shrinks as the model grows.

The largest run continuously pretrains and fine-tunes Llama 3.1 8B to 1M tokens (block 4096, top-k=12, last 3 layers full). It matches its full-attention twin across 16 benchmarks, and needle-in-haystack holds at 1M tokens.

On efficiency, prefilling 1M tokens is up to 6.5x faster. Push to 10M tokens and attention compute drops to a sixteenth (achieved by extending tensor parallelism to the query-head level, broadcasting K/V across distributed heads to dodge the memory wall).

Why it matters

It is one of the few long-context sparse attention methods proven in production, already serving Kimi's long-context requests. Because it is a drop-in replacement, it slots into existing full-attention models without retraining the whole architecture from scratch.

For anyone building long-context applications, near-lossless sub-quadratic attention that handles millions to tens of millions of tokens is exactly the bottleneck. The layer-wise hybrid means you do not have to commit fully to sparsity.

A dose of scepticism: this is a Moonshot technical report. Every number comes from their own setup, there is no independent replication, and there is no head-to-head against other dynamic-sparse methods (Native Sparse Attention, Quest). The baseline is mainly their own full-attention twin.

Limitations

Terms

Source

What people are saying

Related papers

All paper explainers