通过动态剪枝冗余提示词,加速大模型长文本推理
SlimInfer: Accelerating Long-Context LLM Inference via Dynamic Token Pruning
- 在前向传播中动态剪枝不关键的输入token
- 实测提升2.53倍首令牌生成速度,端到端延迟降低1.88倍
- 适合需要高效长文本处理的部署场景
大语言模型长上下文推理受高计算开销制约。现有方法虽优化注意力计算,但仍需处理每层全部隐藏状态,限制整体效率。本文提出SlimInfer框架,通过在前向传播中直接剪枝不关键的提示词来加速推理。核心洞察是信息扩散现象:关键提示词的信息经多层传播后会分布至整个序列,因此可安全剪除大量冗余隐藏状态。SlimInfer引入细粒度动态剪枝机制,在中间层精准移除冗余隐藏状态,实现层间异步KV缓存管理,无需复杂预测器即可预取所需token块,显著降低内存占用与I/O成本。大量实验表明,该方法在单张RTX 4090上对LLaMA3.1-8B-Instruct实现最高2.53倍首令牌生成时间(TTFT)加速和1.88倍端到端延迟降低,且在LongBench上性能无损。代码已开源。
原文摘要 · Abstract (English)
Long-context inference for Large Language Models (LLMs) is heavily limited by high computational demands. While several existing methods optimize attention computation, they still process the full set of hidden states at each layer, limiting overall efficiency. In this work, we propose SlimInfer, an innovative framework that aims to accelerate inference by directly pruning less critical prompt tokens during the forward pass. Our key insight is an information diffusion phenomenon: As information from critical tokens propagates through layers, it becomes distributed across the entire sequence. This diffusion process suggests that LLMs can maintain their semantic integrity when excessive tokens, even including these critical ones, are pruned in hidden states. Motivated by this, SlimInfer introduces a dynamic fine-grained pruning mechanism that accurately removes redundant tokens of hidden state at intermediate layers. This layer-wise pruning naturally enables an asynchronous KV cache manager that prefetches required token blocks without complex predictors, reducing both memory usage and I/O costs. Extensive experiments show that SlimInfer can achieve up to $\mathbf{2.53\times}$ time-to-first-token (TTFT) speedup and $\mathbf{1.88\times}$ end-to-end latency reduction for LLaMA3.1-8B-Instruct on a single RTX 4090, without sacrificing performance on LongBench. Our code is available at https://github.com/Longxmas/SlimInfer.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。