Table of Contents
Fetching ...

Improving Block-Wise LLM Quantization by 4-bit Block-Wise Optimal Float (BOF4): Analysis and Variations

Patrick Blumenberg, Thomas Graave, Tim Fingscheidt

TL;DR

This work identifies suboptimalities in existing 4-bit block-wise absmax quantization (NF4/AF4) for LLMs and introduces BOF4, a theoretically grounded EM/Lloyd-based codebook design that minimizes end-to-end MAE or MSE under block-wise normalization. A signed-absmax normalization (BOF4-S) further reduces quantization error by better representing largest-magnitude weights and zero, while outlier-preserving quantization (OPQ) stores outliers in higher precision to enable larger block sizes. The authors provide both analytical centroid updates and practical Monte-Carlo implementations, with extensive experiments across multiple LLM families showing lowered quantization errors and improved perplexity, both for inference and QLoRA-style fine-tuning. Collectively, these techniques enable more memory-efficient deployment on consumer hardware without sacrificing performance, and they supply open-codebooks and guidance for choosing MAE/MSE objectives and OPQ settings.

Abstract

Large language models (LLMs) demand extensive memory capacity during both fine-tuning and inference. To enable memory-efficient fine-tuning, existing methods apply block-wise quantization techniques, such as NF4 and AF4, to the network weights. We show that these quantization techniques incur suboptimal quantization errors. Therefore, as a first novelty, we propose an optimization approach for block-wise quantization. Using this method, we design a family of quantizers named 4-bit block-wise optimal float (BOF4), which consistently reduces the quantization error compared to both baseline methods. We provide both a theoretical and a data-driven solution for the optimization process and prove their practical equivalence. Secondly, we propose a modification to the employed normalization method based on the signed absolute block maximum (BOF4-S), enabling further reduction of the quantization error and empirically achieving less degradation in language modeling performance. Thirdly, we explore additional variations of block-wise quantization methods applied to LLMs through an experimental study on the importance of accurately representing zero and large-amplitude weights on the one hand, and optimization towards various error metrics on the other hand. Lastly, we introduce a mixed-precision quantization strategy dubbed outlier-preserving quantization (OPQ) to address the distributional mismatch induced by outlier weights in block-wise quantization. By storing outlier weights in 16-bit precision (OPQ) while applying BOF4-S, we achieve top performance among 4-bit block-wise quantization techniques w.r.t. perplexity.

Improving Block-Wise LLM Quantization by 4-bit Block-Wise Optimal Float (BOF4): Analysis and Variations

TL;DR

This work identifies suboptimalities in existing 4-bit block-wise absmax quantization (NF4/AF4) for LLMs and introduces BOF4, a theoretically grounded EM/Lloyd-based codebook design that minimizes end-to-end MAE or MSE under block-wise normalization. A signed-absmax normalization (BOF4-S) further reduces quantization error by better representing largest-magnitude weights and zero, while outlier-preserving quantization (OPQ) stores outliers in higher precision to enable larger block sizes. The authors provide both analytical centroid updates and practical Monte-Carlo implementations, with extensive experiments across multiple LLM families showing lowered quantization errors and improved perplexity, both for inference and QLoRA-style fine-tuning. Collectively, these techniques enable more memory-efficient deployment on consumer hardware without sacrificing performance, and they supply open-codebooks and guidance for choosing MAE/MSE objectives and OPQ settings.

Abstract

Large language models (LLMs) demand extensive memory capacity during both fine-tuning and inference. To enable memory-efficient fine-tuning, existing methods apply block-wise quantization techniques, such as NF4 and AF4, to the network weights. We show that these quantization techniques incur suboptimal quantization errors. Therefore, as a first novelty, we propose an optimization approach for block-wise quantization. Using this method, we design a family of quantizers named 4-bit block-wise optimal float (BOF4), which consistently reduces the quantization error compared to both baseline methods. We provide both a theoretical and a data-driven solution for the optimization process and prove their practical equivalence. Secondly, we propose a modification to the employed normalization method based on the signed absolute block maximum (BOF4-S), enabling further reduction of the quantization error and empirically achieving less degradation in language modeling performance. Thirdly, we explore additional variations of block-wise quantization methods applied to LLMs through an experimental study on the importance of accurately representing zero and large-amplitude weights on the one hand, and optimization towards various error metrics on the other hand. Lastly, we introduce a mixed-precision quantization strategy dubbed outlier-preserving quantization (OPQ) to address the distributional mismatch induced by outlier weights in block-wise quantization. By storing outlier weights in 16-bit precision (OPQ) while applying BOF4-S, we achieve top performance among 4-bit block-wise quantization techniques w.r.t. perplexity.
Paper Structure (50 sections, 74 equations, 10 figures, 10 tables)

This paper contains 50 sections, 74 equations, 10 figures, 10 tables.

Figures (10)

  • Figure 1: The blue histograms show the distributions of normalized weights$p_X(x)$ for block-wise absolute absmax normalization (left) and block-wise signed absmax normalization (right) assuming Gaussian network weights. Also shown are the resulting reconstruction levels$\hat{x}(\ell)$ ($\blacktriangledown$ fixed, $\blacktriangledown$ optimized) and decision thresholds $\xi(\ell)$ (dashed lines), after minimizing the $\mathrm{MSE}(\mathbf{W}, \mathbf{Q}(\mathbf{W}))$ for normally distributed network weights $\mathbf{W} = (w_{b,i})$ with $w_{b,i} \sim p_W = \mathcal{N}(0,1)$ and block size $I=64$. For absolute absmax normalization, we compute the 4-bit block-wise optimal float (BOF4, left), requiring three fixed reconstruction levels (-1, 0, 1). In contrast, when using signed normalization, we obtain BOF4-S (right), in which the largest absolute value in a block and zero are precisely represented by only two fixed reconstruction levels (0, 1), which reduces the quantization error.
  • Figure 2: MAE (left) and MSE (right) quantization error of our quantization methods BOF4 and BOF4-S optimized for MAE (left, ⁎) or MSE (right, $\circ$) compared to the baselines NF4 and AF4 for Gaussian network weights $\mathbf{W} = (w_{b,i})$ with $w_{b,i} \sim \mathcal{N}(0, 1)$ depending on the block size $I$.
  • Figure 3: Perplexity of Llama-3.1 8B on WikiText-2 after quantization with NF4, AF4, and our BOF4-S optimized w.r.t. MAE (left, ⁎) or MSE (right, $\circ$) for different block sizes $I$, with and without outlier-preserving quantization (OPQ, dashed line).
  • Figure 4: Difference in perplexity on WikiText-2 of Llama-3.1 8B quantized with BOF4 ($\mathrm{PPL}_{\mathrm{BOF}}$) vs. a codebook minimizing MSE of normalized weights ($\mathrm{PPL}_{\mathrm{NORM}}$). Lower values indicate better performance of BOF4.
  • Figure 5: Illustration of OPQ outlier detection. The histogram of absolute weights $\frac{|w_{b,i}|}{\sigma_b}$ of an example block $b$ with block size $I=64$ normalized to a unit standard deviation is shown in blue. Weights are identified as outliers (red hatching) iff they are greater than $F^{-1}_M(0.95)$, i.e., expected to be greater than $q=95\%$ of the absolute block maxima $|w_b^\mathrm{max}|$ according to the assumption of Gaussian-distributed network weights $w_{b,i}$. The corresponding PDF $p_M$ of absolute block maxima $|w_b^\mathrm{max}|$ is shown as a black solid line.
  • ...and 5 more figures