Skip to main content
QUICK REVIEW

[Paper Review] Break the Sequential Dependency of LLM Inference Using Lookahead Decoding

Yichao Fu, Peter Bailis|arXiv (Cornell University)|Feb 3, 2024
Natural Language Processing TechniquesComputer Science3 citations
TL;DR

This paper proposes Lookahead Decoding, a lossless, parallel inference method for autoregressive LLMs that eliminates sequential dependency by generating and verifying multiple n-grams in parallel using the model's own capabilities, achieving up to 4x speedup on 8 GPUs in code completion tasks without requiring a draft model or changing output distribution.

ABSTRACT

Autoregressive decoding of large language models (LLMs) is memory bandwidth bounded, resulting in high latency and significant wastes of the parallel processing power of modern accelerators. Existing methods for accelerating LLM decoding often require a draft model (e.g., speculative decoding), which is nontrivial to obtain and unable to generalize. In this paper, we introduce Lookahead decoding, an exact, parallel decoding algorithm that accelerates LLM decoding without needing auxiliary models or data stores. It allows trading per-step log(FLOPs) to reduce the number of total decoding steps, is more parallelizable on single or multiple modern accelerators, and is compatible with concurrent memory-efficient attention (e.g., FlashAttention). Our implementation of Lookahead decoding can speed up autoregressive decoding by up to 1.8x on MT-bench and 4x with strong scaling on multiple GPUs in code completion tasks. Our code is avialable at https://github.com/hao-ai-lab/LookaheadDecoding

Motivation & Objective

  • Address the high latency and poor parallelization of autoregressive LLM decoding, which is memory bandwidth-bound and sequential by nature.
  • Overcome the limitations of speculative decoding methods that rely on auxiliary draft models, which are hard to train and lack generalization.
  • Enable efficient, exact, and parallel decoding using only the base LLM, without changing the output distribution or requiring additional data stores.
  • Design a scalable decoding algorithm that linearly reduces decoding steps with increased per-step FLOPs, making it future-proof for evolving hardware.
  • Ensure compatibility with modern efficiency techniques like FlashAttention and support for distributed multi-GPU inference.

Proposed method

  • Reformulate autoregressive decoding as a fixed-point Jacobi iteration to enable parallel generation of multiple n-grams across different sequence positions.
  • Introduce a lookahead branch that generates disjoint n-grams in parallel using the base LLM, exploiting unused compute cycles.
  • Implement a verification branch that checks the validity of generated n-grams against the base model’s output distribution to maintain exactness.
  • Maintain an n-gram pool to cache historical n-grams, enabling reuse and reducing redundant computation during decoding.
  • Use a trade-off between per-step FLOPs and number of decoding steps, allowing linear reduction in steps with exponential FLOP investment.
  • Design a distributed CUDA implementation supporting multi-GPU Lookahead Parallelism, compatible with memory-efficient attention mechanisms like FlashAttention.

Experimental results

Research questions

  • RQ1Can we accelerate autoregressive LLM decoding without relying on a draft model or auxiliary data stores?
  • RQ2How can we exploit unused parallel compute in modern accelerators to reduce decoding latency while preserving the exact output distribution?
  • RQ3What is the scaling behavior of parallel decoding when increasing per-step FLOPs, and can it be linearly tuned for efficiency?
  • RQ4How does Lookahead Decoding perform under different hardware configurations and model sizes, especially in compute-constrained environments?
  • RQ5Can the method be efficiently parallelized across multiple GPUs while maintaining compatibility with memory-efficient attention mechanisms?

Key findings

  • Lookahead Decoding achieves up to 1.8x speedup on the MT-Bench multi-turn chat benchmark using a single GPU, with significant gains even in low-FLOP environments.
  • On code completion tasks, the method achieves up to 4x speedup when scaled across 8 GPUs using Lookahead Parallelism, demonstrating strong linear scaling.
  • The method maintains exact output distribution by verifying all speculative n-grams against the base model, ensuring no distribution shift.
  • Configurations on A100 GPUs (e.g., W=15, N=5 for 7B model) achieve near-optimal performance, with only a modest wall-clock slowdown despite 120x extra FLOPs per step.
  • The speedup is robust across different sampling methods and remains effective even when FLOPs are limited, with over 30% speedup observed on RTX 3090 GPUs.
  • Using prompts as a reference for n-gram pool construction further boosts performance, outperforming baseline prompt lookup methods in the Hugging Face implementation.

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.