arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2411.06360cs.LGcs.DS
收藏

一种用于加速二值和三值神经网络推理的高效矩阵乘法算法

An Efficient Matrix Multiplication Algorithm for Accelerating Inference in Binary and Ternary Neural Networks

Department of Computer Science, University of Illinois at Chicago(伊利诺伊大学芝加哥分校计算机科学系)

Mohsen Dehghankar, Mahdi Erfanian, Abolfazl Asudeh

AI总结:

针对二值和三值神经网络推理效率低下的问题,提出一种基于权重矩阵预处理与索引的高效矩阵乘法算法,在时间和内存上实现对数级优化,在LLM推理中最高实现5.24倍加速。

摘要:

尽管深度神经网络(DNNs),如大型语言模型(LLMs),取得了巨大的成功并具有通用性,但它们存在推理效率低下的问题,并依赖于先进的计算基础设施。为了应对这些挑战并使这些模型更易获取且更具成本效益,本文提出了改进具有二值和三值权重矩阵的DNNs推理时间和内存效率的算法。特别关注作为推理瓶颈操作的矩阵乘法,我们观察到,模型一旦训练完成,其权重矩阵便不再改变。这使得我们能够预处理这些矩阵并创建索引,从而在对数因子级别减少存储需求,同时实现我们的高效推理算法。具体而言,对于一个 $n\times n$ 的权重矩阵,我们的高效算法保证了 $O(\frac{n^2}{\log n})$ 的时间复杂度,相较于标准的向量-矩阵乘法实现了对数因子的改进。除了理论分析外,我们还进行了广泛的实验以评估算法的实际效率。结果证实了我们的方法在时间和内存方面的优越性,我们观察到乘法时间最高减少了29倍,内存使用最高减少了6倍。应用于LLMs时,我们的实验表明推理时间最高实现了5.24倍的加速。

英文摘要:

Despite their tremendous success and versatility, Deep Neural Networks (DNNs) such as Large Language Models (LLMs) suffer from inference inefficiency and rely on advanced computational infrastructure. To address these challenges and make these models more accessible and cost-effective, in this paper, we propose algorithms to improve the inference time and memory efficiency of DNNs with binary and ternary weight matrices. Particularly focusing on matrix multiplication as the bottleneck operation of inference, we observe that, once trained, the weight matrices of a model no longer change. This allows us to preprocess these matrices and create indices that help reduce the storage requirements by a logarithmic factor while enabling our efficient inference algorithms. Specifically, for a $n\times n$ weight matrix, our efficient algorithm guarantees a time complexity of $O(\frac{n^2}{\log n})$, a logarithmic factor improvement over the standard vector-matrix multiplication. Besides theoretical analysis, we conduct extensive experiments to evaluate the practical efficiency of our algorithms. Our results confirm the superiority of our approach both with respect to time and memory, as we observed a reduction in the multiplication time up to 29x and memory usage up to 6x. When applied to LLMs, our experiments show up to a 5.24x speedup in the inference time.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