IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

quantize_dynamic_block_scaled_mxfp4_kernel

def quantize_dynamic_block_scaled_mxfp4_kernel[in_dtype: DType, *, elements_per_thread: Int](output_ptr: Pointer[UInt8, MutAnyOrigin, _safe=False], output_scales_ptr: Pointer[Float8_e8m0fnu, MutAnyOrigin, _safe=False], input_ptr: Pointer[Scalar[in_dtype], ImmutAnyOrigin, _safe=False], num_elements: Int)

GPU kernel that quantizes BF16 elements to packed MXFP4 with E8M0 block scales on AMD CDNA4.

Each thread processes elements_per_thread elements, cooperatively reduces the per-group maximum via warp shuffle, and uses the V_CVT_SCALEF32_PK_FP4_BF16 intrinsic for hardware FP4 packing.

Parameters:

  • in_dtype (DType): Element type of the input activation tensor (inferred). Must be bfloat16.
  • elements_per_thread (Int): Number of input elements each thread loads and quantizes per iteration.

Was this page helpful?