提出首个面向状态空间模型的树形推测解码算法,显著提升推理速度。
STree: Speculative Tree Decoding for Hybrid State-Space Models
- 利用状态转移矩阵结构实现低开销树形推测解码
- 在三个基准上超越基础推测解码,加速效果明显
- 适合追求高效推理的SSM及混合架构研究者
推测解码通过利用硬件并发性,在单次前向传播中生成多个词元,从而提升大规模自回归Transformer模型的效率。状态空间模型(SSMs)本身比自回归Transformer更高效,因其状态能总结所有历史信息,无需缓存或重复处理滑动窗口中的词元。然而,其状态可能包含数千个词元;因此,推测解码最近被扩展至SSMs。现有方法未利用基于树的验证机制,因为当前SSM缺乏高效计算词元树的能力。本文提出首个可扩展的树形推测解码算法,适用于状态空间模型及SSM与Transformer层的混合架构。我们利用累积状态转移矩阵的结构,以极小开销实现树形推测解码,相较于现有SSM实现仅增加少量开销。同时,给出一个面向硬件优化的实现方案,改进了将AR Transformer的树形推测方法直接应用于SSM的笨拙做法。实验表明,即使使用基础草稿模型和树结构,该方法在三个不同基准上仍优于原始推测解码,为SSM及混合模型推理提速开辟新路径。代码已开源:https://github.com/wyc1997/stree。
原文摘要 · Abstract (English)
Speculative decoding is a technique to leverage hardware concurrency in order to enable multiple steps of token generation in a single forward pass, thus improving the efficiency of large-scale autoregressive (AR) Transformer models. State-space models (SSMs) are already more efficient than AR Transformers, since their state summarizes all past data with no need to cache or re-process tokens in the sliding window context. However, their state can also comprise thousands of tokens; so, speculative decoding has recently been extended to SSMs. Existing approaches, however, do not leverage the tree-based verification methods, since current SSMs lack the means to compute a token tree efficiently. We propose the first scalable algorithm to perform tree-based speculative decoding in state-space models (SSMs) and hybrid architectures of SSMs and Transformer layers. We exploit the structure of accumulated state transition matrices to facilitate tree-based speculative decoding with minimal overhead relative to current SSM implementations. Along with the algorithm, we describe a hardware-aware implementation that improves naive application of AR Transformer tree-based speculative decoding methods to SSMs. Furthermore, we outperform vanilla speculative decoding with SSMs even with a baseline drafting model and tree structure on three different benchmarks, opening up opportunities for further speed up with SSM and hybrid model inference. Code can be found at: https://github.com/wyc1997/stree.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。