When Linear Attention Meets Autoregressive Decoding: Towards More Effective and Efficient Linearized Large Language Models

Haoran You, Yichao Fu, Zheng Wang, Amir Yazdanbakhsh, Yingyan Celine Lin

Abstract

Modern Large Language Models (LLMs) are constrained by the quadratic complexity of standard softmax attention and the sequential nature of autoregressive decoding. This paper presents a novel framework that successfully integrates Linear Attention (LA) with Speculative Decoding. By introducing a masked depthwise convolution to prevent training-time information leakage and a tree-based integration for candidate token verification, the proposed method achieves a 2× generation speedup and a 6.67× reduction in perplexity compared to existing linearization techniques.

Introduction: The Efficiency Bottleneck

As LLMs scale, they encounter two primary efficiency hurdles. First, the quadratic complexity of standard attention mechanisms makes processing long-context sequences computationally prohibitive. As sequence length grows, the time and memory required to compute attention scores increase exponentially, limiting the model's ability to handle long documents or extended dialogues.

Latency scaling of standard softmax attention in BERT models across different hardware.

Second, the sequential decoding process inherent to autoregressive models forces tokens to be generated one by one. This lack of parallelism during inference results in low throughput, even on high-end hardware. While Linear Attention (LA) and Speculative Decoding have been proposed as individual solutions, their integration has been historically difficult due to structural incompatibilities and training instabilities.

Methods: Bridging Linear Attention and Speculative Decoding

The authors propose a revised architecture for Augmented Linearized LLMs, focusing on three key innovations:

  1. Masked Depthwise Convolution (DWConv): To capture local context without compromising causality, the authors implement a causal mask on the DWConv layer. This prevents "information leakage" from future tokens during training, a common failure mode in previous linearized models.
  2. Grouped Linear Attention: The input sequence is partitioned into non-overlapping groups. Local dependencies are managed via parallel local attention, while global interactions are handled through efficient cumulative sums at the group level.
  3. Tree-based LA Integration: Speculative decoding architectures (such as Medusa) generate multiple candidate token trees. Standard LA cannot naturally process these non-linear structures. The authors resolve this by unfolding the convolution into a matrix multiplication, allowing the application of tree-based attention masks directly to linearized kernels.

Key Insights: The Information Leakage Trap

A critical discovery in this research is the "Information Leakage" trap. Many efficient attention augmentations appear to achieve near-zero training loss almost instantly. However, this is often an artifact of non-causal convolutions allowing the model to "peek" at the next token rather than learning to predict it.

Training loss curves showing the "information leakage" trap in standard DWConv versus the causal Masked DWConv.

As shown in the loss curves, standard LA with DWConv fails to learn meaningful representations because it bypasses the predictive task. The introduction of the causal mask (Masked DWConv) restores the proper training objective, allowing the model to converge effectively while maintaining the benefits of local context.

Experimental Results

The researchers evaluated the framework across various models, including LLaMA-2-7B and 13B, using benchmarks like GLUE, Wiki40b, and MT-Bench. Key findings include:

  • Perplexity and Accuracy: On LLaMA models, the augmented LA approach reduced perplexity by 6.67× compared to standard linear attention, significantly narrowing the gap with original softmax performance.
  • Throughput and Latency: The integration with speculative decoding provided a 2× speedup in token generation. For LLaMA-2-7B, inference latency was reduced by up to 56.3%, with a 36.5% reduction in memory usage.
  • Context Extension: The linearized LLaMA-2-7B successfully extended its maximum sequence length from 8K to 32K tokens on a single A100-80GB GPU.

Conclusion and Future Work

This work demonstrates that Linear Attention can be a viable and highly efficient alternative for autoregressive LLMs when properly augmented to handle causality and speculative structures. While the current method requires a brief fine-tuning phase, it paves the way for future foundation models that could be trained from scratch using this linear architecture, potentially supporting near-infinite context windows with high generation throughput.

Summary updated

BibTeX
@inproceedings{you2024when,
  author = {Haoran You and Yichao Fu and Zheng Wang and Amir Yazdanbakhsh and Yingyan Celine Lin},
  title = {{When Linear Attention Meets Autoregressive Decoding: Towards More Effective and Efficient Linearized Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=7mFSaP6IiN},
}
Figure