arXiv:2501.00032cs.LGcs.AI2025-01被引 9

针对ARM CPU优化的低精度推理技术,显著提升大模型运行速度。

Highly Optimized Kernels and Fine-Grained Codebooks for LLM Inference on Arm CPUs

  • 设计专用内核与细粒度权重量化码本,降低计算开销。
  • 4比特模型在ARM上推理速度提升2-3.2倍,延迟大幅降低。
  • 适合在消费级CPU上部署高效率大模型,尤其适用于移动设备。

大语言模型(LLMs)改变了我们对语言理解与生成的认知,但其推理部署面临前所未有的规模与资源挑战。尽管将模型权重量化至亚字节精度可缓解内存压力,但现有分组量化格式存在显著计算开销和资源密集型反量化过程,导致大量计算指令无法执行乘法操作,难以满足通用CPU上的低延迟要求。本文提出一组高度优化的内核,专为加速LLM推理而设计,充分释放包括Arm CPU在内的通用处理器潜力。这些内核通过跨多个输出行分摊操作数加载和权重解包成本,结合优化的交错分组数据布局及压缩路径优化,减少冗余操作和反量化开销,最大化向量与矩阵乘法利用率。此外,提出一种基于分组非均匀码本的超低精度量化方法,更契合权重分布的非均匀特性,在保持更高质量的同时实现更高吞吐。应用于4比特LLM时,相比基于LLaMA.cpp的方案,提示处理速度提升3-3.2倍,自回归解码速度提升2倍。优化内核已开源:https://github.com/ggerganov/llama.cpp。

原文摘要 · Abstract (English)

Large language models (LLMs) have transformed the way we think about language understanding and generation, enthralling both researchers and developers. However, deploying LLMs for inference has been a significant challenge due to their unprecedented size and resource requirements. While quantizing model weights to sub-byte precision has emerged as a promising solution to ease memory pressure, the group quantization formats commonly used for LLM quantization have significant compute overheads and a resource-intensive dequantization process. As a result, a higher proportion of compute instructions do not perform multiplies, i.e., real work, rendering them unsuitable for meeting the required latency requirements for LLMs deployed on commodity CPUs. In this work, we propose a set of highly optimized kernels to accelerate LLM inference and unleash the full potential of CPUs, particularly Arm CPUs. These kernels amortize the cost of loading the operands and the cost of weight unpacking across multiple output rows. This, along with the introduction of an optimized interleaved group data layout for weights and decompression path optimizations to reduce unnecessary operations and dequantization overhead while maximizing the use of vector and matrix multiply operations, significantly improves the efficiency of MAC operations. Furthermore, we present a groupwise non-uniform codebook-based quantization method for ultra-low-precision quantization of LLMs to better match non-uniform patterns in their weight distributions, demonstrating better throughput during token generation while ensuring better quality than the state-of-the-art. Applying these improvements to 4-bit LLMs results in a 3-3.2x improvement in prompt processing and a 2x improvement in autoregressive decoding on Arm CPUs, compared to LLaMA.cpp-based solution. The optimized kernels are available at https://github.com/ggerganov/llama.cpp.

大模型推理量化ARM优化代码优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。