Serving long-context LLMs is costly because attention computation grows linearly with context length. Dynamic sparse attention algorithms (DSAs) mitigate this by attending only to the key-value (KV) cache of critical tokens. However, with DSAs, the main performance bottleneck shifts from HBM bandwidth to HBM capacity: KV caches for unselected tokens must remain in HBM for low-latency decoding, constraining parallel batch size and stalling further throughput gains. Offloading these underutilized KV caches to DRAM could free HBM capacity, allowing larger parallel batch sizes. Yet, achieving such hierarchical HBM-DRAM storage raises new challenges, including fragmented KV cache access, HBM cache contention, and high HBM demands of hybrid batching, that remain unresolved in prior work. This paper proposes SparseServe, an LLM serving system that unlocks the parallel potential of DSAs through efficient hierarchical HBM-DRAM management. SparseServe introduces three key innovations to address the challenges mentioned above: (1) fragmentation-aware KV cache transfer, which accelerates HBM-DRAM data movement through GPU-direct loading (FlashH2D) and CPU-assisted saving (FlashD2H); (2) working-set-aware batch size control that adjusts batch sizes based on real-time working set estimation to minimize HBM cache thrashing; (3) layer-segmented prefill that bounds HBM use during prefill to a single layer, enabling efficient execution even for long prompts. Extensive experimental results demonstrate that SparseServe achieves up to 9.26x lower mean time-to-first-token (TTFT) latency and up to 3.14x higher token generation throughput compared to state-of-the-art LLM serving systems.
翻译:服务长上下文大语言模型(LLM)的成本高昂,因为注意力计算随上下文长度线性增长。动态稀疏注意力算法(DSA)通过仅关注关键令牌的键值(KV)缓存来缓解此问题。然而,采用DSA后,主要性能瓶颈从高带宽内存(HBM)带宽转移到了HBM容量:未选中令牌的KV缓存必须保留在HBM中以实现低延迟解码,这限制了并行批处理大小并阻碍了吞吐量的进一步提升。将这些未充分利用的KV缓存卸载到动态随机存取存储器(DRAM)可以释放HBM容量,从而允许更大的并行批处理规模。然而,实现这种分层的HBM-DRAM存储带来了新的挑战,包括碎片化的KV缓存访问、HBM缓存争用以及混合批处理的高HBM需求,这些在先前工作中仍未得到解决。本文提出了SparseServe,一个通过高效的分层HBM-DRAM管理来解锁DSA并行潜力的LLM服务系统。SparseServe引入了三项关键创新来解决上述挑战:(1)碎片感知的KV缓存传输,通过GPU直接加载(FlashH2D)和CPU辅助保存(FlashD2H)加速HBM-DRAM间的数据移动;(2)工作集感知的批处理大小控制,基于实时工作集估计调整批处理大小,以最小化HBM缓存抖动;(3)层分段预填充,将预填充阶段的HBM使用限制在单个层内,即使对于长提示也能实现高效执行。大量实验结果表明,与最先进的LLM服务系统相比,SparseServe实现了高达9.26倍的首令牌平均时间(TTFT)延迟降低和高达3.14倍的令牌生成吞吐量提升。