Manuscript Offprint

arXiv:2610.08231

OSFP4: Joint Optimization of Diagonal Smoothing and Block Scales for NVFP4 Quantization

Neriah Ben David, Ori Meir, Or Ordentlich

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

NVFP4 is an attractive datatype for large language model (LLM) inference, offering compact storage and native tensor-core acceleration. However, preserving accuracy using NVFP4 requires careful quantization. In this work we develop a novel quantization scheme called Optimized Smoothing and Scaling for NVFP4 (OSFP4). For each linear projection it uses a diagonal smoothing matrix whose entries are optimized to minimize the squared matrix-product quantization error under NVFP4, taking into account the rounding procedure that is used (either round-to-nearest, or GPTQ-style successive interference cancellation). This requires performing joint optimization on the smoothing entries as well as the block scales, which is facilitated by analyzing a multiplicative-dither FP4 quantizer instead of the fixed deterministic one. Experiments show that OSFP4 achieves the highest average accuracy among the evaluated competitors in the corresponding quantization settings, while retaining approximately 94-97% of vendor NVFP4 prefill throughput on the measured workloads. Our code is available here.

1 INTRODUCTION

Low-bit data formats are gaining much popularity for large language models (LLMs) inference, as they require less memory for storing and running the model, decrease the traffic from and to memory, and allow to execute matrix multiplication (MatMul) faster through optimized hardware. The FP4 datatype stands out as a prominent representative of such formats which is heavily used in models running on NVIDIA's Blackwell series and its subsequent generations. Unfortunately, using FP4 instead of higher resolution formats such as FP8 often comes with the cost of reduced accuracy. The goal of this paper is to develop a quantization scheme for NVFP4 that jointly optimizes a diagonal smoothing transformation, as well as the weight block scales in order to maintain maximal accuracy.

At first thought, it is not at all clear that diagonal smoothing is useful for FP4 quantization. Traditionally, the main differentiator between INT constellations and FP constellations was the dynamic range. An INT-R constellation has fixed spacing between constellation points, and its dynamic range is therefore proportional to 2R2^R. Absmax scaling is often used to make sure the input fits within the dynamic range, and the corresponding per-entry mean-squared error (MSE) in representing x∈Rnx \in \mathbb{R}^n in INT-R is consequently proportional to ∥x∥∞2⋅2−2R\|x\|_\infty^2 \cdot 2^{-2R} Ordentlich & Polyanskiy (2026a). For this reason, one of the key aspects in INT-based quantization techniques is controlling the infinity norm of the quantizer's input. Diagonal scaling can help balance the infinity norms of vectors participating in MatMul, and indeed one of the simplest and most efficient techniques for INT-quantized MatMul is SmoothQuant Xiao et al. (2023).

For FP constellations with EE exponent bits, the dynamic range is proportional to 22E2^{2^E}, and can be made “essentially unbounded” with as few as E=4E = 4 exponent bits, as in the standard E4M3 FP8 datatype. The MSE in representing the iith entry xix_i of x∈Rnx \in \mathbb{R}^n is therefore proportional to

∗^{*}The authors are listed in alphabetical order.

∣xi∣2⋅2−2M|x_i|^2 \cdot 2^{-2M}, where MM is the number of mantissa bits, provided that xix_i is inside the constellation's dynamic range Ordentlich & Polyanskiy (2026a). For this reason, quantization to FP is typically considered simpler, and requires less pre and post processing than quantization to INT constellations. In particular, whenever EE is large enough so that dynamic range is not a limiting factor, SmoothQuant-style diagonal scaling is quite useless, as E[(QFP(Xi⋅α)QFP(Yi/α)−XiYi)2]\mathbb{E}[(Q_{\mathrm{FP}}(X_i \cdot \alpha)Q_{\mathrm{FP}}(Y_i/\alpha) - X_iY_i)^2] is proportional to E[∣Xi∣2∣Yi∣2]2−2M\mathbb{E}[|X_i|^2|Y_i|^2]2^{-2M} for all α>0\alpha > 0 provided that the distribution of (Xi,Yi)(X_i, Y_i) is “sufficiently smooth” and Xi⋅αX_i \cdot \alpha and Yi/αY_i/\alpha are within the quantizer’s dynamic range with high probability.

The picture is different for the FP4 E2M1 format since with E=2E = 2 the dynamic range is too small to be ignored. To combat the effect of limited dynamic range, FP4 is usually applied with microscaling as in MXFP4 or NVFP4, where a group of gg entries are also given a common scale γ\gamma. In MXFP4 g=32g = 32 and γ\gamma is represented in E8M0 format, whereas in NVFP4 g=16g = 16 and γ\gamma is represented in E4M3 format. Here we focus on NVFP4, which is becoming a common choice for models running on NVIDIA hardware, though some of the techniques we develop may also be useful for MXFP4 as well.

