MOIRA: Mass-Oriented Indexing with Ragged Attention for Long-Context Decoding
Long-context decoding is limited by memory bandwidth, because every output token must read the KV cache of every layer. Sparse decoding reduces this cost by reading only part of the KV cache, but the number of pages a query needs varies widely across KV heads, layers, and steps. Fixed budgets are simple, yet they are sized for demanding cases and tuned per workload; adaptive budgets follow this variation more flexibly, but existing designs pay for that flexibility with extra selection cost or training.
The kernel-level challenge is that FlashAttention-3 and FlashInfer are designed for rows of similar length. When page lists differ in length per KV head, these kernels either pad the lists and forfeit much of the sparse saving, leave thread blocks unbalanced, or rely on a host-side plan that runs outside the CUDA graph. MOIRA addresses this as a training-free sparse decode path in vLLM whose budget adapts per KV head and per layer. For every request, layer, KV head, and step, a coverage rule keeps the smallest set of pages whose estimated attention mass reaches a fraction gamma. A new kernel, self-planning attention, lets each thread block derive its own share of the work from the list lengths, so the whole decode step stays inside the CUDA graph.
On an H200 at RULER's 128k context, MOIRA with gamma=0.99 matches dense accuracy while reading about 30% of the pages and reduces time per output token (TPOT) by 2.2-2.5x relative to dense FA3. With gamma=0.98, it reduces TPOT by 2.7x and stays within the noise of dense. Under high serving load, it raises throughput by up to 51%.
These results suggest that a budget adapted per head and layer, paired with a kernel that keeps such budgets inside the CUDA graph, makes sparse decoding both flexible and fast.