IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

mxfp4_quantize

def mxfp4_quantize[dtype: DType, width: SIMDLength, //, lanes: Int](values: SIMD[dtype, width]) -> Tuple[SIMD[.uint32, (SIMD(width) // Int(8))], Float8_e8m0fnu]

Quantizes a group spread over adjacent lanes to E2M1 with a UE8M0 scale.

The scale is the smallest power of two that brings the group's largest magnitude, floored at 6 * 2^-126, to at most 6.

Parameters:

  • ​dtype (DType): The values' type, FP32 or BF16.
  • ​width (SIMDLength): The values each lane holds, a multiple of 8.
  • ​lanes (Int): The adjacent lanes that share one scale.

Args:

Returns:

Tuple[SIMD[.uint32, (SIMD(width) // Int(8))], Float8_e8m0fnu]: The packed codes, even values in the low nibbles, and the group's scale.

Was this page helpful?