arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.06766cs.CL
收藏

利用稀疏性实现长上下文推理:在消费级GPU上处理百万级token上下文

Exploiting Sparsity for Long Context Inference: Million Token Contexts on Commodity GPUs

University of Maryland, College Park(马里兰大学帕克分校);Salesforce Research(Salesforce研究院)

Ryan Synk, Monte Hoover, John Kirchenbauer, Neel Jain, Alex Stein, Manli Shu, Josue Melendez Sanchez, Ramani Duraiswami, Tom Goldstein

AI总结:

针对Transformer模型长上下文推理在消费级GPU上的资源瓶颈,提出基于top-k选择的可调稀疏注意力机制,仅关注最相关token,在约16GB显存上支持百万级token推理,仅用2%输入token即可保留95%以上基准性能。

摘要:

训练后的Transformer模型对处理数十万输入token的推理需求日益增长。这种极端规模的推理需要大量计算资源,阻碍了Transformer在长上下文场景下在消费级(即非数据中心级)硬件上的应用。为解决基于自注意力的Transformer语言模型在长上下文推理时的时间成本问题,并使其能在广泛可用的硬件上部署,我们提出一种可调机制:通过top-k选择机制,在每个生成步骤仅关注最相关的token,从而降低前向传播成本。我们展示了该方法的效率提升:使用约16GB GPU内存,可对高达100万token的上下文窗口进行推理。实验表明,模型能够处理因键值对数量减少而产生的稀疏性。通过仅关注不到2%的输入token,我们在常见基准(RULER、AlpacaEval和Open LLM Leaderboard)上实现了超过95%的模型性能。

英文摘要:

There is growing demand for performing inference with hundreds of thousands of input tokens on trained transformer models. Inference at this extreme scale demands significant computational resources, hindering the application of transformers at long contexts on commodity (i.e not data center scale) hardware. To address the inference time costs associated with running self-attention based transformer language models on long contexts and enable their adoption on widely available hardware, we propose a tunable mechanism that reduces the cost of the forward pass by attending to only the most relevant tokens at every generation step using a top-k selection mechanism. We showcase the efficiency gains afforded by our method by performing inference on context windows up to 1M tokens using approximately 16GB of GPU RAM. Our experiments reveal that models are capable of handling the sparsity induced by the reduced number of keys and values. By attending to less than 2% of input tokens, we achieve over 95% of model performance on common benchmarks (RULER, AlpacaEval, and Open LLM Leaderboard).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