arXiv:2610.29445cs.LOOct 2026

Manuscript Offprint

arXiv:2610.29445

Deciding Scale Placement in MXFP4 Dot Products with Integer Arithmetic

Shreyas Vinayakumar

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

Shreyas Vinayakumar

Abstract. Block-scaled formats represent a group of values as low-bit elements multiplied by one shared scale. The Open Compute Project's microscaling (MX) family includes MXFP4, which stores 32 four-bit elements with a shared power-of-two scale. While lowering a dot-product reduction for execution, a compiler can apply these scales before the reduction, or defer scaling until afterwards. Although equivalent over real numbers, these formulations can produce different IEEE binary32 results through overflow or underflow, with equivalence also depending on the reduction tree. We study the legality of compiler rewrites in either direction by deriving conditions under which the two formulations are bitwise equivalent.

To decide rewrite legality, we construct an integer state machine that exploits the finite element alphabet and shared power-of-two scales, modeling overflow, NaN, and subnormal rounding. We prove its faithfulness under bounded scale codes and integer coefficients, yielding an exact encoding of the equivalence query in quantifier-free linear integer arithmetic(QF_LIA). For MXFP4, we derive a closed-form sufficient upper bound on the sum of scale exponents for any fixed binary reduction tree within the supported coefficient range. This bound depends on the size of the largest proper subtree. For four tree shapes at block lengths k∈{2,3,4,8,16,32}k \in \{2, 3, 4, 8, 16, 32\} and two shapes at k=64k = 64, SMT finds counterexamples when this upper bound is increased by one exponent step. We evaluate the computational cost of this approach against the standard direct encoding in quantifier-free floating-point arithmetic (QF_FP). On matched queries, cvc5 proves the integer version in seconds but reaches a configured one-CPU-hour limit on the floating-point proof even at k=2k = 2. The implementation was cross-checked using an independent floating-point encoding, exhaustive and stratified binary32 execution, and GPU replay of counterexamples. An MLIR lowering prototype demonstrates selection between the two formulations using the certified conditions as static or runtime guards.

Keywords: floating point · microscaling · MXFP4 · compiler correctness · SMT · equivalence checking

1 Introduction

As ML models, particularly large language models, continue to grow in size, they require substantial memory and computational resources to store and process their parameters and intermediate activations. Reducing the number of bits

S. Vinayakumar

used to represent each value can improve throughput and reduce energy use on supporting hardware compared to full 32-bit floating-point arithmetic, by reducing data movement and enabling efficient arithmetic. However, reducing bit width affects precision and dynamic range, and requires care to preserve numerical accuracy and to avoid overflow or underflow.

Block scaling formats like Open Compute Project’s microscaling (MX) formats, which store a tensor as blocks of narrow elements that share one scale [24,27], extend the dynamic range of the elements while keeping storage costs moderate. These formats have become so important that major vendors have added native support: NVIDIA’s Blackwell tensor cores and AMD’s matrix cores support multiplying block-scaled matrices [23,5]. On the software end, frameworks like Triton expose the operation as dot_scaled and emulate it on other targets [31], and torchao emulates it by dequantizing to a wide type and calling an ordinary matrix multiply [26].

In MXFP4, a block holds 32 four-bit E2M1(2 bit exponent, 1 bit mantissa) elements and one eight-bit E8M0 scale, and the scale is a power of two. For an E2M1 element with sign bit S, exponent field E, and mantissa bit M, its nonzero normalized decoded value is

(−1)S2E−1(1+M2),(-1)^{S}2^{E-1}\left(1+\frac{M}{2}\right),

which is then multiplied by the block scale. An E8M0 scale has the decoded value 2e−1272^{e-127}, where ee is the unsigned integer stored in the scale byte. Consider the dot product of two k-sized MXFP4 blocks with scales sAs_A, sBs_B and elements a1,…,aka_1, \ldots, a_k and b1,…,bkb_1, \ldots, b_k. A way to compute the dot product is to dequantize elements from each block, and perform a reduction as shown below:

∑i=1k(sAai)(sBbi),\sum_{i=1}^{k}(s_{A}a_{i})(s_{B}b_{i}),

Another way to compute it would be to perform reduction over the original element values without dequantization, and then multiply the result with scales of both blocks:

(sAsB)∑i=1kaibi.\left(s_{A}s_{B}\right)\sum_{i=1}^{k}a_{i}b_{i}.

We call these the direct and hoisted forms respectively, because it hoists the common scale for each element of a block. The hoisted form performs k+2k + 2 multiplications instead of 3k3k; at k=32k = 32 that is 34 instead of 96. Both scale placements occur in practice: the OCP specification uses the hoisted form while writing the block dot product but leaves the internal precision and the order of operations to the implementation [24]. On the other hand, torchao's emulation dequantizes operands before matrix multiplication [26]. Under real arithmetic, the distributive law makes the two forms equivalent. This identity motivates scale hoisting as a compiler optimization.

