arXiv:2505.14884cs.LGcs.AI2025-05NeurIPS被引 7

通过动态关注头稀疏性,实现大批次高效语言模型推理。

Polar Sparsity: High Throughput Batched LLM Inferencing with Scalable Contextual Sparsity

  • 聚焦注意力层头级稀疏性,突破传统稀疏计算在大批量下的瓶颈。
  • 在多种模型与批量大小下实现最高2.2倍的端到端加速。
  • 无需修改模型结构,适配大规模高吞吐部署系统。

加速大语言模型(LLM)推理对实际应用中高吞吐、低延迟需求至关重要。上下文稀疏性(每个标记仅激活部分参数)有潜力但难以扩展至大规模批处理,因活跃神经元并集迅速趋近密集计算。本文提出极化稀疏性(Polar Sparsity),发现随批大小和序列长度增长,稀疏性的重要性从MLP层转向注意力层。批量下MLP虽更高效但稀疏性消失;而注意力层成本上升,其头稀疏性保持稳定且批处理无关。我们设计了选择性头注意力机制,配备硬件友好的稀疏感知GPU内核,在OPT、LLaMA-2/3、Qwen、Mistral等模型上实现最高2.2倍端到端加速,不牺牲精度。据我们所知,这是首个证明上下文稀疏性可有效扩展至大规模批处理的工作,仅需极少改动即适用于大规模高吞吐部署。代码已开源:https://github.com/susavlsh10/Polar-Sparsity。

原文摘要 · Abstract (English)

Accelerating large language model (LLM) inference is critical for real-world deployments requiring high throughput and low latency. Contextual sparsity, where each token dynamically activates only a small subset of the model parameters, shows promise but does not scale to large batch sizes due to union of active neurons quickly approaching dense computation. We introduce Polar Sparsity, highlighting a key shift in sparsity importance from MLP to Attention layers as we scale batch size and sequence length. While MLP layers become more compute-efficient under batching, their sparsity vanishes. In contrast, attention becomes increasingly more expensive at scale, while their head sparsity remains stable and batch-invariant. We develop Selective Head Attention with hardware-efficient, sparsity-aware GPU kernels, delivering up to \(2.2\times\) end-to-end speedups for models like OPT, LLaMA-2 \& 3, Qwen, Mistral across various batch sizes and sequence lengths without compromising accuracy. To our knowledge, this is the first work to demonstrate that contextual sparsity can scale effectively to large batch sizes, delivering substantial inference acceleration with minimal changes, making Polar Sparsity practical for large-scale, high-throughput LLM deployment systems. Our code is available at: https://github.com/susavlsh10/Polar-Sparsity.

稀疏推理大模型部署注意力优化高性能计算

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。