LeanSparse: Memory-Efficient Serving for Native Sparse-Attention LLMs

Zaifeng Pan, Chris Wu, Xinwei Qiang, Zhengding Hu, Zhongkai Yu, Yufei DingarXiv 2026

TL;DR

LeanSparse is a memory-efficient serving system designed for native sparse-attention LLMs (like DeepSeek-V4) that enables processing massive contexts up to 1M tokens. By implementing layer-wise prefill streaming and a coarse-to-fine indexing strategy for decoding, it achieves nearly 3x higher request concurrency and reduces median Time to First Token (TTFT) from 21.6 seconds to just 0.6 seconds.

What Problem Does This Paper Address?

As Large Language Models (LLMs) move toward million-token context windows, GPU memory (HBM) has become the primary bottleneck. Native sparse-attention models attempt to solve this by only attending to a small, learned subset of historical tokens. However, existing serving systems face two major hurdles:

  1. Persistent Indexer Residency: Even if the actual Key-Value (KV) cache is offloaded to host RAM, the "indexer keys"—used by the model to decide which tokens to attend to—typically remain on the GPU. As shown in Figure 1, at 512K tokens, these indexer keys can occupy 7.2x more space than the active KV buffer, severely limiting how many requests a GPU can handle simultaneously.
  2. Prefill Memory Spikes: The prefill phase (processing the initial prompt) requires significant temporary memory. In shared environments, a new request often has to wait for existing decoding tasks to finish and release memory before it can even start prefilling, leading to massive delays in responsiveness.
Figure 1. Indexer key storage grows with context length. Per- request memory of one CSA layer in HiSparse: FP8 indexer keys versus the fixed hot KV buffer.

Methods

LeanSparse introduces two primary architectural innovations to break these bottlenecks:

1. Layer-wise Prefill Streaming

Instead of keeping a request's entire prefix history in GPU memory during prefill, LeanSparse recognizes that the model processes data one layer at a time. The system uses a double-buffering approach: while the GPU computes one layer using "Buffer A," it simultaneously streams the next layer's prefix data from host memory into "Buffer B." This overlaps data transfer with computation, keeping the memory footprint constant regardless of the number of layers.

2. Coarse-to-Fine Decode Indexing

To avoid keeping all indexer keys on the GPU during decoding, LeanSparse uses a two-stage search:

  • Coarse Pass: It stores highly compressed versions of indexer keys on the GPU using Product Quantization (PQ). This reduces the memory footprint of the indexer history by roughly 4x (e.g., from 132 bytes to 32 bytes per entry). The system performs a fast search on these compact codes to identify a set of promising candidates.
  • Fine Pass: It fetches the original, full-precision indexer keys from host memory only for these candidates to perform an exact reranking.

To make this efficient, LeanSparse maintains separate, fixed-size GPU caches for both indexer keys and KV entries, exploiting the fact that successive decoding steps often attend to overlapping sets of tokens.

Figure 5. System overview of LeanSparse. Host memory stores the full history of indexer keys and compressed KV. GPU memory holds two reusable history buffers during prefill, and compact PQ codes with separate indexer key and KV caches during decode.

Datasets

The authors evaluated LeanSparse using:

  • DeepSeek-V4-Flash: A state-of-the-art native sparse-attention model.
  • NVIDIA Open-SWE-Traces: 128 long-context multi-turn sessions used to measure real-world serving performance.
  • LongSWE-Bench: Used to construct synthetic contexts ranging from 200K to 950K tokens for stress-testing throughput.
  • Accuracy Benchmarks: GSM8K (reasoning), Multi-key Needle-in-a-Haystack (retrieval), LongBench v2 (understanding), and OpenAI MRCR (coreference resolution).

Key Insights and Ideas

  • Decoupling Indexing from Attention: The core "aha moment" is treating the indexer keys and the KV cache as separate entities with different lifecycle requirements. By compressing the indexer keys, you can keep the "search map" of a million-token history on-device while offloading the heavy data.
  • Hiding Latency via Pipelining: The prefill bottleneck isn't just about total capacity; it's about timing. By streaming layers, LeanSparse allows prefill to start almost immediately, even when the GPU is nearly full of decoding requests.
  • Approximation is Sufficient for Filtering: You don't need perfect accuracy when searching the history; you just need a high "recall." As long as the true top tokens are in the candidate set, the second "fine" pass will fix the ranking.

Key Results

LeanSparse was compared against state-of-the-art baselines like HiSparse and ECHO on NVIDIA H100 GPUs:

  • Concurrency: At 950K context length, LeanSparse supports 2.95x as many concurrent requests as HiSparse.
  • Throughput: It achieves 2.14x higher decode throughput at the same 950K context limit.
  • Responsiveness: In multi-turn scenarios, median TTFT dropped by 97.2% (from 21.6s to 0.6s) because requests no longer had to wait for massive memory blocks to clear.
  • Accuracy: The system maintains model quality, with scores on benchmarks like GSM8K and NIAH remaining within 0.5% of the unoptimized baseline.

Limitations and Future Work

While LeanSparse significantly pushes the boundaries of long-context serving, some limitations remain:

  • Linear Growth: Although the memory per token is reduced, the PQ-compressed indexer keys still grow linearly with context length. Eventually, even these will exhaust GPU memory.
  • Coarse Pass Overhead: At shorter context lengths (e.g., 200K), the overhead of the coarse-to-fine screening can slightly increase step time compared to simple exact scoring.
  • Future Directions: The authors suggest exploring more aggressive compression or hierarchical indexing structures to scale beyond the 1M token mark.

For more details, you can find the full paper at arXiv:2611.04671v1.

Summary updated

Abstract

Sparse attention limits the history read by each query, but serving long contexts still requires substantial GPU memory. Existing KV offloading systems retain the full history of indexer keys on GPU, limiting decode concurrency. Prefill's temporary memory demand can further delay admission even when enough memory remains for the same request's subsequent decode. We present LeanSparse, a serving system that reduces both decode's persistent memory use and prefill's temporary memory demand. Our design exploits two observations: prefill consumes historical data one layer at a time, and decode can identify promising candidates before comparing their original indexer scores. During prefill, LeanSparse streams layer histories through two reusable GPU buffers, overlapping next-layer loading with ongoing model computation. During decode, coarse-to-fine indexing searches compact representations and retrieves original indexer keys only for candidate refinement. Separate indexer key and KV caches reuse data across generation steps. We implement LeanSparse in SGLang and evaluate it on DeepSeek-V4-Flash. At 950K context length, LeanSparse supports 2.95$\times$ as many concurrent requests and achieves 2.14$\times$ decode throughput over HiSparse. On multi-turn Open-SWE traces, it reduces median time to first token from 21.6 to 0.6s and median session completion time by 17.7% relative to ECHO.
BibTeX
@misc{pan2026leansparse,
  author = {Zaifeng Pan and Chris Wu and Xinwei Qiang and Zhengding Hu and Zhongkai Yu and Yufei Ding},
  title = {{LeanSparse: Memory-Efficient Serving for Native Sparse-Attention LLMs}},
  year = {2026},
  eprint = {2611.04671},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.04671},
}
Figure