arXiv:2606.06302cs.LGcs.SE2026-06被引 1

Tangram通过静态分配注意力头缓存,让多轮大模型推理更快更省内存。

Tangram: Unlocking Non-Uniform KV Cache Compression for Efficient Multi-turn LLM Serving

  • 提前静态分配各注意力头的缓存大小,避免运行时动态调整
  • 压缩后吞吐量最高提升2.6倍,比全量缓存快近3倍
  • 适合需要高并发、低延迟的在线大模型服务场景

多轮大模型服务中,对话历史积累导致键值(KV)缓存随轮次和用户数量持续增长,迅速超过模型权重本身,使内存成为吞吐量的主要瓶颈。非均匀KV压缩通过为不同注意力头分配异构预算,相比均匀方案显著提升精度,但难以实用:现代服务架构假设所有头的缓存长度一致,异构性引发页面碎片化,导致高达25%的预填充时间用于回收零散页面,且负载不均使解码延迟最高增加1.7倍,或每步解码消耗15–20%时间用于重规划。我们发现这种异构性无需运行时发现:头级保留率具有两层结构规律——输入无关的头排名与极窄的每头比例范围——仅需50个样本即可离线校准。基于此,我们提出Tangram,一个服务框架,静态解决以往系统动态处理的问题:预算预留(Budget Reservation)在调度时固定各头压缩后容量,消除页面回收;稀疏分页(Ragged Paging)将相似预算的头聚类到独立页表,把碎片化转为可回收内存;事前负载均衡(Ahead-of-Time Load Balancing)预先计算平衡的GPU分区,实现零运行时规划。在vLLM上实现的Tangram作为现有非均匀压缩方法的即插即用底层,保持相同精度的同时,端到端吞吐量相比全量缓存基准最高提升2.6倍。代码已公开于https://github.com/aiha-lab/TANGRAM。

原文摘要 · Abstract (English)

Multi-turn LLM serving accumulates dialogue history whose Key-Value (KV) cache grows with every turn and every user, quickly exceeding the model weights themselves and making memory -- not compute -- the binding constraint on throughput. Non-uniform KV compression, which allocates heterogeneous budgets across attention heads, preserves accuracy far better than uniform schemes, yet remains impractical: modern serving stacks assume identical KV lengths across heads, so heterogeneity traps freed memory as page fragmentation, spends up to 25% of prefill time reclaiming scattered pages, and skews GPU workloads that inflate decode latency by up to $1.7\times$ or burn 15--20% of each decode step on re-planning. We observe that this heterogeneity need not be discovered at runtime: head-wise retention follows a two-level structural regularity -- an input-invariant head ranking with narrowly bounded per-head ratios -- that can be calibrated offline from as few as 50 samples. Building on this insight, we present Tangram, a serving framework that statically resolves what prior systems handle dynamically: Budget Reservation fixes each head's post-compression footprint at scheduling time, eliminating page reclamation; Ragged Paging clusters similar-budget heads into independent page tables, turning fragmentation into reclaimable memory; and Ahead-of-Time Load Balancing precomputes balanced GPU partitions with zero runtime planning. Implemented on vLLM, Tangram serves as a drop-in substrate for existing non-uniform compression methods, matching their accuracy while improving end-to-end throughput by up to $2.6\times$ over the full-KV baseline. Our implementation is publicly available at https://github.com/aiha-lab/TANGRAM.

大模型推理内存优化非均匀压缩KV缓存

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。