[论文解读] SpecExec: Massively Parallel Speculative Decoding for Interactive LLM Inference on Consumer Devices
SpecExec 提出了一种大规模并行推测解码方法,通过利用强大的推测模型构建高覆盖率的推测树,并在目标模型上单次前向传播中验证该树,实现了在消费级 GPU 上通过内存卸载运行 500 亿参数以上大语言模型的交互式推理。该方法在 4 位量化下实现 4–6 个 token/秒,在 16 位权重下实现 2–3 个 token/秒,相比串行推理实现了 10–18 倍的加速。
As large language models gain widespread adoption, running them efficiently becomes crucial. Recent works on LLM inference use speculative decoding to achieve extreme speedups. However, most of these works implicitly design their algorithms for high-end datacenter hardware. In this work, we ask the opposite question: how fast can we run LLMs on consumer machines? Consumer GPUs can no longer fit the largest available models (50B+ parameters) and must offload them to RAM or SSD. When running with offloaded parameters, the inference engine can process batches of hundreds or thousands of tokens at the same time as just one token, making it a natural fit for speculative decoding. We propose SpecExec (Speculative Execution), a simple parallel decoding method that can generate up to 20 tokens per target model iteration for popular LLM families. It utilizes the high spikiness of the token probabilities distribution in modern LLMs and a high degree of alignment between model output probabilities. SpecExec takes the most probable tokens continuation from the draft model to build a "cache" tree for the target model, which then gets validated in a single pass. Using SpecExec, we demonstrate inference of 50B+ parameter LLMs on consumer GPUs with RAM offloading at 4-6 tokens per second with 4-bit quantization or 2-3 tokens per second with 16-bit weights.
研究动机与目标
- 在显存有限且内存带宽受限的消费级 GPU 上,实现对大尺寸 500 亿参数以上大语言模型的交互式推理。
- 解决现有推测解码方法在将大模型卸载到 CPU 内存时可扩展性差且接受率低的问题。
- 设计一种推测解码框架,在高达 2048 个推测 token 的预算下最大化 token 接受率,同时保持对不同模型家族和硬件配置的灵活性。
- 证明推测解码可在带宽受限的消费级硬件上被有效利用,以实现交互式推理速度。
- 提供一个实用、开源的系统,使用户能够在消费设备上实现本地化、私密且高效的大型语言模型推理。
提出的方法
- SpecExec 使用强大的推测模型和并行搜索算法,构建一个大规模、确定性的推测树,以探索最可能的 token 续接。
- 它利用现代大语言模型中概率分布的高稀疏性和对齐特性,构建类似缓存的树结构,用于推测验证。
- 目标模型在单次前向传播中并行验证整个推测树,一次性接受所有有效 token 序列。
- 该方法采用一种简单的验证算法,将推测树视为预计算的候选续接缓存,最大限度减少冗余计算。
- 系统根据模型的概率分布和硬件约束,动态调整推测树的深度与广度,确保高接受率。
- 该系统与卸载框架集成,高效管理 GPU 与 CPU 内存之间的模型权重传输,最小化带宽瓶颈。
实验结果
研究问题
- RQ1在带宽受限的消费级硬件上,当推测 token 数量扩展到数千个时,推测解码能否实现高接受率?
- RQ2如何优化推测树的构建,以在兼容卸载到消费级 GPU 的大语言模型推理的前提下,最大化 token 接受率?
- RQ3在使用推测解码并配合内存卸载的消费级 GPU 上,500 亿参数以上大语言模型的可实现推理速度是多少?
- RQ4SpecExec 的性能与现有推测解码方法相比如何,特别是在卸载场景下的加速比与可扩展性方面?
- RQ5SpecExec 是否能在配备 4 位量化或 16 位权重模型的消费级硬件上实现交互式大语言模型推理(≥2 个 token/秒)?
主要发现
- SpecExec 在 4 位量化 500 亿参数以上大语言模型的消费级 GPU 上实现了 4–6 个 token/秒,支持交互式推理。
- 在 16 位权重下,SpecExec 在相同硬件上实现 2–3 个 token/秒,相比串行推理仍实现 10–18 倍加速。
- 该方法每轮目标模型前向传播最多可接受 20 个 token,显著优于以往方法约 10 个 token 的限制。
- 在 RTX 4090 上,SpecExec 使用 4 位量化 Llama2-70B 目标模型时达到 5.66 个 token/秒,展现出在高端消费级硬件上的强劲性能。
- 即使在较旧的消费级 GPU 如 RTX 2080Ti 上,SpecExec 仍实现 1.86 个 token/秒,表明其在广泛设备上的可行性。
- SpecExec 在性能上优于固定树结构的推测解码方法(如 Sequoia),后者在类似设置下仅实现 2.2 个 token/秒。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。