I-LLM: Efficient Integer-Only Inference for Fully-Quantized Low-Bit Large Language Models

Xing Hu, Yuan Cheng, Dawei Yang, Zhihang Yuan, Jiangyong Yu, Chen Xu, Sifan Zhou

Introduction

Post-training quantization (PTQ) is a critical technique for deploying Large Language Models (LLMs) on resource-constrained devices. However, most current quantization methods are "fake quantized," relying on floating-point (FP) arithmetic for non-linear operators like Softmax and RMSNorm, and converting weights back to FP during computation. This reliance on FP units creates a significant bottleneck for edge and cloud hardware optimized for integer operations.

The Challenge: Activation Fluctuations

The primary obstacle to true integer-only quantization in LLMs is the extreme variation in activation values. These fluctuations occur across two dimensions:

  1. Inter-channel variation: Specific channels exhibit massive spikes in activation values, often several orders of magnitude higher than the mean.
  2. Inter-token variation: Values fluctuate significantly between different tokens in a sequence, making static quantization ranges ineffective.
Statistical distribution of activations showing outliers across channel and token indices.

These outliers make it difficult to map activations to a low-bit integer range without losing significant information or precision. Standard quantization methods often clip these values or use a scale that washes out the smaller, more frequent values that carry the bulk of the model's information.

The I-LLM Framework

To address these challenges, the authors propose I-LLM, a novel PTQ framework designed for fully integer-only inference. I-LLM introduces three key technical innovations that allow the model to remain in the integer domain throughout the entire inference pass.

1. Fully-Smooth Block-Reconstruction (FSBR)

FSBR aggressively smooths inter-channel variations by balancing the variance between activations and weights across the entire model. While previous "smoothing" techniques existed, they were often limited to linear layers. I-LLM's breakthrough is the decomposition of non-linear functions like SiLU (within SwiGLU units) into smoothable components. By breaking $SiLU(x)$ into $x \cdot \sigma(x)$, the authors can apply smoothing factors to the non-linear part of the transformer block, making the data distribution significantly more amenable to quantization.

2. Dynamic Integer-only MatMul (DI-MatMul)

To handle inter-token variations, I-LLM utilizes dyadic numbers—rational numbers of the form $n/2^k$, where $n$ and $k$ are integers. This representation allows the model to perform dynamic scaling during matrix multiplication using only integer multiplication and bit-shifts. By avoiding floating-point division entirely, DI-MatMul brings the benefits of dynamic range adjustment to integer-only hardware, ensuring that each token's unique distribution is preserved.

3. Integer-only Non-linear Operators

Modern LLMs rely heavily on transcendental functions like exponents in Softmax or square roots in RMSNorm. I-LLM introduces "Dynamic Integer" (DI) versions of these operators:

  • DI-Normalization: Efficiently handles layer and RMS normalization using integer-only arithmetic.
  • DI-Exp and DI-ClippedSoftmax: These approximate the exponential function and Softmax using linear interpolation and bit-shifts. DI-ClippedSoftmax is particularly effective because it ignores extreme outliers that do not contribute to the final probability distribution, thereby saving precious bit-precision for the values that actually matter for the model's output.
3D landscape of activations highlighting the significant spikes that hinder standard quantization.

Experimental Results

I-LLM was evaluated on LLaMA (7B to 30B), LLaMA2, LLaMA3-8B, and the OPT model families across various benchmarks, including WikiText2, C4, and zero-shot reasoning tasks like PIQA and ARC.

  • W4A4 Performance: I-LLM achieves near-lossless accuracy at 4-bit weights and 4-bit activations. In many tests, it achieved perplexity scores 10% to 30% lower than existing state-of-the-art quantization methods like OmniQuant.
  • Surpassing FP Baselines: Notably, on the LLaMA-30B model at W6A6, I-LLM achieved an average zero-shot accuracy of 67.99%, surpassing the original FP16 baseline of 67.44%. This suggests that the smoothing and reconstruction process might even have a slight regularizing effect.

Conclusion

I-LLM is the first framework to successfully bridge the gap between integer-only quantization and the complex architecture of modern LLMs. By eliminating the need for floating-point units during inference, it paves the way for efficient LLM deployment on a wider range of hardware, from mobile chips to high-throughput cloud accelerators.

Summary updated

BibTeX
@misc{hu2024i,
  author = {Xing Hu and Yuan Cheng and Dawei Yang and Zhihang Yuan and Jiangyong Yu and Chen Xu and Sifan Zhou},
  title = {{I-LLM: Efficient Integer-Only Inference for Fully-Quantized Low-Bit Large Language Models}},
  year = {2024},
  eprint = {2405.17849},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.17849},
}
Figure