Pipelined Top-p Sparse Attention for Long-Context LLM Serving — NeurIPS 2026
Nurlan Nazaraliyev, Elaheh Sadredini, Nael Abu-Ghazaleh — University of California, Riverside
Long-context decoding is bound by reading the KV cache. Sparse attention reads only the tokens that matter, but how many tokens matter changes from head to head, layer to layer and step to step. Top-p (nucleus) selection adapts to that; top-k cannot. Top-p has stayed out of serving systems for two reasons: its block count is unknown until selection finishes, which breaks the fixed memory allocation that engines like vLLM rely on, and its selection kernels can cost more than attention itself.
DisSparse makes top-p practical in vLLM:
- Selection off the scheduler's critical path. The scheduler allocates blocks only for new tokens; the model executor allocates the blocks each step's top-p selection fetches.
- A two-stream pipeline. Top-p selection and prefetch for layer ℓ+1 run on one CUDA stream while layer ℓ computes on another, using the similarity of consecutive layers' hidden states.
- Single-pass histogram top-p on an INT4 key cache. An INT4 GEMV kernel scores the cache, then a histogram kernel finds the top-p threshold in one pass instead of a multi-pass search.
- Token relocation. Tokens that received the most attention during prefill are gathered into the first KV blocks, so block-level top-p reaches the same attention mass with fewer blocks.
Up to 8× larger batches than dense vLLM under the same GPU memory. On two A100-40GB GPUs (disaggregated prefill/decode), dense vLLM runs out of memory at batch 4 for Llama-3.1-8B and batch 2 for Phi-3-mini; DisSparse serves batch 32 and 8, with 2× and 2.5× higher peak throughput.
1.17×–1.80× faster selection than Twilight, the state-of-the-art top-p method, with the same Quest first stage (A100, Llama-3.1-8B layer, p = 0.95):
Dense-level accuracy from a small fraction of the cache. Average over 12 LongBench tasks:
| Model | Full attention | Quest + Twilight | DisSparse | DisSparse budget |
|---|---|---|---|---|
| LongChat-7B-v1.5-32k (p = 0.85) | 36.10 | 37.33 | 37.79 (+4.7%) | 170 tokens |
| Llama-3.1-8B-Instruct (p = 0.95) | 52.01 | 52.00 | 52.20 (+0.4%) | 610 tokens of up to 128K |
- On PG-19, fixed-budget Quest-128 reaches perplexity 79.23 on Llama-3.1-8B; DisSparse stays at the dense 11.28.
- On 11 RULER subtasks at 16K and 32K, every sparse configuration is within 0.8 points of full attention.
- INT4 + histogram selection recovers ≥ 97% of the blocks chosen by exact FP16 top-p.
- Token relocation reduces the blocks needed to reach p = 0.95 by 7.2–14.1% across three models, without hurting accuracy.
All numbers are from the paper; see Section 5 and Appendix B for the full tables.
Requirements: Linux, an NVIDIA GPU, Python ≥ 3.10, a CUDA build of PyTorch ≥ 2.4 with the matching CUDA
toolkit (nvcc), and git.
git clone https://github.com/nnurlan008/DisSparse.git
cd DisSparse
bash install.shinstall.sh installs the dissparse package (pip install -e ".[bench]"), compiles the two CUDA kernels,
and fetches the Twilight baseline used in Figure 9. Use bash install.sh --no-baseline to skip the baseline.
To compile for GPUs other than the one in the machine, set TORCH_CUDA_ARCH_LIST (for example "8.0;8.9;9.0").
Check the kernels against the PyTorch reference:
python tests/test_kernels.pyimport torch
from dissparse import int4_blocklse_topp, int4_token_topp, quantize_int4_per_token, pack_int4
# one decode step: q [batch, query heads, 128], key cache [batch, KV heads, seq, 128]
q = torch.randn(1, 32, 128, device="cuda", dtype=torch.float16)
k = torch.randn(1, 8, 32768, 128, device="cuda", dtype=torch.float16)
codes, scales, mins = quantize_int4_per_token(k) # the INT4 metadata cache (kept next to the FP16 cache)
packed = pack_int4(codes) # two 4-bit codes per byte
# block level: which 16-token KV blocks to fetch to cover 95% of the attention mass
block_mask = int4_blocklse_topp(q, packed, scales, mins, top_p=0.95) # [1, 32, 2048] int8
# token level
token_mask, scores = int4_token_topp(q, packed, scales, mins, top_p=0.95) # [1, 32, 32768] uint8Both functions accept an optional candidate mask (for example a Quest selection); top-p is then computed
over the candidates only. Token relocation is in dissparse/relocation.py.
| Path | |
|---|---|
csrc/ |
CUDA kernels: int4_blocklse_topp.cu (Algorithm 1), int4_token_topp.cu (Algorithm 3) |
dissparse/ |
Python package: kernel bindings (ops.py), PyTorch reference (reference.py), token relocation (relocation.py) |
tests/ |
kernel vs. reference checks |
benchmarks/fig9_selection_latency/ |
Figure 9: benchmark, plot script, and our measured results |
baselines/twilight/ |
script that fetches the Twilight baseline from upstream (no Twilight code is stored here) |
vllm/ |
vLLM integration (coming soon) |
@inproceedings{nazaraliyev2026dissparse,
title = {DisSparse: Pipelined Top-p Sparse Attention for Long-Context LLM Serving},
author = {Nazaraliyev, Nurlan and Sadredini, Elaheh and Abu-Ghazaleh, Nael},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
year = {2026}
}We compare against Twilight and use Quest-style page selection, the kernels of flash-topk-attention for the baseline, and FlashInfer headers to build them. This work was partially supported by the National Science Foundation and the Commonwealth Cyber Initiative.
Apache-2.0. See LICENSE.

