Skip to main content
QUICK REVIEW

[论文解读] LLMCad: Fast and Scalable On-device Large Language Model Inference

Daliang Xu, Wangsong Yin|arXiv (Cornell University)|Sep 8, 2023
Topic ModelingComputer Science被引用 13
一句话总结

LLMCad 是一个在设备上推断引擎,它使用内存驻留的小型 LLM 来生成候选标记并由更大、准确的 LLM 来验证并纠正它们,在物联网设备上实现最高 9.3x 的标记生成速度提升,在智能手机上实现 3.5–4.7x 的提升,同时不牺牲准确性。

ABSTRACT

Generative tasks, such as text generation and question answering, hold a crucial position in the realm of mobile applications. Due to their sensitivity to privacy concerns, there is a growing demand for their execution directly on mobile devices. Currently, the execution of these generative tasks heavily depends on Large Language Models (LLMs). Nevertheless, the limited memory capacity of these devices presents a formidable challenge to the scalability of such models. In our research, we introduce LLMCad, an innovative on-device inference engine specifically designed for efficient generative Natural Language Processing (NLP) tasks. The core idea behind LLMCad revolves around model collaboration: a compact LLM, residing in memory, takes charge of generating the most straightforward tokens, while a high-precision LLM steps in to validate these tokens and rectify any identified errors. LLMCad incorporates three novel techniques: (1) Instead of generating candidate tokens in a sequential manner, LLMCad employs the smaller LLM to construct a token tree, encompassing a wider range of plausible token pathways. Subsequently, the larger LLM can efficiently validate all of these pathways simultaneously. (2) It employs a self-adjusting fallback strategy, swiftly initiating the verification process whenever the smaller LLM generates an erroneous token. (3) To ensure a continuous flow of token generation, LLMCad speculatively generates tokens during the verification process by implementing a compute-IO pipeline. Through an extensive series of experiments, LLMCad showcases an impressive token generation speed, achieving rates up to 9.3x faster than existing inference engines.

研究动机与目标

  • 解决在移动设备上阻碍 LLMs 的设备端扩展定律的内存瓶颈。
  • 通过隐私保护的设备端推理,使实时生成式 NLP 任务(如文本生成、问答)成为可能。
  • 提出在设备内存容量限制下保持准确性并提升速度的模型协作技术。

提出的方法

  • 使用内存驻留的小型 LLM 作为标记生成器,构建多个可行延续的标记树。
  • 使用更大、精度更高的 LLM 作为非自回归验证器,一次性验证所有分支。
  • 引入基于置信度的分支节奏机制,在分支间分配计算资源(最大-最小公平性)。
  • 实现一个树解码器,在保留自回归掩码的同时实现多分支标记生成。
  • 应用非自回归验证(NAV)对标记树进行批量验证,提升错误检测和回滚速度。
  • 结合使用树累积置信度和自适应阈值触发验证的自适应回退策略。
  • 引入一个推测性生成流水线,在考虑内存容量的计算-输入输出流水线中实现生成与验证的重叠。
(a) Emergent abilities across various LLMs.
(a) Emergent abilities across various LLMs.

实验结果

研究问题

  • RQ1在设备端的 LLM 推断如何在不牺牲生成质量的前提下克服内存瓶颈?
  • RQ2生成后验证的模型协作是否能够在资源受限的设备上同时实现高速度与高准确性?
  • RQ3在标记树生成框架中,哪些机制最适合触发验证并将无谓的计算降至最低?
  • RQ4推测性生成与 IO/计算流水线如何在不影响输出的情况下改善利用率?

主要发现

  • 相较于最先进的基线,LLMCad 在物联网设备上平均每个标记生成时间减少 2.9–9.3x,在智能手机上减少 3.5–4.7x。
  • 对于 >10B 规模的 LLM(如 LLaMA2-13B),LLMCad 可以在移动设备上每秒生成不止一个标记。
  • LLMCad 在速度方面优于竞争基线,同时在多个模型和数据集上维持准确性。
  • 标记树生成和非自回归验证实现并行验证,比自回归验证更快地检测错误。
  • 使用树累积置信度的自适应回退可以改善验证的决策时机并减少不必要的检查。
  • 在内存-IO感知的流水线下,推测性生成通过生成与验证的重叠来隐藏验证延迟。
(b) Generation latency of LLMs across various devices.
(b) Generation latency of LLMs across various devices.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。