为量化推理设计混合精度矩阵乘法,显著提升多架构性能。
The Cambrian Explosion of Mixed-Precision Matrix Multiplication for Quantized Deep Learning Inference
- 重构经典矩阵乘法,适配现代CPU的混合精度整数运算。
- 在x86_64、ARM、RISC-V上实现比浮点方案更高性能。
- 适合关注边缘设备推理优化的研究者与工程师。
深度学习的发展促使计算从传统的64位浮点(FP64)转向低精度格式,如FP16、BF16及8/16位整数,并结合混合精度算术。这一转变提升了计算吞吐量,降低了内存和带宽消耗,改善了能效,特别有利于资源受限的边缘设备。为此,硬件架构也相应演进,包括支持混合精度向量单元和面向深度学习任务的矩阵引擎的定制指令集(ISA)。矩阵-矩阵乘法(gemm)是深度学习与科学计算的核心基础,传统上依赖SIMD单元上的axpy向量指令进行优化。然而,随着硬件转向以点积为中心的混合精度操作,服务于量化推理,这些旧方法正逐步被淘汰。本文重新审视经典高性能gemm,提出适应现代ISA(x86_64、ARM、RISC-V)的混合精度整数(MIP)算术策略,展示新型微核设计与数据布局,有效利用专用硬件,在三种代表性CPU架构上实现了显著优于浮点实现的性能。这些工作标志着由深度学习推理需求驱动的gemm优化新纪元,我们称之为矩阵乘法的‘寒武纪时期’。
原文摘要 · Abstract (English)
Recent advances in deep learning (DL) have led to a shift from traditional 64-bit floating point (FP64) computations toward reduced-precision formats, such as FP16, BF16, and 8- or 16-bit integers, combined with mixed-precision arithmetic. This transition enhances computational throughput, reduces memory and bandwidth usage, and improves energy efficiency, offering significant advantages for resource-constrained edge devices. To support this shift, hardware architectures have evolved accordingly, now including adapted ISAs (Instruction Set Architectures) that expose mixed-precision vector units and matrix engines tailored for DL workloads. At the heart of many DL and scientific computing tasks is the general matrix-matrix multiplication gemm, a fundamental kernel historically optimized using axpy vector instructions on SIMD (single instruction, multiple data) units. However, as hardware moves toward mixed-precision dot-product-centric operations optimized for quantized inference, these legacy approaches are being phased out. In response to this, our paper revisits traditional high-performance gemm and describes strategies for adapting it to mixed-precision integer (MIP) arithmetic across modern ISAs, including x86_64, ARM, and RISC-V. Concretely, we illustrate novel micro-kernel designs and data layouts that better exploit today's specialized hardware and demonstrate significant performance gains from MIP arithmetic over floating-point implementations across three representative CPU architectures. These contributions highlight a new era of gemm optimization-driven by the demands of DL inference on heterogeneous architectures, marking what we term as the "Cambrian period" for matrix multiplication.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。