Skip to main content
QUICK REVIEW

[Paper Review] Understanding INT4 Quantization for Transformer Models: Latency Speedup, Composability, and Failure Cases

Xiaoxia Wu, Cheng Li|arXiv (Cornell University)|Jan 27, 2023
Ferroelectric and Negative Capacitance DevicesEngineering6 citations
TL;DR

This paper investigates INT4 quantization (W4A4) for transformer language models, demonstrating near-zero accuracy loss in encoder-only (BERT) and encoder-decoder (BART) models, but significant degradation in decoder-only (GPT) models. It introduces a highly optimized end-to-end INT4 inference pipeline that achieves up to 8.5× latency speedup over FP16 and 1.7× improvement over SOTA INT8 inference, while analyzing failure cases and composability with pruning and layer reduction.

ABSTRACT

Improving the deployment efficiency of transformer-based language models has been challenging given their high computation and memory cost. While INT8 quantization has recently been shown to be effective in reducing both the memory cost and latency while preserving model accuracy, it remains unclear whether we can leverage INT4 (which doubles peak hardware throughput) to achieve further latency improvement. In this study, we explore the feasibility of employing INT4 weight and activation (W4A4) quantization for language models. Our findings indicate that W4A4 quantization introduces no to negligible accuracy degradation for encoder-only and encoder-decoder models, but causes a significant accuracy drop for decoder-only models. To materialize the performance gain using W4A4, we develop a highly optimized end-to-end W4A4 encoder inference pipeline supporting different quantization strategies. Our INT4 pipeline is $8.5 imes$ faster for latency-oriented scenarios and up to $3 imes$ for throughput-oriented scenarios compared to the inference of FP16, and improves the SOTA BERT INT8 performance from FasterTransformer by up to $1.7 imes$. We provide insights into the failure cases when applying W4A4 to decoder-only models, and further explore the compatibility of INT4 quantization with other compression methods, like pruning and layer reduction.

Motivation & Objective

  • To evaluate the feasibility of W4A4 quantization (4-bit weights and activations) for transformer-based language models, particularly focusing on accuracy degradation.
  • To develop a high-performance, optimized end-to-end INT4 inference pipeline for encoder models that supports both latency- and throughput-oriented workloads.
  • To analyze the root causes of accuracy drops in decoder-only models (e.g., GPT) under W4A4 quantization.
  • To study the composability of INT4 quantization with other compression techniques such as pruning and layer reduction.
  • To improve upon existing SOTA INT8 inference performance by leveraging the higher throughput of INT4 computation on modern GPUs.

Proposed method

  • Utilizes layer-wise knowledge distillation with quantization-aware training (QAT) to enable W4A4 quantization for BERT and BART models.
  • Employs post-quantization techniques with dynamic range calibration and clipping to minimize accuracy loss during weight and activation quantization.
  • Designs a modular, highly optimized INT4 inference pipeline using CUDA kernels and Tensor Cores, supporting multiple quantization strategies for latency or throughput optimization.
  • Applies quantization to all linear layers, including attention and feed-forward networks, with full FP16 precision for residual connections to maintain stability.
  • Conducts ablation studies on layer normalization, pretraining effects, and attention mechanisms to isolate failure modes in decoder models.
  • Evaluates composability by combining W4A4 with 50% weight sparsity (Ampere-structure) and 25% layer reduction, measuring accuracy and performance trade-offs.
Understanding INT4 Quantization for Transformer Models: Latency Speedup, Composability, and Failure Cases

Experimental results

Research questions

  • RQ1Can W4A4 quantization be applied to encoder-only (BERT), encoder-decoder (BART), and decoder-only (GPT) transformer models with acceptable accuracy loss?
  • RQ2What are the primary causes of significant accuracy degradation in decoder-only models under W4A4 quantization?
  • RQ3How can an optimized end-to-end INT4 inference pipeline be designed to maximize latency and throughput improvements on modern GPU hardware?
  • RQ4To what extent can INT4 quantization be composed with other compression techniques like pruning and layer reduction without significant performance degradation?
  • RQ5Can the proposed INT4 pipeline achieve superior inference performance compared to existing SOTA INT8 implementations?

Key findings

  • W4A4 quantization results in no to negligible accuracy degradation for BERT (encoder-only) and BART (encoder-decoder) models on classification and summarization tasks.
  • Decoder-only models (e.g., GPT) experience a significant accuracy drop under W4A4 quantization, particularly in autoregressive generation tasks.
  • The proposed INT4 inference pipeline achieves up to 8.5× speedup in latency-oriented scenarios and up to 3× in throughput-oriented scenarios compared to HuggingFace FP16 inference.
  • The pipeline improves SOTA BERT INT8 performance from FasterTransformer by up to 1.7×, demonstrating the performance gains of INT4 over INT8.
  • Layer reduction experiments show that a 9-layer W4A4 BART model (6-encoder, 3-decoder) maintains 99.4% of the performance of the full 12-layer model on CNNDailyMail.
  • Composability experiments show that combining W4A4 with 50% sparsity causes only ~0.5 GLUE point degradation, and with 25% layer reduction, accuracy remains largely stable on summarization tasks.
Understanding INT4 Quantization for Transformer Models: Latency Speedup, Composability, and Failure Cases

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.