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

要約

大規模言語モデル(Large Language Models:LLM)のようなディープニューラルネットワーク(Deep Neural Network:DNN)は、その大きな成功と汎用性にもかかわらず、推論効率の悪さに苦しみ、高度な計算インフラに依存している。これらの課題に対処し、これらのモデルをより利用しやすく、費用対効果の高いものにするために、本稿では、2値及び3値の重み行列を持つDNNの推論時間とメモリ効率を改善するアルゴリズムを提案する。特に推論のボトルネックとなる行列の乗算に着目し、一度学習したモデルの重み行列はもはや変化しないことを観察する。これにより、これらの行列を前処理し、効率的な推論アルゴリズムを可能にしながら、ストレージの必要量を対数倍削減するのに役立つインデックスを作成することができる。具体的には、$n倍n$の重み行列に対して、我々の効率的なアルゴリズムは$O(˶frac{n^2}{log n})$の時間複雑度を保証し、標準的なベクトルと行列の掛け算に対して対数倍改善する。理論的な解析に加えて、我々のアルゴリズムの実用的な効率を評価するために広範な実験を行った。その結果、乗算時間は最大29倍、メモリ使用量は最大6倍の削減が確認され、時間とメモリの両面で本アプローチの優位性が確認された。LLMに適用した場合、我々の実験では推論時間が最大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.

arxiv情報

著者 Mohsen Dehghankar,Mahdi Erfanian,Abolfazl Asudeh
発行日 2025-05-02 16:58:10+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, DeepL

カテゴリー: cs.DS, cs.LG パーマリンク