DisSparse: Pipelined Top-$p$ Sparse Attention for Long-Context LLM Serving

Nurlan Nazaraliyev, Elaheh Sadredini, Nael Abu-Ghazaleh

TL;DR

Serving long-context Large Language Models (LLMs) is heavily bottlenecked by the memory footprint of the conversation history (the KV cache). While skipping unimportant words saves memory, production systems typically use rigid "top-$k$" rules—grabbing a fixed number of memory blocks—because dynamic, probability-based "top-$p$" selection is slow and breaks static memory allocators. DisSparse solves both problems through an algorithm-system co-design inside vLLM, allowing LLMs to adaptively fetch just enough context per step while supporting up to 8× larger batch sizes without sacrificing accuracy.

What Problem Does This Paper Address?

When an LLM processes a massive document or long conversation, it stores past token representations in a Key-Value (KV) cache in fast GPU memory. As context grows to hundreds of thousands of tokens, simply reading and storing this cache chokes memory capacity and bandwidth.

Dynamic sparse attention relieves this bottleneck by attending only to the most relevant tokens for a given query. In production engines like vLLM, the standard approach is top-$k$ selection: picking a fixed number ($k$) of KV cache blocks. Systems love top-$k$ because $k$ is predictable—the scheduler knows exactly how much memory to reserve before the math even begins.

Nature, however, doesn't care about our schedulers. Attention patterns vary wildly across layers, heads, and generation steps:

Figure 1: Llama-3.1-8B-Instruct [47] on NarrativeQA from LongBench [12]: critical token counts per layer per decode step vary substantially, showing why fixed-k budgets are mismatched. Results on other models are in Appendix A.

A fixed $k$ wastes bandwidth when attention is laser-focused on a few words, and drops vital context when attention is spread thin. Top-$p$ (nucleus) selection—fetching just enough tokens to reach a cumulative probability threshold $p$ (say, 95% of attention mass)—adapts naturally to this variation. Yet, top-$p$ has been practically exiled from production serving for two reasons:

  1. Selection is too slow: Existing top-$p$ methods rely on multi-pass binary searches over all tokens, which ends up taking longer than the attention calculation itself (up to 76% of layer execution time!).
  2. Unpredictable memory: You don't know how many blocks you need until after you compute the scores, breaking the deterministic pre-allocation that modern schedulers rely on.

Furthermore, because vLLM groups tokens into fixed-size pages (blocks), a single high-scoring token forces the system to load an entire block of mostly useless neighbors—an inefficiency the authors call intra-block sparsity.

Figure 2: Llama-3.1-8B-Instruct [47], Layer 0 on Long- BenchV2 [11]. Block-level top-p selects ∼2× more tokens than a token-level oracle to reach p = 0.95, mo- tivating the relocation kernel.

Methods

DisSparse integrates training-free top-$p$ sparse attention into a disaggregated vLLM setup (where initial prompt processing, or prefill, and token generation, or decode, run on separate GPUs) using four clever techniques:

  • Hybrid Block Allocation: Instead of forcing the central scheduler to guess how many blocks top-$p$ will pick, DisSparse splits the job. The scheduler handles predictable allocations (newly generated tokens and a tiny, 4-bit quantized INT4 replica of the key cache), while the GPU worker dynamically allocates temporary slots for full-precision FP16 blocks fetched from CPU memory at runtime.
  • Two-Stream Speculative Pipelining: Because consecutive LLM layers have remarkably similar hidden states (0.87–0.95 cosine similarity), DisSparse doesn't wait for layer $\ell$ to finish before figuring out what layer $\ell+1$ needs. One CUDA stream computes attention and feed-forward networks for layer $\ell$, while a second stream concurrently uses layer $\ell$'s state to run top-$p$ selection on the lightweight INT4 cache replica and prefetches the winning FP16 blocks for layer $\ell+1$.
  • Single-Pass Histogram Top-$p$ Kernel: Rather than running expensive multi-pass binary searches, DisSparse computes per-block log-sum-exp scores on the INT4 cache. If the top 8 blocks already hit threshold $p$, it takes a fast exit. Otherwise, it buckets the remaining log-probabilities into a 64-bin register histogram in a single pass to find the cutoff threshold.
  • Banded Token Relocation: Right after prefill, DisSparse sums up the attention each token received and physically reorders the KV cache so important tokens share early blocks. Crucially, instead of a naive global sort—which scrambles chronological order—it groups tokens into coarse importance "bands" (4,096 tokens wide) and restores chronological order within each band.

Datasets

DisSparse is training-free and evaluated across existing long- and medium-context benchmarks (no new datasets are introduced):

  • Long-context understanding: LongBench (12 tasks) and LongBenchV2 (up to 32K–64K tokens).
  • Retrieval: RULER (11 needle-in-a-haystack style subtasks at 16K and 32K context).
  • Medium-context reasoning, QA, and perplexity: GSM8K, COQA, and PG-19.

