Class MxFp8
java.lang.Object
smile.llm.quant.MxFp8
MXFP8 (OCP microscaling) weights: FP8 E4M3 elements with one shared E8M0 scale per 32
consecutive elements along the reduction dimension.
An E8M0 byte s encodes the power of two 2^(s - 127); 255 is NaN.
A weight W[n][k] is fp8[n][k] * 2^(scale[n][k / 32] - 127). Checkpoints store the
scales as <name>.weight_scale_inv (U8, [N, K / 32]).
This is the portable reference: it expands a weight to a dense tensor. Production kernels keep the FP8 bytes and apply the scales in the GEMM.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Tensordequantize(Tensor weight, Tensor scale, ScalarType dtype) Expands an MXFP8 weight to a dense tensor.static floate8m0ToFloat(int code) Returns the value of an E8M0 scale byte.
-
Field Details
-
BLOCK
public static final int BLOCKElements sharing one scale.- See Also:
-
-
Method Details
-
e8m0ToFloat
public static float e8m0ToFloat(int code) Returns the value of an E8M0 scale byte.- Parameters:
code- the stored byte,0..255.- Returns:
2^(code - 127), or NaN for255.
-
dequantize
Expands an MXFP8 weight to a dense tensor.- Parameters:
weight- FP8 E4M3 weight[N, K]withKa multiple ofBLOCK.scale- E8M0 scales asUInt8[N, K / 32], on the same device asweight.dtype- result dtype.- Returns:
- the dense weight
[N, K]; the caller owns it. - Throws:
IllegalArgumentException- if the shapes are not an MXFP8 layout.
-