arXiv cs.LG论文
Twig:面向混合注意力大模型的并行且内存高效的树状推测解码方法
针对混合注意力LLM中线性注意力层状态依赖导致的树状推测解码效率瓶颈,提出Twig内核-运行时协同设计方案。通过树结构因子化实现节点并行验证,加速3.4-7.7倍;利用Token级因子表示状态更新,减少82-99倍瞬态内存占用。集成至SGLang后,离线吞吐量达自回归的4.72倍,在线Agent工作负载下TTFT和TPOT分别降低67.6%和49.9%。
这篇是正式发表的长论文,站内提供中文解读,全文请到原文阅读 PDF。
Abstract:Emerging LLMs increasingly interleave full attention with recurrent linear attention to reduce long-context serving costs. Tree speculative decoding could further accelerate these hybrid models, but recurrent linear-attention layers carry parent-dependent states. Existing engines therefore verify proposal trees sequentially and snapshot the full state per node, causing latency and memory to grow with tree and batch sizes. We present Twig, a kernel--runtime co-design for tree speculative decoding of hybrid LLMs. Twig derives a tree-structured factorization of the linear-attention recurrence and realizes it with a resource-efficient GPU kernel that verifies all nodes in parallel, accelerating linear-attention tree verification by 3.4--7.7$\times$. It losslessly represents speculative state updates as token-level factors and reconstructs only the accepted state, reducing transient state memory by 82--99$\times$ and freeing GPU memory for KV caches. We integrate Twig into SGLang, a widely deployed production LLM serving engine, and further optimize its runtime through batch-wide verification budgeting. Across four models, two GPU platforms, and diverse datasets, Twig achieves up to $4.72\times$ the offline decode throughput of autoregressive decoding and up to $2.03\times$ that of the strongest tree-speculative baseline. Under online agent workloads, Twig reduces TTFT and TPOT by up to $67.6\%$ and $49.9\%$, respectively, over the strongest tree-speculative baseline.