MXAttention: Data-Free Optimal Scaling and Pre-Normalization Quantization for MXFP4 Attention

Jianlin Yu, Jing Lin, Linghui Kong, Aiyue Chen, Weiyi Sun, Chenyu Zeng, Wangli Lan, Jinxi Li, Zhuo Zheng, Ziyang Yue, Danning Ke, Fei Yi, Tianchi Hu, Yuan Ding, Yiwu Yao, Junsong WangarXiv 2026

TL;DR

MXAttention is a data-free post-training quantization framework that enables near-lossless 4-bit (MXFP4) attention acceleration for video diffusion models without requiring calibration data or retraining. By mathematically resolving the block-scaling trade-off and fixing a subtle normalization mismatch inside the online softmax loop, it preserves full-precision video quality with negligible computational overhead.

What Problem Does This Paper Address?

Video diffusion Transformers (such as Wan2.2 and HunyuanVideo) generate stunning, high-resolution videos but suffer from massive computational bottlenecks due to the quadratic complexity of attention mechanisms. Quantizing attention tensors to ultra-low precision formats like 4-bit (FP4) is a highly attractive solution supported by modern hardware architectures (e.g., NVIDIA Blackwell, AMD Instinct, and Ascend 950).

However, directly applying the open-standard MXFP4 format severely degrades video generation quality. The authors identify two core numerical failure modes responsible for this degradation:

  1. The Clipping-Underflow Trade-off: MXFP4 uses a shared power-of-two scale factor for blocks of 32 elements. Standard scaling rules either clip large outlier values (causing saturation) or underflow small values to zero, introducing massive quantization noise.
  2. Softmax Normalization Mismatch: In optimized attention implementations like FlashAttention, the unnormalized softmax exponentials are quantized for the output update but left unquantized for the row-wise sum accumulation. This breaks the fundamental mathematical guarantee that attention probabilities must sum to one, leading to severe error propagation across layers.

Methods

The authors introduce MXAttention, a fully data-free post-training quantization (PTQ) framework that integrates seamlessly into the FlashAttention pipeline via two main components:

  • Universal Optimal Scaling (UOS): Instead of relying on expensive per-layer empirical searches or calibration datasets, the authors mathematically prove that power-of-two block microscaling creates a log-periodic structure. This structure makes the optimal scaling boundary completely independent of the underlying data distribution. They derive a closed-form, global optimal boundary $Q_{max} = 7.25$ that minimizes quantization error across any layer or model.
  • Pre-Normalization Quantization (PNQ): To eliminate the normalization mismatch, PNQ ensures that the exact same quantized unnormalized softmax exponential tile is reused for both the row-wise sum and the output-accumulator updates. This preserves row-wise normalization by construction.

Additionally, a standard Hadamard Rotation is applied to the Query ($Q$) and Key ($K$) matrices to suppress activation outliers before quantization.

Overview of the MXAttention pipeline integrating UOS and PNQ into FlashAttention

Datasets

The method was evaluated on two state-of-the-art large-scale video diffusion models:

  • Wan2.2-14B
  • HunyuanVideo-13B

The evaluation utilized a fixed prompt subset from the Open-Sora prompt suite. Video generation quality was benchmarked using VBench (evaluating Subject Consistency, Imaging Quality, and Aesthetic Quality), alongside frame-level similarity metrics (Cosine Similarity, SSIM, and PSNR) to measure fidelity against the FP16 baseline.

Key Insights and Ideas

  • The Magic Number 7.25: The most surprising insight is that the optimal scaling boundary for MXFP4 is universally $7.25$, whether the underlying data distribution is Gaussian, log-uniform, or highly skewed. Power-of-two scaling forces a periodic boundary condition where distribution-specific harmonics alter the shape of the error curve but never shift the location of its minimum.
  • FlashAttention's Hidden Flaw: Standard quantization approaches break FlashAttention's online softmax because they mix quantized and unquantized paths. Fixing this doesn't require extra memory or additional passes over the attention matrix; simply syncing the quantization point (PNQ) ensures mathematical consistency.
Figure 2: UOS objective under different wrapped distributions. (a) Percentage increase in the objective relative to its value at q = 7.25 under a log-uniform density. (b) The same quantity under representative nonuniform wrapped densities. Distribution-specific harmonics change the curve shapes, but all cases share the minimum q = 7.25.

Key Results

  • Near-Lossless Quality: On Wan2.2, MXAttention recovers 95.4% of the Imaging Quality gap between standard OCP MXFP4 and FP16. On HunyuanVideo, it fully closes the gap and slightly outperforms the FP16 baseline on VBench metrics.
  • Minimal Degradation: Across all reported VBench metrics, MXAttention exhibits less than 0.01 absolute degradation compared to full FP16 precision.
  • Frame-level Fidelity: Frame-level structural similarity (SSIM) jumps drastically compared to standard MXFP4 (e.g., from 0.5076 to 0.6319 on Wan2.2), significantly reducing visual artifacts, blurring, and identity drifting.
  • Zero Overhead: Because PNQ reuses already-quantized tiles and UOS relies on a fixed constant, the framework introduces negligible algorithmic overhead and is highly fusion-friendly for hardware deployment.

Limitations and Future Work

  • While PNQ guarantees row-wise normalization in exact arithmetic, real-world hardware implementations still face ordinary floating-point rounding errors during final accumulation and division steps.
  • The paper focuses specifically on the open-standard MXFP4 format (E2M1 with 32-element blocks). Extending this elegant, data-free log-periodic analysis to other emerging microscaling formats with different block sizes or non-power-of-two scales remains an open direction for future research.

Summary updated

BibTeX
@misc{yu2026mxattention,
  author = {Jianlin Yu and Jing Lin and Linghui Kong and Aiyue Chen and Weiyi Sun and Chenyu Zeng and Wangli Lan and Jinxi Li and Zhuo Zheng and Ziyang Yue and Danning Ke and Fei Yi and Tianchi Hu and Yuan Ding and Yiwu Yao and Junsong Wang},
  title = {{MXAttention: Data-Free Optimal Scaling and Pre-Normalization Quantization for MXFP4 Attention}},
  year = {2026},
  eprint = {2607.24377},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.24377},
}
Figure