Rotate Q and K
A fixed Hadamard transform redistributes large outliers across the head dimension. Q and K mean query and key.
K′ = K · H
MXAttention combines outlier smoothing, a better MXFP4 scaling boundary, and normalization-aware probability quantization so both matrix multiplications can use 4-bit data while preserving the meaning of attention.
The important idea is not just “use FP4.” Each quantization point is placed where it protects the semantics of online softmax.
A fixed Hadamard transform redistributes large outliers across the head dimension. Q and K mean query and key.
Choose the shared E8M0 scale with the universal FP4 boundary 7.25. E8M0 stores the shared power-of-two block scale.
Q and K are consumed by the first low-precision matrix multiplication.
PNQ reuses the quantized exponential tile for both the row sum and PV, where PV means probability × value.
Quantizing only the PV branch creates a mismatch: the numerator uses FP4 probabilities while the denominator still uses higher-precision probabilities.
The row sum and output accumulator disagree about what “P” is.
l += Σ P̃
O += MXFP4(P̃) · V̂
The same FP4 values define both normalization and value aggregation.
l += Σ P̂
O += P̂ · V̂
Move the block maximum to see how the UOS rule selects a power-of-two scale. The cells are illustrative E2M1 projections, not a full hardware emulator.
UOS computes the shared scale from ceil(log₂(M / 7.25)).
Red cells indicate saturation pressure; amber cells indicate values likely to collapse toward zero after coarse FP4 projection.
UOS improves numerical representation, but PNQ is what prevents online softmax from normalizing one probability tensor while aggregating with another.
Definitions for the names, formats, tensors, and symbols used in the diagrams.
The complete low-precision method: Hadamard rotation, UOS, and PNQ inside a fused tiled-attention kernel.
Each element uses a 4-bit floating-point value, while a small block of values shares a separate power-of-two scale.
A data-free MXFP4 scale rule using Qmax = 7.25 to balance large-value clipping against small-value underflow and rounding.
Quantizes unnormalized softmax probabilities before calculating their row sum, then reuses the same values for normalization and PV.
The element-level FP4 format used by MXFP4. Its small set of representable values makes scale selection important.
The shared block-scale format. With no mantissa, the scale is a power of two: efficient, but relatively coarse.
The organization behind the standard microscaling format specification that defines MXFP4 and related formats.
QKᵀ produces attention scores. Normalized probabilities then multiply V to produce the output.
The second attention matrix multiplication, which combines value vectors using their softmax probabilities.
A compact floating-point representation using four bits per element. It is faster and smaller, but less precise than FP16 or BF16.
Maintains a running maximum, row sum, and output accumulator so the full attention matrix does not need to be stored.
Spreads localized Q/K outliers across channels before quantization while preserving the full-precision dot product.
M — maximum absolute value in one MX block.Qmax — normalized boundary used to choose the block scale.e — exponent of the shared power-of-two scale.H — Hadamard or orthogonal rotation matrix.d — attention head dimension.S — score tile from QKᵀ / √d.m — running row maximum in online softmax.P̃ — unquantized, unnormalized softmax values.P̂ — MXFP4-quantized softmax values.l — running softmax row sum.O — running attention output accumulator.Q̂, K̂, V̂ — quantized query, key, and value tensors.