TokenGate:通过学习型Token剪枝使LLM实现快速且内存高效的预填充

·

研究论文 · 2026/10/21

TokenGate 是一种小型即插即用组件,可扩展现有已训练模型,实现长上下文输入上的端到端可学习 token 剪枝,从而加速并降低预填充的内存消耗。为克服 top-K 剪枝不可微的问题,作者提出 token 门控注意力,借鉴混合专家机制,利用 token 重要性分数重新加权注意力 logits。在多种任务上,TokenGate 在预填充阶段实现 1.4-11.3 倍的首 token 时间(TTFT)加速和 1.5-3.4 倍的峰值内存降低,且无精度损失;与最佳先前 token 剪枝方法相比,预填充速度提升至多 6.4 倍,峰值内存降低 2 倍。TokenGate 可原生扩展标准 Transformer(如 Qwen3)和混合注意力模型(如 Qwen3.5),适配成本与标准参数高效微调相当。

TokenGate 提供了一种高效、低成本的 token 剪枝方案,能显著提升长上下文预填充的速度和内存效率,且易于集成到现有模型,对实际部署有重要价值。

Expert human readers process large inputs (e.g., code repositories and long documents) by skimming to closely read only what matters. On the other hand, language models process all input tokens through each model layer, resulting in significant processing costs for long-context inputs. We introduce TokenGate, a small, drop-in component that extends existing trained models to enable end-to-end learnable token pruning over long-context inputs for fast and memory-efficient prefill. To enable end-to-end learning despite the non-differentiable top-K operator for token pruning, we introduce token-gated attention, a mechanism inspired by Mixture-of-Experts that re-weights attention logits using token importance scores. Across diverse tasks, TokenGate achieves 1.4-11.3times faster time-to-first token (TTFT) and 1.5-3.4times lower peak memory at no accuracy degradation for prefill in transformers. Compared to the best-performing prior methods for token-pruning, TokenGate gives up to 6.4times faster prefill and 2times lower peak memory. TokenGate natively extends both standard transformers (e.g., Qwen3) and hybrid-attention models (e.g., Qwen3.5) with simple lightweight adaptation comparable to standard parameter-efficient fine-tuning. We make our code available at: https://github.com/tokengate-models/TokenGate.

阅读原文

参与讨论