The scale γ\gamma can be used to ensure that the input to the FP4 quantizer never exceeds 6, which is the largest value in the FP4 constellation. In particular, for x∈R16x \in \mathbb{R}^{16} the default absmax-to-6 rule sets γ≈∥x∥∞/6\gamma \approx \|x\|_\infty / 6 such that ∥γ−1x∥∞≈6\|\gamma^{-1}x\|_\infty \approx 6. This rule takes care of the upper limit of the dynamic range: it ensures that no entry of γ−1x\gamma^{-1}x is large enough to saturate the quantizer. However, with this rule all entries with magnitude 24 times smaller than ∥x∥∞\|x\|_\infty will be quantized to 0, so that the total distortion can be quite large when xx is largely unbalanced. Furthermore, even for balanced vectors, there are multiple choices of γ\gamma for which all entries of γ−1x\gamma^{-1}x are within the dynamic range of the FP4 constellation, and careful optimization of γ\gamma may yield significant reduction of MSE over the absmax-to-6 rule.

This work develops an NVFP4 quantization method that utilizes a diagonal matrix A∈Rn×nA \in \mathbb{R}^{n \times n} for “smoothing” the weight matrix W∈Rm×nW \in \mathbb{R}^{m \times n} to WA−1WA^{-1} and the activation matrix X∈Rn×kX \in \mathbb{R}^{n \times k} to AX, as in SmoothQuant. The clear advantage of diagonal A with respect to more general structures for A, e.g. block-rotation Egiazarian et al. (2026), PCA directions aligning Chen et al. (2025), tensor of dense small matrices Sun et al. (2025), is that diagonal pre-processing is cheap and can easily be done in runtime for the activations. In fact, in some layers it can be fused into the LayerNorm or RMSnorm.

In contrast to SmoothQuant where A is used for balancing infinity norms, the role of the matrix A here is more intricate. It should balance the distribution of all entries within the same groups (16 consecutive entries) in the rows of W and in the columns of X, so that the corresponding E4M3 scales can then be used to minimize the MSE. Developing a mathematical formulation that accurately captures this objective is one of the main challenges addressed in this work. This is achieved by analyzing a randomized multiplicatively dithered FP4 quantizer instead of the deterministic one, which is actually used by our scheme. The distortion incurred by the randomized quantizer admits a relatively simple form using the function ϕ(⋅)\phi(\cdot) introduced below (See Figure 1), and is closely related to the distortion incurred by the deterministic quantizer (Lemma 1). This in turn enables to jointly optimize the smoothing weight matrix and the block scales.

Using the fixed weights and calibration activations, we optimize the diagonal entries of A and the block scales offline in two stages. In the first stage we jointly optimize the diagonal entries of A and the block scales with respect to a dithered FP4 quantizer, whose corresponding MSE loss is smooth and amenable to optimization. Crucially, the loss takes into account whether round-to-nearest (RTN) or successive-interference-cancellation (SIC) will be used for the actual weight quantization. The resulting A is retained, while the weight scales are finely optimized over the E4M3 grid in the second stage. Activation scales must instead be determined in real time; our default is absmax-to-6.

Our main contributions are:

• We develop an expression that approximates the expected squared Frobenius norm of the matrix-product error under randomized FP4 quantization for diagonally smoothed NVFP4 quantization, as a function of the smoothing parameters and the group scales. This expression takes into account the rounding procedure (RTN/SIC) for W, and is amenable to efficient joint optimization of all participating parameters.

• Relying on this approximation, we develop a quantization scheme called Optimized Smoothing and Scaling for NVFP4 (OSFP4) quantization. This scheme uses the approximation to perform joint continuous optimization of diagonal smoothing and block scales, followed by discrete E4M3 weight-scale selection. The optimization criterion for the discrete weight-scale depends on the calibration second-moments as well as on the rounding method (RTN/SIC). The activation group scales are set using absmax-to-6.

• Experiments show that OSFP4 achieves the highest average accuracy among the evaluated competitors in the corresponding quantization settings, while retaining approximately 94-97% of vendor NVFP4 prefill throughput on the measured workloads.

• We provide an add-on package for LLM Compressor AI & vLLM Project (2024) that implements our OSFP4 compression method and exports quantized models as vLLM checkpoints, together with a vLLM plugin that support the additional diagonal smoothing layers.

References (66)