Abstract
Post-training quantization (PTQ) is a vital technique for deploying large-scale generative models on resource-constrained edge devices. However, the softmax activation layer is notoriously sensitive to quantization, often leading to catastrophic performance loss when converted to 8-bit integers. This paper identifies a systematic downward bias in quantized softmax outputs caused by the "rounding to zero" of small probability values. We introduce Softmax Bias Correction, a zero-cost offline method that estimates this bias using a small calibration set and absorbs it into existing quantization parameters. Our approach significantly improves the Signal-to-Quantization Noise Ratio (SQNR) in Stable Diffusion and reduces perplexity in Large Language Models (LLMs) without increasing inference latency.
1. Introduction
The computational demands of modern generative models, such as Transformers and Diffusion models, necessitate efficient execution strategies for mobile and edge deployment. 8-bit integer (INT8) quantization is a standard approach to reduce memory footprint and increase throughput. While weights and most activations are amenable to PTQ, the softmax layer remains a significant challenge. Developers frequently resort to keeping softmax in high precision (FP16 or FP32), creating a performance bottleneck.
Direct 8-bit quantization of softmax typically causes model quality to plummet. This degradation stems from the fact that softmax outputs are often sparse, with many values being smaller than the smallest representable step in an 8-bit grid. Consequently, up to 99% of these values are rounded to zero, causing the resulting "probabilities" to sum to significantly less than 1.0. In iterative models like Stable Diffusion, this systematic bias compounds over multiple steps, leading to the generation of low-quality or nonsensical outputs.
2. Methodology: Softmax Bias Correction
The core contribution of this work is a method to counteract systematic quantization noise through an offline calibration phase. The authors define the quantization bias as the difference between the expected value of the floating-point output and the quantized output.
By processing a small calibration dataset (e.g., 400 samples), the average "missing" probability mass is empirically estimated. To ensure zero overhead during inference, this bias is "absorbed" into the existing asymmetric quantization parameters—specifically by modifying the zero-point or offset. The researchers evaluated various granularities for this correction, concluding that a per-attention head approach provides the best balance between hardware compatibility and accuracy restoration.
3. Experimental Results
The effectiveness of Softmax Bias Correction was validated on two major benchmarks: Stable Diffusion v1.5 and the OPT-125M language model.
3.1 Stable Diffusion
In image generation tasks, uncorrected 8-bit quantization leads to a significant loss of detail and structural integrity. By applying bias correction, the SQNR was improved from 3.17 dB to 6.05 dB. Qualitative analysis demonstrates that the corrected 8-bit models produce images that are nearly indistinguishable from the FP32 baseline, effectively mitigating the error magnification inherent in the iterative diffusion process.
3.2 Large Language Models
For the OPT-125M model, evaluated on the Wiki-40b dataset, the method achieved a 4.8-point improvement in perplexity. This recovery is substantial in the context of LLM performance, indicating that the bias correction successfully restores the model's predictive capabilities.
4. Discussion and Conclusion
Softmax Bias Correction offers a practical, hardware-friendly solution for fully 8-bit generative pipelines. By addressing the systematic "rounding to zero" trap, the method restores model fidelity with zero additional compute cost at runtime.
Limitations include a dependency on the calibration dataset; while a small set of 400 samples proved sufficient in this study, performance may vary if deployment data significantly deviates from the calibration distribution. Future work should explore the applicability of this linear correction to ultra-low precision regimes (e.g., 4-bit) and newer architectures like Llama 3 or video-based generative models.
Summary updated