Skip to main content
QUICK REVIEW

[论文解读] Efficient LLM Inference on CPUs

Haihao Shen, Hanwen Chang|arXiv (Cornell University)|Nov 1, 2023
Topic Modeling被引用 10
一句话总结

本论文介绍一种自动 INT4 权重专用量化流程和一个面向 CPU 的 LLM 运行时,以加速 CPU 上的推理,在最小的准确率损失下实现较快的每 token 延迟。它在从 3B 到 20B 参数的 LLM 上显示结果,使用单插槽第四代英特尔至强处理器。

ABSTRACT

Large language models (LLMs) have demonstrated remarkable performance and tremendous potential across a wide range of tasks. However, deploying these models has been challenging due to the astronomical amount of model parameters, which requires a demand for large memory capacity and high memory bandwidth. In this paper, we propose an effective approach that can make the deployment of LLMs more efficiently. We support an automatic INT4 weight-only quantization flow and design a special LLM runtime with highly-optimized kernels to accelerate the LLM inference on CPUs. We demonstrate the general applicability of our approach on popular LLMs including Llama2, Llama, GPT-NeoX, and showcase the extreme inference efficiency on CPUs. The code is publicly available at: https://github.com/intel/intel-extension-for-transformers.

研究动机与目标

  • 推动在 CPU 硬件上高效部署大型语言模型(LLMs)。
  • 提出一种利用 Intel Neural Compressor 的自动 INT4 权重专用量化流程。
  • 开发一个基于 CPU 调优的张量库和带有优化内核的 LLM 运行时。
  • 在第四代英特尔至强处理器上展示在主流 LLM(3B–20B)上的准确性和性能。

提出的方法

  • 使用 Intel Neural Compressor 的自动 INT4 量化流程,支持 GPTQ、SignRound、AWQ、TEQ、RTN,并具备可调粒度(分组大小如 32、64、128、... 1024)。
  • 生成高质量的 INT4 模型,相对于 FP32 基线的准确率损失<1%。
  • 一个以 CPU 为重点、受 ggml 启发的张量库,支持跨 ISA 范围(AVX2、AVX512、AVX512_VNNI、AMX)的 INT4 内核,以及动态输入量化。
  • 具备 KV-cache 优化的 LLM 运行时设计与 CPU-张量后端,实现高效的解码器-仅 Transformer 推理。
  • 在第四代英特尔至强可扩展处理器上对开源 LLM(3B–20B)进行评估,比较 ggml 基于实现。
Figure 1: The left part is the automatic INT4 quantization flow: given a FP32 model, the flow takes the default INT4 quantization recipes and evaluates the accuracy of INT4 model; the recipe tuning loop is optional, if INT4 model can meet the accuracy target. The right part is a simplified runtime f
Figure 1: The left part is the automatic INT4 quantization flow: given a FP32 model, the flow takes the default INT4 quantization recipes and evaluates the accuracy of INT4 model; the recipe tuning loop is optional, if INT4 model can meet the accuracy target. The right part is a simplified runtime f

实验结果

研究问题

  • RQ1自动 INT4 量化是否能够在跨不同 LLM 的情况下产生相对于 FP32 基线的精度损失小于 1% 的 INT4 模型?
  • RQ2与基于 ggml 的基线相比,CPU 优化的 LLM 运行时在 CPU 上进行下一个标记生成时的延迟性能如何?
  • RQ3在单插槽第四代英特尔至强 CPU 上部署 3B–20B 参数的 LLM 时,实际的延迟和准确性提升是多少?
  • RQ4哪些特定的 CPU 内核和 KV-cache 优化对 LLM 在 CPU 上的推理速度贡献最大?

主要发现

  • INT4 模型在多种 LLM(如 GPT-J 6B、Llama-2 7B、Llama 7B、GPT-NeoX 20B、Falcon 7B)中实现的精度在 FP32 基线的 <1% 范围内。
  • LLM 运行时对 ggml 基于解决方案的性能提升最高可达 1.6x(分组大小 128),对分组大小 32 的提升为 1.3x。
  • 在单个插槽的第四代英特尔至强可扩展处理器上,6B–20B 模型的每个 token 的生成延迟在 CPU 硬件上范围为 20 ms 到 80 ms。
  • 一个端到端的流水线,结合自动 INT4 量化和 CPU 调优运行时,在 CPU 上实现高效的 LLM 推理并保持准确性。
Figure 2: Key components in LLM runtime: general and LLM specialized.
Figure 2: Key components in LLM runtime: general and LLM specialized.

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。