W4A16混合精度矩阵乘法在解耦架构上的应用:针对Ascend NPU的内核设计与内存瓶颈分析
W4A16 Mixed-Precision Matrix Multiplication on Decoupled Architecture: Kernel Design and Memory Bottleneck Analysis for Ascend NPUs
AI总结:
本研究提出适用于Ascend NPU的W4A16混合精度矩阵乘法内核,通过优化解耦架构实现高效量化,发现内存传输是主要瓶颈,最大加速比达1.48倍。
摘要:
随着大语言模型(LLMs)的扩展,仅权重量化(W4A16:4位权重,16位激活)成为减少内存占用且最小化精度损失的关键。然而,其在华为Ascend 910神经处理单元(NPU)上的高效部署面临挑战,因为该加速器的解耦计算架构有限的原生混合精度支持。为了在这样的架构上实现量化,我们提出了首个适用于Ascend 910 NPU的W4A16矩阵乘法内核。我们的设计利用向量核心进行实时的INT4到FP16反量化,利用立方核心实现高吞吐量的GEMM,以及Split-K并行化以缓解内存延迟。在各种矩阵形状和批量大小的性能评估中,我们的方法在K>>N(LLM解码中的典型场景)时优于数据并行方法。特别地,我们的方法可以实现1.01倍到1.74倍的加速。此外,我们的分析揭示出主要瓶颈不是反量化计算本身,而是额外的全局内存传输用于权重,使W4A16在PyTorch中仅达到FP16xFP16矩阵乘法的最大加速倍数为1.48倍。长远来看,我们的方法为在各种领域专用加速器上高效部署量化的大语言模型奠定了坚实基础,并提供了有价值的见解。
英文摘要:
As Large Language Models (LLMs) scale, weight-only quantization (W4A16: 4-bit weights, 16-bit activations) becomes critical for reducing memory footprint with minimal accuracy loss. However, its efficient deployment on Huawei's Ascend 910 Neural Processing Unit (NPU) is challenging due to limited native mixed-precision support and the accelerator's decoupled compute architecture. To enable quantization on such architecture, we present the first practical W4A16 matrix multiplication kernel tailored for the Ascend 910 NPU. Our design leverages vector cores for on-the-fly INT4-to-FP16 dequantization, cube cores for high-throughput GEMM, and Split-K parallelization to mitigate memory latency. Performance evaluations across diverse matrix shapes and batch sizes show our method outperforms data-parallel approaches when K >> N, a typical scenario in LLM decoding. Specially, our method can achieve a speedup ranging from 1.01x to 1.74x. In addition, our profile reveals the primary bottleneck is not dequantization compution itself, but extra global memory transfer for the weight, making W4A16 only reaching a maximum speedup of 1.48x over native FP16xFP16 matrix multiplication in PyTorch. In the long run, our method lays a solid foundation and provides insightful views for the efficient deployment of quantized large language models on various domain-specific accelerators.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。