BiQGEMM: Matrix Multiplication with Lookup Table For Binary-Coding-based Quantized DNNs

Yongkweon Jeon, Baeseong Park, Se Jung Kwon, Byeongwook Kim, Jeongin Yun, Dongsoo Lee

Abstract

The number of parameters in deep neural networks (DNNs) is rapidly increasing to support complicated tasks and to improve model accuracy. Correspondingly, the amount of computations and required memory footprint increase as well. Quantization is an efficient method to address such concerns by compressing DNNs such that computations can be simplified while required storage footprint is significantly reduced. Unfortunately, commercial CPUs and GPUs do not fully support quantization because only fixed data transfers (such as 32 bits) are allowed. As a result, even if weights are quantized into a few bits, CPUs and GPUs cannot access multiple quantized weights without memory bandwidth waste. Success of quantization in practice, hence, relies on an efficient computation engine design, especially for matrix multiplication that is a basic computation engine in most DNNs. In this paper, we propose a novel matrix multiplication method, called BiQGEMM, dedicated to quantized DNNs. BiQGEMM can access multiple quantized weights simultaneously in one instruction. In addition, BiQGEMM pre-computes intermediate results that are highly redundant when quantization leads to limited available computation space. Since pre-computed values are stored in lookup tables and reused, BiQGEMM achieves lower amount of overall computations. Our extensive experimental results show that BiQGEMM presents higher performance than conventional schemes when DNNs are quantized.

Introduction

As deep learning models grow in complexity, quantization has become a standard technique for model compression. However, a significant "hardware-software gap" exists: modern CPUs and GPUs are optimized for 32-bit or 16-bit data. When weights are reduced to 2 or 3 bits, these processors often waste memory bandwidth or require expensive "unpacking" steps to convert bits back into a format suitable for calculation.

In real-time applications like voice assistants or translation, inference often occurs in "few-batch" scenarios where the system is memory-bound. In these cases, the processor spends more time waiting for weights to arrive from memory than performing actual calculations. BiQGEMM (Binary-coding-based Quantized GEMM) addresses this by exploiting the limited computation space created by quantization, replacing redundant arithmetic with fast lookup table (LUT) retrievals.

Binary-Coding-based Quantization

The foundation of BiQGEMM is binary-coding-based quantization. Unlike standard uniform quantization, which maps values to a linear grid, this method represents weights as a sum of binary matrices (containing only -1 and 1) multiplied by scaling factors.

Binary-coding-based quantization vs. uniform quantization (INT4)

This representation allows multiple quantized weights to be packed into a single machine word. By doing so, BiQGEMM can access multiple weights simultaneously in one instruction, effectively bypassing the memory bandwidth limitations of commodity hardware.

The BiQGEMM Algorithm

BiQGEMM accelerates matrix multiplication by transforming the process from arithmetic-heavy to memory-retrieval-heavy. The core mechanism involves two main stages:

1. Efficient Table Construction

For a small chunk of an input vector (a "LUT-unit" $\mu$), there are only $2^\mu$ possible results when multiplied by a corresponding chunk of binary weights. BiQGEMM pre-computes these $2^\mu$ outcomes on-the-fly. To keep overhead low, the algorithm uses a Dynamic Programming approach to build these tables in $O(2^\mu)$ time, which is significantly faster than naive matrix multiplication.

2. Retrieval-based Computation

During the actual matrix multiplication, the algorithm does not perform standard multiply-accumulate operations. Instead, it uses the bit-packed weights directly as indices (keys) to pull pre-computed results from the LUT.

The BiQGEMM process: bit-packing weights into keys for LUT retrieval

This approach effectively merges the "unpacking" and "calculation" steps into a single memory access. To ensure high performance, a "LUT-stationary" tiling strategy is used to keep the lookup tables in fast on-chip memory (SRAM or Cache) as long as possible.

Experimental Results

The researchers evaluated BiQGEMM primarily on Natural Language Processing (NLP) tasks using Transformer and LSTM architectures across mobile CPUs, desktop CPUs, and high-end GPUs.

  • Speedups: On mobile CPUs (ARM Cortex-A76), BiQGEMM achieved nearly a 10x speedup over the full-precision Eigen library for 1-bit weights. On the NVIDIA Tesla V100, it was up to 30x faster than standard kernels for large matrices at small batch sizes.
  • Accuracy: Using 3-bit quantization, a Transformer model on the WMT13 English-to-German dataset achieved a BLEU score of 25.5, very close to the 32-bit baseline of 25.8.
  • Efficiency: The Dynamic Programming method for building LUTs was shown to be $\mu$ times faster than naive approaches, justifying the on-the-fly construction cost.

Conclusion

BiQGEMM demonstrates that redundancy in quantized spaces is an opportunity for performance optimization. By replacing redundant arithmetic with memoization via lookup tables, it provides a software-level innovation that accelerates DNNs on existing phones and laptops. While most effective for memory-bound, small-batch scenarios, future hardware optimizations for non-sequential memory access could further enhance its utility in broader deep learning workloads.

Summary updated

BibTeX
@inproceedings{jeon2020biqgemm,
  author = {Yongkweon Jeon and Baeseong Park and Se Jung Kwon and Byeongwook Kim and Jeongin Yun and Dongsoo Lee},
  title = {{BiQGEMM: Matrix Multiplication with Lookup Table For Binary-Coding-based Quantized DNNs}},
  booktitle = {SC},
  year = {2020},
  url = {https://openreview.net/forum?id=uqRlAcWY4sH},
}
Figure