Cerberus: Efficient Inference with Adaptive Parallel Decoding and Sequential Knowledge Enhancement

Yuxuan Liu, Wenyuan Li, Laizhong Cui, Hailiang YangarXiv 2024 · DOI

Abstract

Large Language Models (LLMs) typically rely on auto-regressive decoding, which generates text one token at a time, leading to significant inference latency. While parallel decoding techniques have been proposed to mitigate this, they often face a trade-off between prediction accuracy and execution speed, or suffer from computational overhead in uncertain scenarios. This paper presents Cerberus, an inference framework that utilizes sequential knowledge enhancement through interconnected decoding heads and an entropy-based gating mechanism. Cerberus achieves a speedup of up to 2.12x over standard decoding and demonstrates superior efficiency compared to existing parallel methods.

Introduction

The transformative power of Large Language Models is often hampered by their "speed limit." Standard auto-regressive decoding is inherently sequential, meaning even high-end GPUs are underutilized while waiting for the next token to be generated. Parallel decoding (or speculative decoding) attempts to solve this by predicting multiple future tokens simultaneously and verifying them in a single pass. However, existing frameworks struggle with two main issues: the Accuracy-Parallelism Trade-off, where heads are either fast but inaccurate or accurate but slow, and the Overhead Problem, where failed parallel predictions take longer than standard decoding.

Methodology

Cerberus introduces two key innovations to overcome these bottlenecks: Sequential Knowledge Enhancement and Entropy-based Gating.

Sequential Knowledge Enhancement (Cerberus Heads)

In traditional parallel decoding frameworks like Medusa, decoding heads operate independently. Cerberus improves upon this by connecting the heads internally. Each head receives information from the preceding head's internal modules, specifically the residual blocks (ResBlocks).

Comparison of (a) independent Medusa heads and (b) sequentially connected Cerberus heads that share internal features.

This architecture allows subsequent heads to "know" the context established by previous heads, significantly improving prediction accuracy for tokens further in the sequence. Because this connection occurs within the head structure rather than waiting for final token outputs, the heads can still be executed in parallel, maintaining high throughput.

Adaptive Parallel Decoding (Entropy-based Gating)

Not every step in text generation is suitable for parallel decoding. In "challenging" steps where the model is uncertain, the computational cost of guessing and verifying multiple tokens (the "speculation tax") can exceed the time required for standard auto-regression. Cerberus implements a gating mechanism that monitors the entropy of the model's hidden states in real-time to decide the optimal path.

The Cerberus gating mechanism adaptively switches between parallel decoding (Confident) and standard auto-regression (Confused) based on real-time entropy.
  • Confident State (Low Entropy): When the model is certain, it utilizes parallel decoding and tree verification to accelerate generation.
  • Confused State (High Entropy): When uncertainty is high, the system bypasses the parallel heads and tree verification, falling back to standard auto-regressive decoding to minimize overhead.

Experimental Results

The researchers evaluated Cerberus using a Vicuna-7B model on the MT-Bench benchmark, covering categories from coding to humanities.

Performance and Efficiency

Cerberus achieved a speedup ratio ranging from 1.57x to 2.12x compared to standard auto-regressive decoding. Notably, it outperformed the Medusa framework by 10% to 30% in acceleration. The gating mechanism proved vital for efficiency; in tasks like "Humanities" and "Extraction," approximately 24% of steps were correctly identified as "hard," allowing the model to avoid unnecessary parallel computation and save significant time.

Prediction Accuracy

Ablation studies confirmed that the sequential connections in Cerberus heads significantly improved "top-k" prediction accuracy. This improvement was most pronounced for tokens further ahead in the sequence (e.g., Heads 3 and 4), leading to more coherent drafts and higher acceptance rates during the tree verification phase.

Conclusion

Cerberus offers a robust solution to the latency challenges of LLM inference. By combining sequentially enhanced decoding heads with an adaptive gating mechanism, it balances accuracy and speed more effectively than previous methods. While future work is needed to automate threshold tuning and manage the increased parameter count, Cerberus represents a significant advancement in making LLMs more efficient for real-world applications.

Summary updated

Abstract

Large language models (LLMs) often face a bottleneck in inference speed due to their reliance on auto-regressive decoding. Recently, parallel decoding has shown significant promise in enhancing inference efficiency. However, we have identified two key issues with existing parallel decoding frameworks: (1) decoding heads fail to balance prediction accuracy and the parallelism of execution, and (2) parallel decoding is not a universal solution, as it can bring unnecessary overheads at some challenging decoding steps. To address these issues, we propose Cerberus, an adaptive parallel decoding framework introduces the gating mechanism to enable the LLMs to adaptively choose appropriate decoding approaches at each decoding step, along with introducing a new paradigm of decoding heads that introduce the sequential knowledge while maintaining execution parallelism. The experiment results demonstrate that the Cerberus can achieve up to 2.12x speed up compared to auto-regressive decoding, and outperforms one of the leading parallel decoding frameworks, Medusa, with a 10% - 30% increase in acceleration and superior generation quality.
BibTeX
@misc{liu2024cerberus,
  author = {Yuxuan Liu and Wenyuan Li and Laizhong Cui and Hailiang Yang},
  title = {{Cerberus: Efficient Inference with Adaptive Parallel Decoding and Sequential Knowledge Enhancement}},
  year = {2024},
  eprint = {2410.13344},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.13344},
}
Figure