arXiv(opens in a new tab)cs.LGOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.12327

SparseDecoding: Decoding-Aware Pruning for Accurate and Efficient LLM Inference

Qitong Wang, Xinwei Niu, Mingluo Su, Shanwei Zhao, Shiai Zhu, Huan Wang

ABSTRACT

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.48×1.48\times end-to-end wall-clock decoding speedup on A100 GPUs.

1 INTRODUCTION

Large language models (LLMs) are increasingly used for long-output applications such as document drafting, long-form content generation, and code generation (Bai et al., 2025; Wu et al., 2025; Chen et al., 2021; Jain et al., 2025). The autoregressive decoding process of LLMs is memory-bound and typically dominates end-to-end inference latency (Kim et al., 2025; Fu et al., 2024). Generating such long outputs incurs substantial latency, making inference efficiency a practical concern for deployment. Weight pruning addresses the inference cost problem of neural networks by zeroing out insignificant weights (Han et al., 2015). In terms of LLMs, due to the compute cost and data restrictions, training-free methods are the dominant ones (Frantar & Alistarh, 2023; Su & Wang, 2026) for sparsifying LLMs, especially those based on the OBS framework (Hassibi & Stork, 1992).

Existing training-free pruning methods (Frantar & Alistarh, 2023; Su & Wang, 2026) typically rely on a small calibration set to estimate or compensate for the output reconstruction error. Consequently, calibration data play a critical role in determining the quality of the pruned model. Existing methods usually collect calibration activations by running fixed sequences from the calibration set under teacher forcing. This protocol is appropriate for static-input inference settings, where the model inputs remain unchanged by its own predictions. However, autoregressive decoding continuously extends the input context with previously generated tokens. Pruning errors at early decoding steps may therefore alter subsequent predictions and contexts, causing the resulting activation distribution to progressively deviate from that observed during teacher-forced calibration. As shown

*Equal contribution. ✉Corresponding author: wanghuan@westlake.edu.cn

Figure

(a) Activation discrepancy during decoding.

(b) Prefill and decoding speedup.

Figure 1: Motivating observations for decoding-aware sparse inference. (a) The relative activation discrepancy between the dense and pruned models grows rapidly during the first few decoding steps before settling into a plateau. The shaded region shows the interquartile range across transformer layers, while the curves correspond to the first (layer 0), middle (layer 16), and last (layer 31) layers. All layers reach 90% of their plateau by decoding step 12, after which the activation discrepancy remains largely unchanged. (b) Speedup of the 2:4 sparse Tensor Core path over dense execution. Existing sparse kernels provide 1.31 to 1.46× speedups during the prefill stage, but achieve only 0.85 to 0.87× of dense performance during autoregressive decoding. Results are obtained on Llama-3.1-8B with 2:4 sparsity on an NVIDIA A100 GPU.

in Figure 1a, the relative activation discrepancy increases rapidly during the early stage of autoregressive decoding, with all layers reaching at least 90% of their eventual plateau within the first 12 decoding steps. After this initial increase, the discrepancy remains largely stable throughout the subsequent decoding process, even as generation continues for hundreds of additional steps. This behavior suggests that the activation distribution during decoding differs from that observed under fixed teacher-forced calibration, motivating us to construct the calibration objective directly from decode-time activations.

Meanwhile, reducing the theoretical computational cost of pruning alone does not necessarily translate into lower latency, and achieving practical speedups requires efficient sparse-kernel implementations. We consider N:MN:M semi-structured sparsity as a case study, since it offers hardware-friendly regularity while retaining flexibility in selecting weights (Fang et al., 2024). Existing 2:4 Sparse Tensor Core libraries, such as cuSPARSELt (NVIDIA Corporation, 2021) are optimized primarily for Sparse Matrix-Matrix Multiplication (SpMM) (Lin et al., 2023). By contrast, operations during decoding are dominated by Sparse Matrix-Vector Multiplication (SpMV) (Hong et al., 2024), rather than SpMM, and thus cannot be accelerated by cuSPARSELt implementations.

In this paper, we introduce SparseDecoding (Figure 2) to address these two issues. On the algorithmic side, we build the calibration matrices from layer-wise input activations collected as the dense model generates tokens autoregressively. We keep only the activations from decoding and discard those from prefill. This decoding-aware calibration can be used directly with existing pruning methods such as SparseGPT (Frantar & Alistarh, 2023). On the system side, inspired by nmSPARSE (Lin et al., 2023), a GPU library for general N:M sparse computation, we design a customized N:M SpMV kernel for efficient autoregressive decoding. Instead of storing a separate 32-bit column index for each nonzero, we represent the sparsity pattern with bitmasks, using one bit per input column and packing every 32 consecutive bits into a 32-bit mask. For the 50% N:M patterns with M≤32M \leq 32 considered in our kernel design, each aligned 32-bit mask word contains exactly 16 set bits. This allows every output row to traverse its bitmask in the same number of steps, keeping the workload uniform across GPU threads. Together, decoding-aware calibration and the optimized N:M SpMV kernel preserve generation quality while providing practical end-to-end decoding speedups.

