Skip to main content
QUICK REVIEW

[Paper Review] LLMCad: Fast and Scalable On-device Large Language Model Inference

Daliang Xu, Wangsong Yin|arXiv (Cornell University)|Sep 8, 2023
Topic ModelingComputer Science13 citations
TL;DR

LLMCad is an on-device inference engine that uses a memory-resident small LLM to generate candidate tokens and a larger, accurate LLM to verify and rectify them, achieving up to 9.3x faster token generation on IoT devices and 3.5–4.7x on smartphones without sacrificing accuracy.

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.

Motivation & Objective

  • Address memory bottlenecks hindering on-device scaling laws for LLMs on mobile devices.
  • Enable real-time generative NLP tasks (e.g., text generation, QA) with privacy-preserving on-device inference.
  • Propose model-collaboration techniques to maintain accuracy while boosting speed within device memory limits.

Proposed method

  • Use a memory-resident small LLM as a token generator to build a token tree of multiple plausible continuations.
  • Employ a larger, high-precision LLM as a non-autoregressive verifier to validate all branches in one shot.
  • Introduce a confidence-based branch pacing mechanism to allocate compute across branches (max-min fairness).
  • Implement a tree decoder that preserves autoregressive masking while enabling multi-branch token generation.
  • Apply non-autoregressive verification (NAV) to verify token trees in batch, enabling faster error detection and rollback.
  • Incorporate a self-adaptive fallback strategy using tree-cumulative confidence and a self-adaptive threshold to trigger verification.
  • Introduce a speculative generation pipeline to overlapped generation and verification within a memory-cap-aware compute-IO pipeline.
(a) Emergent abilities across various LLMs.
(a) Emergent abilities across various LLMs.

Experimental results

Research questions

  • RQ1How can on-device LLM inference overcome memory walls while preserving generation quality?
  • RQ2Can a generate-then-verify model collaboration achieve both high speed and accuracy on resource-constrained devices?
  • RQ3What mechanisms best trigger verification and minimize wasted computation in a token-tree generation framework?
  • RQ4How can speculative generation and IO/compute pipelining improve utilization without compromising outputs?

Key findings

  • LLMCad reduces average per-token generation time by 2.9–9.3x on IoT devices and 3.5–4.7x on smartphones compared to state-of-the-art baselines.
  • For >10B-sized LLMs (e.g., LLaMA2-13B), LLMCad can generate more than one token per second on mobile devices.
  • LLMCad outperforms competitive baselines in speed while maintaining accuracy across multiple models and datasets.
  • Token-tree generation and non-autoregressive verification enable parallel verification and faster error detection than autoregressive verification.
  • Self-adaptive fallback using tree-cumulative confidence improves decision timing for verification and reduces unnecessary checks.
  • Speculative generation hides verification latency by overlapping generation with verification under a memory-IO aware pipeline.
(b) Generation latency of LLMs across various devices.
(b) Generation latency of LLMs across various devices.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.