MoA: Mixture of Sparse Attention for Automatic Large Language Model Compression

📅 2024-06-21
🏛️ arXiv.org
📈 Citations: 41
✨ Influential: 5
📄 PDF
🤖 AI Summary
To address memory and throughput bottlenecks in large language models (LLMs) during long-context reasoning—caused by uniform sliding-window attention—this paper proposes the first automated sparse attention compression framework. It identifies a bimodal, heterogeneous behavior across attention heads in long contexts: “expansion” (broad context coverage) and “local fixation” (narrow, position-stable focus), and designs a hybrid sparse mechanism enabling dynamic, head-wise, layer-wise, and sequence-length–adaptive sparsity patterns. Leveraging performance profiling–driven search space construction, joint optimization of sparsity patterns and scaling laws, and automatic policy generation, the framework integrates seamlessly with FlashAttention2 and vLLM. Experiments demonstrate: 3.9× longer supported context length; 1.5–7.1× higher retrieval accuracy; maximum performance degradation reduced from 9%–36% to ≤5%; 1.2–1.4× lower GPU memory consumption; and 6.6–8.2× higher decoding throughput.

Technology Category

Machine Learning: Large Multimodal Models (LMMs)Natural Language Processing: (Large) Language ModelsComputer Vision: Large Vision Models

Application Category

Search and Retrieval-Augmented AI: Large language models for searchUser Modeling, Personalization and Recommendation: Large Language Models (LLM) for user modeling and recommendationSemantics and Knowledge: Methods to enhance, augment, integrate or synergize semantic models such as knowledge graphs and LLMs
📝 Abstract
Sparse attention can effectively mitigate the significant memory and throughput demands of Large Language Models (LLMs) in long contexts. Existing methods typically employ a uniform sparse attention mask, applying the same sparse pattern across different attention heads and input lengths. However, this uniform approach fails to capture the diverse attention patterns inherent in LLMs, ignoring their distinct accuracy-latency trade-offs. To address this challenge, we propose the Mixture of Attention (MoA), which automatically tailors distinct sparse attention configurations to different heads and layers. MoA constructs and navigates a search space of various attention patterns and their scaling rules relative to input sequence lengths. It profiles the model, evaluates potential configurations, and pinpoints the optimal sparse attention compression plan. MoA adapts to varying input sizes, revealing that some attention heads expand their focus to accommodate longer sequences, while other heads consistently concentrate on fixed-length local contexts. Experiments show that MoA increases the effective context length by $3.9 imes$ with the same average attention span, boosting retrieval accuracy by $1.5-7.1 imes$ over the uniform-attention baseline across Vicuna-{7B,13B}, and Llama3-{8B,70B} models. Moreover, MoA narrows the capability gaps between sparse and dense models, reducing the maximum relative performance drop from $9%-36%$ to within $5%$ across two long-context understanding benchmarks. MoA achieves a $1.2-1.4 imes$ GPU memory reduction, boosting decode throughput by $6.6-8.2 imes$ and $1.7-1.9 imes$ compared to FlashAttention2 and vLLM, with minimal impact on performance. Our code is available at url{https://github.com/thu-nics/MoA}.
Problem

Research questions and friction points this paper is trying to address.

Optimizing LLM inference efficiency with heterogeneous sliding-window attention lengths
Addressing uniform window length limitations in capturing diverse attention patterns
Balancing accuracy-latency trade-offs across different attention heads and layers
Innovation

Methods, ideas, or system contributions that make the work stand out.

Automatically tailors distinct sliding-window lengths to heads
Adapts window configurations to varying input sizes dynamically
Optimizes length configurations through profiling and search space
🔎 Similar Papers
No similar papers found.
💼 Related Jobs
No related jobs found.