SpeContext: 通过推测上下文稀疏性在LLMs中实现高效的长上下文推理
SpeContext: Enabling Efficient Long-context Reasoning with Speculative Context Sparsity in LLMs
AI总结:
SpeContext通过推测上下文稀疏性,在LLMs中实现高效的长上下文推理,显著提升云和边缘环境的吞吐量和速度,同时保持精度。
摘要:
在本文中,我们指出检索算法的目标是与LLM对齐,这与LLM中的知识蒸馏目标相似。我们从信息论的角度分析蒸馏语言模型(DLM)与原始LLM之间的信息焦点相似性,并因此提出了一种新的范式,利用DLM作为检索算法。基于这一见解,我们提出了SpeContext,一种为长上下文推理设计的算法和系统联合设计方法。(1) 在算法层面,SpeContext基于DLM的头部注意力权重提出轻量级检索头,通过剪枝冗余,实现了超过90%的参数减少。(2) 在系统层面,SpeContext通过弹性加载策略设计了异步预取数据流,有效重叠KV缓存检索与LLM计算。(3) 在编译层面,SpeContext构建了理论内存模型,并实现了自适应内存管理系统,通过最大化GPU内存利用率实现加速。我们部署并评估了SpeContext在两个资源受限的环境中,云和边缘。大量实验表明,与Huggingface框架相比,SpeContext在云环境中实现了高达24.89倍的吞吐量提升,在边缘环境中实现了10.06倍的速度提升,同时精度损失微乎其微,推动了精度和吞吐量的帕累托前沿。
英文摘要:
In this paper, we point out that the objective of the retrieval algorithms is to align with the LLM, which is similar to the objective of knowledge distillation in LLMs. We analyze the similarity in information focus between the distilled language model(DLM) and the original LLM from the perspective of information theory, and thus propose a novel paradigm that leverages a DLM as the retrieval algorithm. Based on the insight, we present SpeContext, an algorithm and system co-design for long-context reasoning. (1) At the algorithm level, SpeContext proposes lightweight retrieval head based on the head-level attention weights of DLM, achieving > 90% parameters reduction by pruning the redundancy. (2) At the system level, SpeContext designs an asynchronous prefetch dataflow via the elastic loading strategy, effectively overlapping KV cache retrieval with the LLM computation. (3) At the compilation level, SpeContext constructs the theoretical memory model and implements an adaptive memory management system to achieve acceleration by maximizing GPU memory utilization. We deploy and evaluate SpeContext in two resourceconstrained environments, cloud and edge. Extensive experiments show that, compared with the Huggingface framework, SpeContext achieves up to 24.89x throughput improvement in cloud and 10.06x speedup in edge with negligible accuracy loss, pushing the Pareto frontier of accuracy and throughput.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。