Abstract
Despite the recent success of large language models (LLMs), LLMs are particularly challenging in long-sequence inference scenarios due to the quadratic computational complexity of the attention mechanism. Inspired by the interpretability theory of feature attribution in neural network models, we observe that not all tokens have the same contribution. Based on this observation, we propose a novel token pruning framework, namely Saliency-driven Dynamic Token Pruning (SDTP), to gradually and dynamically prune redundant tokens based on the input context. Specifically, a lightweight saliency-driven prediction module is designed to estimate the importance score of each token with its hidden state, which is added to different layers of the LLM to hierarchically prune redundant tokens. Furthermore, a ranking-based optimization strategy is proposed to minimize the ranking divergence of the saliency score and the predicted importance score. Extensive experiments have shown that our framework is generalizable to various models and datasets. By hierarchically pruning 65% of the input tokens, our method greatly reduces 33% ~ 47% FLOPs and achieves speedup up to 1.75× during inference, while maintaining comparable performance. We further demonstrate that SDTP can be combined with KV cache compression method for further compression.
Introduction
The demand for LLMs to handle increasingly long contexts—often exceeding 128K tokens—has exposed a critical bottleneck: the quadratic computational complexity ($O(n^2)$) of the attention mechanism. This complexity makes both the initial "prefill" stage and the subsequent "decoding" stage resource-intensive. While existing solutions often focus on KV cache compression using local heuristics, they frequently overlook broader semantic importance and fail to accelerate the computation-heavy prefill phase.
Saliency-driven Dynamic Token Pruning (SDTP) addresses these challenges by identifying and removing redundant tokens hierarchically across Transformer layers. By reducing the actual number of tokens processed in deeper layers, SDTP provides a fundamental boost to inference efficiency.
The SDTP Framework
The core of SDTP lies in its ability to learn which tokens are essential for the model's output. The framework consists of several key innovations:
- Learnable Pruning Modules: Lightweight, two-layer Multi-Layer Perceptrons (MLPs) are inserted between Transformer blocks to predict an "importance score" for each token based on its hidden state.
- Gradient-based Saliency Supervision: These modules are trained using saliency scores derived from model interpretability. By analyzing the gradient of the output with respect to the input, the framework identifies tokens that are linguistically significant.
- Ranking-based Optimization: Rather than matching exact values, the optimization focuses on the relative ranking of tokens. This ensures the pruning module accurately identifies which tokens are most expendable.
- Hierarchical Cascade Pruning: Tokens deemed redundant at early layers are permanently removed from the computation path, leading to a "cascade" effect that significantly reduces FLOPs in subsequent layers.
Key Insights and Experimental Setup
Research into token importance revealed that "salient" tokens are sparse, and this sparsity increases with model depth. Crucially, redundancy is persistent: a token found to be redundant in an early layer rarely becomes important later. This justifies the hierarchical approach of SDTP.
The researchers validated SDTP on Llama2-7B, Mistral-7B-Instruct-v0.2, and BLOOM-7B across diverse benchmarks, including LongBench for long-context tasks and lm-eval-harness for general downstream performance. The pruning modules were aligned using the Databricks-dolly-15K dataset over just two epochs.
Efficiency and Performance Results
SDTP demonstrates significant gains in efficiency without sacrificing model accuracy. On Mistral-7B, the method achieved a 47.2% reduction in FLOPs and a 1.75× end-to-end speedup for 128K context lengths. Peak GPU memory usage was reduced by up to 34.26%.
Despite pruning up to 65% of tokens, performance remained comparable to unpruned baselines. In some cases, such as Llama2-7B on downstream tasks, average scores slightly improved, suggesting that pruning may act as a form of noise reduction. Furthermore, SDTP proved superior to prompt compression methods like LLMLingua-2, particularly in coding and few-shot learning scenarios.
Conclusion and Future Work
SDTP offers a robust framework for accelerating LLM inference by dynamically pruning redundant tokens. Its ability to accelerate the prefill phase and its compatibility with KV cache compression techniques make it a versatile tool for long-sequence processing. Future research may explore adapting this method to larger models (70B+), Mixture-of-Experts architectures, and implementing fully dynamic pruning ratios that adapt to the complexity of specific inputs.
Summary updated