PowerInfer: Fast Large Language Model Serving with a Consumer-grade GPU
作者: Yixin Song, Zeyu Mi, Haotong Xie, Haibo Chen
分类: cs.LG, cs.OS
发布日期: 2023-12-16 (更新: 2024-12-12)
备注: SOSP 2024
💡 一句话要点
PowerInfer:利用消费级GPU实现快速大语言模型推理服务
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大语言模型 推理加速 GPU-CPU混合 消费级GPU 神经元激活 幂律分布 稀疏计算
📋 核心要点
- 现有大语言模型推理对GPU内存需求高,消费级GPU难以支持大型模型。
- PowerInfer利用神经元激活的幂律分布特性,设计GPU-CPU混合推理引擎。
- 实验表明,PowerInfer在消费级GPU上显著优于llama.cpp,性能接近服务器级GPU。
📝 摘要(中文)
本文介绍了PowerInfer,一个在配备单块消费级GPU的个人电脑(PC)上实现高速大语言模型(LLM)推理的引擎。PowerInfer设计的核心原则是利用LLM推理中固有的高局部性,这种局部性表现为神经元激活的幂律分布。这种分布表明,一小部分神经元(称为热神经元)在不同输入中持续激活,而大部分神经元(称为冷神经元)则根据特定输入而变化。PowerInfer利用这一洞察力设计了一个GPU-CPU混合推理引擎:热激活神经元被预加载到GPU上以实现快速访问,而冷激活神经元在CPU上计算,从而显著降低GPU内存需求和CPU-GPU数据传输。PowerInfer进一步集成了自适应预测器和神经元感知稀疏算子,优化了神经元激活和计算稀疏性的效率。评估表明,在单个NVIDIA RTX 4090 GPU上,PowerInfer在各种LLM(包括OPT-175B)上显著优于llama.cpp,高达11.69倍,同时保持了模型精度。对于OPT-30B模型,PowerInfer实现了与高端服务器级A100 GPU相当的性能,在单个消费级RTX 4090 GPU上达到了其token生成速率的82%。
🔬 方法详解
问题定义:现有的大语言模型(LLM)推理通常需要大量的GPU内存,这使得在资源有限的消费级GPU上部署大型模型变得非常困难。传统的推理方法没有充分利用LLM中神经元激活的特性,导致了不必要的内存占用和计算开销。
核心思路:PowerInfer的核心思路是观察到LLM中神经元的激活呈现幂律分布,即少数“热神经元”经常被激活,而大多数“冷神经元”只在特定输入下激活。通过将热神经元加载到GPU上,并在CPU上计算冷神经元,可以显著减少GPU内存需求和CPU-GPU数据传输。
技术框架:PowerInfer采用GPU-CPU混合推理引擎。首先,通过分析训练数据或少量样本,确定热神经元和冷神经元。然后,将热神经元预加载到GPU内存中,以便快速访问。对于每个输入,首先在GPU上计算热神经元的激活,然后将结果传递给CPU,在CPU上计算冷神经元的激活。最后,将CPU的计算结果传回GPU,完成整个推理过程。此外,PowerInfer还集成了自适应预测器和神经元感知稀疏算子,以进一步优化性能。
关键创新:PowerInfer的关键创新在于它充分利用了LLM中神经元激活的幂律分布特性,并设计了一个GPU-CPU混合推理引擎。与传统的推理方法相比,PowerInfer能够显著减少GPU内存需求,从而使得在消费级GPU上部署大型LLM成为可能。此外,自适应预测器和神经元感知稀疏算子的引入进一步提高了推理效率。
关键设计:PowerInfer的关键设计包括:1) 热神经元和冷神经元的划分策略,需要平衡GPU内存占用和CPU计算开销;2) CPU上的计算优化,例如使用高效的稀疏矩阵乘法库;3) CPU和GPU之间的数据传输优化,例如使用异步传输和数据压缩;4) 自适应预测器的设计,用于预测哪些冷神经元需要被激活,从而减少CPU计算量;5) 神经元感知稀疏算子的设计,用于利用神经元激活的稀疏性来加速计算。
📊 实验亮点
PowerInfer在单个NVIDIA RTX 4090 GPU上,对各种LLM(包括OPT-175B)的推理速度比llama.cpp快高达11.69倍,同时保持了模型精度。对于OPT-30B模型,PowerInfer在单个消费级RTX 4090 GPU上达到了高端服务器级A100 GPU的82%的token生成速率。这些结果表明,PowerInfer能够显著提高消费级GPU上LLM推理的性能。
🎯 应用场景
PowerInfer的潜在应用领域包括:在本地个人电脑上运行大型语言模型,从而实现离线推理和隐私保护;在边缘设备上部署LLM,例如智能手机和嵌入式系统;为资源受限的用户提供低成本的LLM服务。该研究的实际价值在于降低了LLM的使用门槛,使得更多人能够受益于LLM技术。未来,PowerInfer可以进一步扩展到支持更多类型的LLM和硬件平台。
📄 摘要(原文)
This paper introduces PowerInfer, a high-speed Large Language Model (LLM) inference engine on a personal computer (PC) equipped with a single consumer-grade GPU. The key principle underlying the design of PowerInfer is exploiting the high locality inherent in LLM inference, characterized by a power-law distribution in neuron activation. This distribution indicates that a small subset of neurons, termed hot neurons, are consistently activated across inputs, while the majority, cold neurons, vary based on specific inputs. PowerInfer exploits such an insight to design a GPU-CPU hybrid inference engine: hot-activated neurons are preloaded onto the GPU for fast access, while cold-activated neurons are computed on the CPU, thus significantly reducing GPU memory demands and CPU-GPU data transfers. PowerInfer further integrates adaptive predictors and neuron-aware sparse operators, optimizing the efficiency of neuron activation and computational sparsity. The evaluation shows that PowerInfer significantly outperforms llama.cpp by up to 11.69x while retaining model accuracy across various LLMs (including OPT-175B) on a single NVIDIA RTX 4090 GPU. For the OPT-30B model, PowerInfer achieves performance comparable to that of a high-end server-grade A100 GPU, reaching 82% of its token generation rate on a single consumer-grade RTX 4090 GPU.