Key Insights and Ideas

  • Top-$k$'s dominance is a systems artifact, not an algorithmic victory. Fixed budgets fail dramatically on diffuse-attention tasks (e.g., Quest-128 drops GSM8K accuracy from 0.78 to 0.40 on Llama-3.1-8B), whereas adaptive top-$p$ preserves full-attention quality.
  • Pure sorting breaks attention locality; banded sorting saves it. Grouping high-value prefill tokens together cuts down wasted block fetches, provided you maintain local chronological sequences within importance tiers. And because Rotary Position Embeddings (RoPE) are baked into keys before caching, moving tokens around in memory doesn't corrupt their positional meaning!
  • 4-bit keys + histograms are plenty accurate for routing. Using an 8× smaller INT4 key cache with a 64-bin histogram achieves $\ge 97\%$ recall compared to exact FP16 sorting.

Key Results

Evaluated across six models (including Llama-3.1-8B, Qwen2.5-7B, LongChat-7B, and Phi-3-mini):

  • System Throughput & Capacity: Under identical GPU memory budgets (two 40GB A100s), DisSparse supports 8× larger batch sizes on Llama-3.1-8B (batch 32 vs. 4) and 4× larger on Phi-3-mini (batch 8 vs. 2), yielding 2× to 2.5× higher peak throughput than dense vLLM.
  • Kernel Speedup: DisSparse's selection analyzer is 1.17× to 1.80× faster than Twilight (the state-of-the-art top-$p$ baseline).
  • Accuracy: Matches dense attention within $\pm 0.5\%$ on Llama-3.1-8B LongBench, hits 100% single-needle retrieval on RULER, and actually beats dense attention by +4.7% on LongChat-7B (likely by filtering out distracting low-attention noise).
  • Relocation Savings: Banded token relocation reduces the number of fetched blocks by 7.6% to 14.1% while maintaining or slightly improving benchmark scores (up to +3.03 points on LongBenchV2).

Limitations and Future Work

  • Small-batch latency overhead: At very small batch sizes, dense vLLM has ~1.5× faster time-per-output-token (TPOT). This happens because DisSparse's two-stream pipeline is currently incompatible with vLLM's single-stream CUDA Graph capture, leaving kernel launch overheads exposed. Implementing multi-stream CUDA Graph capture is a clear next step.
  • Missing coarse page filtering in end-to-end vLLM: While tested in isolated kernel benchmarks, the full vLLM integration does not yet include a Quest-style first-stage filter, meaning the selection stream currently runs a matrix-vector multiply over the entire INT4 cache replica. Adding hierarchical filtering would further trim selection latency at ultra-long contexts.

Summary updated

Abstract

Long-context LLM inference is bottlenecked by the memory demands of the key-value (KV) cache, whose size scales linearly with context length. Dynamic sparse attention reduces this bottleneck by fetching and attending only to a critical subset of tokens. The dominant primitive in dynamic sparse attention research and deployment is fixed-budget top-$k$ selection, which is favored because its deterministic block count aligns with the static memory allocation that systems like vLLM rely on. Top-$k$ uses a fixed budget regardless of how attention mass is distributed across heads, layers, and decode steps, leading to either wasted bandwidth on heads with peaky attention or dropped context on heads with diffuse attention. Top-$p$ (nucleus) selection adapts naturally to this variation but has seen limited adoption in production serving systems due to two system-level challenges: variable block counts that break deterministic block allocation and computationally expensive selection kernels that exceed the cost of attention itself. We present DisSparse, a serving system that integrates top-$p$ sparse attention into vLLM end-to-end. DisSparse decouples block selection from the scheduler's critical path, hides selection latency behind layer computation via a two-stream pipeline, and introduces a single-pass histogram-based top-$p$ kernel. We further observe \emph{intra-block sparsity}, the inflation of selection budgets caused by mixing high- and low-importance tokens within fixed-size KV cache blocks, and address it with a token relocation kernel guided by accumulated prefill attention scores. Across long- and medium-context benchmarks on multiple models, DisSparse achieves 1.17$\times$ to 1.80$\times$ speedup in sparsity analysis (block selection) over state-of-the-art top-$p$ methods with negligible accuracy loss and supports up to 8$\times$ larger maximum batch sizes than dense vLLM under the same memory budget. Code is available at https://github.com/nnurlan008/DisSparse.
BibTeX
@inproceedings{nazaraliyev2026dissparse,
  author = {Nurlan Nazaraliyev and Elaheh Sadredini and Nael Abu-Ghazaleh},
  title = {{DisSparse: Pipelined Top-$p$ Sparse Attention for Long-Context LLM Serving}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=zcxTKrFsxv},
}
Figure