SparseDecoding:面向准确高效LLM推理的解码感知剪枝

·

研究论文 · 2026/10/09

大型语言模型(LLM)推理的解码阶段受内存带宽限制,导致显著延迟。基于Hessian的逐层免训练网络剪枝是解决该问题的主流方法,因为剪枝减少了解码时从内存读取的非零参数数量。然而,这类方法通常使用预先收集的自然序列计算Hessian,而解码时模型输入的是自生成token,两者之间存在分布偏移。在自然序列上计算的Hessian与在生成序列上计算的不同。我们观察到这种差异导致生成过程中的激活分布偏离剪枝时使用的分布,进一步损害剪枝模型性能。此外,大多数现有能带来实际加速的LLM剪枝方法主要针对稀疏矩阵-矩阵乘法(SpMM),对解码中占主导的稀疏矩阵-向量乘法(SpMV)支持有限。为解决这些问题,我们提出SparseDecoding,一个面向准确高效LLM解码的原则性解码感知剪枝框架。具体而言,在算法层面,SparseDecoding从密集模型自回归生成过程中逐层收集的激活(排除预填充阶段)构建校准矩阵,从而使剪枝目标与解码激活对齐。在系统层面,我们开发了优化的N:M稀疏矩阵-向量内核,采用位掩码索引和固定步长遍历。在代表性LLM(Llama-3.1-8B、Llama-3.3-70B、Qwen3-14B/32B)上的大量实证结果表明,我们的方法在长文本生成基准上始终优于标准的固定文本校准,同时在A100 GPU上实现高达1.48倍的端到端实际解码加速。

该研究针对LLM解码阶段的内存瓶颈问题,提出了一种解码感知的剪枝方法,不仅从算法上对齐了剪枝与解码激活,还从系统上优化了稀疏矩阵-向量运算,在多个大模型上实现了显著的端到端加速,对高效LLM推理具有重要实践意义。

The memory-bound nature of the decoding stage of large language model (LLM) inference incurs significant latency. Layer-wise training-free network pruning approaches guided by the Hessian have been a prominent solution to this problem, as pruning reduces the number of nonzero parameters read from memory during decoding. Nevertheless, typical methods in this line compute the Hessian using pre-collected natural sequences, whereas the model is fed self-generated tokens during decoding, creating a distribution shift between the two sequences. The Hessian calculated on the natural sequence is different from that calculated on the generated sequence. We observe that this discrepancy causes the activation distribution during generation to deviate from that used for pruning, further hurting the pruned model performance. Moreover, most existing LLM pruning methods that bring actual speedup primarily target the sparse matrix-matrix (SpMM) multiplication, providing limited support for the sparse matrix-vector (SpMV) operations, which dominate decoding. To solve these problems, we introduce SparseDecoding, a principled decoding-aware pruning framework tailored for accurate and efficient LLM decoding. Specifically, at the algorithmic axis, SparseDecoding constructs calibration matrices from layer-wise activations collected during the dense-model autoregressive generation, excluding prefill, thereby aligning the pruning objective with the decoding activations. At the system axis, we develop an optimized N:M sparse matrix-vector kernel with bitmask indexing and fixed-step traversal. Substantial empirical results on representative LLMs (Llama-3.1-8B, Llama-3.3-70B, Qwen3-14B / 32B) demonstrate that our method consistently outperforms standard fixed-text calibration on the long-form generation benchmarks while achieving up to 1.48x end-to-end wall-clock decoding speedup on A100 GPUs.

阅读原文

参与讨论