Table 1. The same 32-lane input evaluated by three plausible lowerings. The linear direct reduction is not equivalent to the hoisted form, so scale hoisting is not a legal result-preserving rewrite for this input and reduction tree.

FormReduction shapeBinary32 result
directlinear (left fold)+∞+\infty (0x7f800000)
directbalanced tree1004⋅21181004 \cdot 2^{118} (0x7f7b0000)
hoistedeither shape1004⋅21181004 \cdot 2^{118} (0x7f7b0000)

In binary32 arithmetic, rewriting can change the answer significantly. Take k=32k = 32, scale codes eA=120e_A = 120 and eB=252e_B = 252, which denote sA=2−7s_A = 2^{-7} and sB=2125s_B = 2^{125}, and a block with twenty-nine lanes of ai=bi=6a_i = b_i = 6 followed by the pairs (−6,6)(-6, 6), (−2,2)(-2, 2), and (0,0)(0, 0). The exact dot product is 1004⋅2118≈3.34×10381004 \cdot 2^{118} \approx 3.34 \times 10^{38}. This is below the binary32 overflow threshold, and the hoisted form returns it. The direct form, summed from left to right, yields 29⋅36⋅2118=4176⋅211629 \cdot 36 \cdot 2^{118} = 4176 \cdot 2^{116} after twenty-nine lanes; that exceeds 21282^{128}, and the running sum overflows to +∞+\infty before the remaining terms can be added. The direct form returns +∞+\infty. Summed as a balanced tree instead, the direct form never builds that prefix and returns the finite value. One input has three plausible lowerings, and whether the results agree depends on the shape of the reduction. Table 1 makes the resulting failure of rewrite equivalence explicit. Section 6.2 shows the direct and hoisted forms as an MLIR pass emits them.

Existing compilers have two ways to deal with this today. Under strict IEEE semantics, rewriting is forbidden, because it can change the returned value. Under fast-math flags it is allowed, together with every other reassociation. For example, LLVM's language reference warns that reassociation may “dramatically change results” [20]. Neither option uses the unique constraints known about this particular operation: the element alphabet has sixteen codes(4 bits per element), the scale is a power of two, the block length is fixed by the format, and the compiler itself chooses the reduction tree. We derive sufficient guards for rewrites between the direct and hoisted forms under a fixed reduction tree, and establish sharpness for the configurations evaluated here.

Bit-precise SMT supports bounded equivalence checking of floating-point programs [22,21], but the direct encoding is expensive even for small instances of this family (Section 2.6). Our contribution is an exact reduction to quantifier-free linear integer arithmetic(QF_LIA) that exposes the arithmetic structure of these queries.

Every E2M1 product is a quarter-integer of magnitude at most 36, and the scales are powers of two. Under an upper bound on each scale code and a bound on the magnitudes of intermediate integer coefficients, both programs can be represented by a state machine consisting of an integer coefficient and a tag in {fin,+∞,−∞,NaN}\{\mathrm{fin}, +\infty, -\infty, \mathrm{NaN}\}. These bounds ensure exactness in the normal range, while overflow and subnormal rounding can be expressed as conditions on integers. The resulting query in QF_LIA is equisatisfiable with the floating-point query under

S. Vinayakumar

these bounds, and counterexamples translate constructively in both directions (Theorem 1, Section 3).

We use the following vocabulary throughout: A lane is an index i∈{1,…,k}i \in \{1, \ldots, k\}, one position in a block. A scale code is the eight-bit E8M0 field ee of a block, and its scale is 2e−1272^{e-127}. The exponent sum t=(eA−127)+(eB−127)t = (e_A - 127) + (e_B - 127) is the exponent of the combined scale sAsBs_A s_B. A band is an interval of exponent sums. The guard is the condition on the pair of scale codes under which we prove the rewrite exact; it consists of an upper cap on each code and a band on the exponent sum. A band is certified for a block length and a tree when the solver has proved that no block inside it separates the two forms, and it is sharp when widening it by one exponent step admits a counterexample. A witness is a concrete block, elements and scale codes together, on which the two forms return different binary32 values.

This paper makes the following contributions.

– An exact reduction of a family of floating-point equivalence queries to QF_LIA, with a faithfulness proof and constructive counterexample translations on the domain of interest (Section 3).

– A closed-form sufficient guard using MXFP4's element and scale encodings for any fixed binary reduction tree within the coefficient budget, with solver-established sharpness for four shapes at block lengths 2,3,4,8,16,32 lanes and for two shapes at 64 lanes (Sections 4 and 5.3).

– A prototype implementation of a rewrite guard based on the certified bands (Section 6.2) in an MLIR lowering pass, and a description of which parts of the construction carry over to other block formats(Section 6).

– A comparison of the two theories, evaluating the relative cost using the same solver and validating the encoding against an independently written floating-point encoding, against exhaustive and stratified binary32 execution, and by replaying witnesses on a GPU(Section 5).

References (26)