Figure

Figure 2: Overview of SparseDecoding. Unlike standard pruning methods collecting calibration activations from fixed corpora, SparseDecoding calibrates on the model-generated tokens from task prompts while discarding the prefill activations. Meanwhile, existing N:M sparse Tensor Core kernels accelerate prefill but often underperform dense execution during autoregressive decoding. SparseDecoding instead introduces a decoding-oriented sparse execution pipeline that converts pruned weights into an efficient N:M representation and employs an optimized sparse decoding kernel, achieving up to 1.48×1.48\times decoding speedup under the experimental setup described in Sec. 4.

In summary, this paper makes three contributions:

  1. We propose a decoding-aware pruning method that aligns the pruning objective with the activations encountered during autoregressive decoding.

  2. We further develop an optimized N:M SpMV kernel for efficient sparse decoding, using bitmask indexing and fixed-step traversal to reduce metadata and indexing overhead.

  3. Extensive experiments across multiple LLMs show that SparseDecoding improves long-form generation quality over existing pruning baselines while achieving up to 1.48×1.48\times end-to-end decoding speedup on A100 GPUs.

References (49)

  • Longwriter: Unleashing 10,000+ word generation from long context llms
  • Is c4 dataset optimal for pruning? an investigation of calibration data for LLM pruning
  • Evaluating Large Language Models Trained on Code
  • Learning to prune deep neural networks via layer-wise optimal brain surgeon
  • Classeval: A manually-crafted benchmark for evaluating llms on class-level code generation (opens arXiv in a new tab)
  • MaskLLM: Learnable semi-structured sparsity for large language models
  • Optimal brain compression: A framework for accurate post-training quantization and pruning
  • SparseGPT: Massive language models can be accurately pruned in one-shot
  • Break the sequential dependency of llm inference using lookahead decoding
  • Sparse GPU kernels for deep learning
  • The Pile: An 800GB Dataset of Diverse Text for Language Modeling
  • The Llama 3 Herd of Models
  • Learning both weights and connections for efficient neural networks
  • Deep compression: Compressing deep neural network with pruning, trained quantization and huffman coding
  • Second order derivatives for network pruning: Optimal brain surgeon
  • Channel pruning for accelerating very deep neural networks
  • Sparsity in deep learning: pruning and growth for efficient inference and training in neural networks
  • Flashdecoding++: Faster large language model inference on gpus
  • Livecodebench: Holistic and contamination free evaluation of large language models for code
  • Beware of calibration data for pruning large language models
  • Overfill: Two-stage models for efficient language model decoding
  • Optimal brain damage
  • Efficient gpu kernels for n:m-sparse weights in deep learning
  • Reasoning models can be accurately pruned via chain-of-thought reconstruction
  • Llm-pruner: On the structural pruning of large language models
  • Pointer sentinel mixture models
  • Accelerating sparse deep neural networks (opens arXiv in a new tab)
  • Channel permutations for n:m sparsity
  • Exploring the limits of transfer learning with a unified text-to-text transformer
  • Woodfisher: Efficient second-order approximation for neural network compression
  • Rose: Reordered sparsegpt for more accurate one-shot large language models pruning
  • A simple and effective pruning approach for large language models
  • Triton: an intermediate language and compiler for tiled neural network computations
  • Global aligned structured sparsity learning for efficient image super-resolution
  • Think before you prune: Self-reflective structured pruning for reasoning language models (opens arXiv in a new tab)
  • Redpajama: an open dataset for training large language models, 2024
  • Learning structured sparsity in deep neural networks
  • Writingbench: A comprehensive benchmark for generative writing
  • Qwen3 Technical Report
  • Learning best combination for efficient n:m sparsity
  • The scalar $\epsilon_{\ell,C}^{(k)}$ is the operator (spectral) norm of the difference between the normalized calibration Hessian and the identity matrix $I_{k}$
  • More generally, a smaller $\epsilon_{\ell,C}^{(k)}$ indicates a smaller worst-case relative discrepancy between the calibration and decode-time reconstruction objectives over these directions
  • (13) by dividing by $\mathcal{L}_{\ell,\mathrm{Dec}}^{(k)}(\Delta W_\ell)$
  • We instantiate the fixed calibration source TF using the C4 dataset (Raffel et al., 2020), hence, we denote the fixed calibration source as C4 within this section
  • (8), and define
  • (10), obtained by substituting empirical Hessians for the population Hessians
  • SparseDecoding (ours) calibrates on autoregressive generations conditioned on LongWriter prompts; C4 uses fixed C4 sequences
  • Pile and RedPajama use fixed pretraining-corpus sequences; SparseDecoding calibrates on autoregressive generations conditioned on LongWriter prompts
  • Each nonzero position is recovered using a bit-scan operation that locates the least significant set bit