Lune

ICML2025Top-tier venue

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

Mohsen Dehghankar, Mahdi Erfanian, Abolfazl Asudeh

Abstract

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 × n weight matrix, our efficient algorithm guarantees a time complexity of O( 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. 1 Related Work is further discussed in Appendix B.

Ask Lune

Ask anything. The answer quotes the paper.

Lune reads all of it and the papers around it, then shows you the passages behind every answer.

Questions to start from

Lune answers from

the full paper · 1 top-tier paper that cites it · related work

Get the answer

Free to start. No credit card required.

Cited by top-tier papers1

  1. RTInfer: Real-Time Inference of Multiple DNNs on Edge GPUsRenjie Li, Tong Sun, Yi Gao, Wei DongICML 2026

Builds on3

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Ladder: Enabling Efficient Low-Precision Deep Learning Computing through Hardware-aware Tensor TransformationLei Wang, Lingxiao Ma, Shijie Cao, Quanlu Zhang et al.OSDI 2024 · 56 citations
  3. Fast Matrix Multiplications for Lookup Table-Quantized LLMsHan Guo, William Brandon, Radostin Cholakov, Jonathan Ragan-Kelley et al.EMNLP Findings 2024 · 5 citations

Related papers

  1. Computation and Memory-Efficient Model Compression with Gradient ReweightingZhiwei Li, Yuesen Liao, Binrui Wu, Yuquan Zhou et al.NeurIPS 2025
  2. Basis Sharing: Cross-Layer Parameter Sharing for Large Language Model CompressionJingcun Wang, Yu-Guang Chen, Ing-Chao Lin, Bing Li et al.ICLR 2025
  3. Scaling Laws and Efficient Inference for Ternary Language ModelsTejas Vaidhya, Ayush Kaushal, Vineet Jain, Francis Couture Harpin et al.ACL 2025
  4. Conv-Basis: A New Paradigm for Efficient Attention Inference and Gradient Computation in TransformersYingyu Liang, Heshan Liu, Zhenmei Shi, Zhao Song et al.EMNLP Findings 2025
  5. Differentiable Learning of Generalized Structured Matrices for Efficient Deep Neural NetworksChangwoo Lee, Hun-Seok KimICLR 2024 · 6 citations
Dusk over the sea between two cliffs drawn in fine vertical lines