LUT-GEMM: Quantized Matrix Multiplication based on LUTs for Efficient Inference in Large-Scale Generative Language Models

Gunho Park, Baeseong park, Minsub Kim, Sungjae Lee, Jeonghoon Kim, Beomseok Kwon, Se Jung Kwon, Byeongwook Kim, Youngjoo Lee, Dongsoo Lee

Large language models (LLMs) are heavily bottlenecked by memory bandwidth during text generation. To mitigate this, researchers widely use weight-only quantization. However, existing methods require costly on-the-fly dequantization to perform the actual math. This paper introduces LUT-GEMM, a novel GPU kernel that uses Look-Up Tables (LUTs) to perform matrix multiplications directly on quantized weights, eliminating dequantization overhead and achieving up to a 2.1x speedup over state-of-the-art methods like OPTQ.

The Problem: The Dequantization Bottleneck

During the generation phase of LLMs, predicting the next token is an autoregressive process. This step is notoriously "memory-bound"—the GPU spends more time moving massive model weights from memory to the compute cores than it does actually performing calculations.

To fix this, researchers use weight-only quantization, compressing 16-bit weights down to 3 or 4 bits while keeping the activations at 16 bits. This shrinks the memory footprint, allowing massive models to fit on fewer GPUs and reducing data transfer times.

However, current hardware doesn't natively support multiplying 4-bit integers with 16-bit floats. Consequently, existing frameworks (like OPTQ or AWQ) have to read the 4-bit weights and dequantize them back to 16-bit floats on the fly before doing the math. This dequantization process is resource-intensive, meaning current quantization methods save memory bandwidth but fail to actually reduce the computational workload.

Comparison of quantization schemes: (a) standard W8/A8, (b) W4/A16 with on-the-fly dequantization, and (c) the proposed LUT-GEMM bypassing dequantization.

The Solution: LUT-GEMM

The authors introduce LUT-GEMM, a custom GPU kernel that bypasses dequantization entirely by using Look-Up Tables (LUTs).

The method leverages Binary-Coding Quantization (BCQ), where weights are represented as binary vectors (+1 or -1) multiplied by a scaling factor. Because the weights are binary, multiplying them by full-precision activations results in a highly limited set of possible outcomes. Instead of doing the math on the fly, LUT-GEMM takes a chunk of the activation vector, pre-computes all possible dot-product combinations with the binary weights, and stores these answers in the GPU's ultra-fast shared memory as a Look-Up Table. During the actual matrix multiplication, the GPU simply "looks up" the pre-computed answers based on the binary weight patterns.

Crucially, the authors made two major upgrades to standard BCQ to make it viable for modern LLMs:

  1. Adding a Bias Term: This simple mathematical tweak allows their BCQ format to perfectly represent standard uniform quantization (the kind used by AWQ and OPTQ), making LUT-GEMM highly versatile.
  2. Group-Wise Quantization: Instead of one scaling factor per row, they share scaling factors across smaller "groups" of weights, allowing for a fine-grained trade-off between memory compression and accuracy.

Key Insights

  • Dequantization is a false necessity: You don't actually have to convert compressed weights back to full precision to do math with them. By reframing matrix multiplication as a lookup problem, you can skip the conversion step entirely and achieve true computational speedups.
  • BCQ is surprisingly adaptable: Historically, Binary-Coding Quantization was limited to symmetric, non-uniform quantization. By proving that adding a bias term allows BCQ to mimic standard uniform quantization, the authors bridged a gap, allowing their highly efficient LUT-based kernel to accelerate models quantized by popular existing methods.
  • Group size ($g$) is a hidden latency lever: In quantization, the "group size" dictates how many weights share a single scaling factor. While usually viewed as an accuracy hyperparameter, $g$ directly impacts the memory footprint of the scaling factors themselves. Tuning $g$ alongside the bit-width ($q$) provides a much richer search space for optimizing inference latency.

Performance and Results

The authors evaluated LUT-GEMM across standard NLP benchmarks (WikiText-2, PTB, C4, PIQA) and demonstrated remarkable efficiency gains:

  • Massive Speedups: When applied to a 3-bit quantized OPT-175B model, LUT-GEMM accelerated token generation latency by 2.1x on a single GPU compared to the OPTQ baseline.
  • Kernel-Level Efficiency: The LUT-GEMM kernel itself reduces computational complexity by 2.6x compared to previous GEMM kernels (like cuBLAS, OPTQ, and AWQ).
  • Hardware Reduction: LUT-GEMM enables running the massive OPT-175B model on a single A100 (80GB) GPU using 3-bit quantization. The FP16 baseline requires 8 GPUs to run. Remarkably, the single-GPU quantized version achieves comparable latency (51.6 ms/token) to the 8-GPU FP16 setup (42.4 ms/token), resulting in massive energy and hardware savings.

Limitations and Future Work

The primary limitation of LUT-GEMM is its focus on single-batch inference (batch size = 1). As the batch size increases, the performance gains of LUT-GEMM diminish. This happens because the memory bandwidth between the GPU compute cores and the LUTs stored in shared memory becomes a new bottleneck. However, the authors anticipate that this constraint will naturally lessen as future GPU architectures continue to improve shared memory bandwidth.

Summary updated

BibTeX
@inproceedings{park2024lut,
  author = {Gunho Park and Baeseong park and Minsub Kim and Sungjae Lee and Jeonghoon Kim and Beomseok Kwon and Se Jung Kwon and Byeongwook Kim and Youngjoo Lee and Dongsoo Lee},
  title = {{LUT-GEMM: Quantized Matrix Multiplication based on LUTs for Efficient Inference in Large-Scale Generative Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=gLARhFLE0F},
}
Figure