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

matmul_dynamic_block_scaled_mxfp4_kernel

def matmul_dynamic_block_scaled_mxfp4_kernel[out_dtype: DType, BLOCK_N: Int](c_ptr: Pointer[Scalar[out_dtype], MutAnyOrigin, _safe=False], a_ptr: Pointer[UInt8, ImmutAnyOrigin, _safe=False], b_ptr: Pointer[UInt8, ImmutAnyOrigin, _safe=False], a_scales_ptr: Pointer[Float8_e8m0fnu, ImmutAnyOrigin, _safe=False], b_scales_ptr: Pointer[Float8_e8m0fnu, ImmutAnyOrigin, _safe=False], M: Int, N: Int, K: Int)

GPU kernel that computes an MXFP4 block-scaled matmul on AMD CDNA4 using FP4 dot-product intrinsics.

Each thread computes BLOCK_N output elements for one row by iterating over K in MXFP4_SF_VECTOR_SIZE groups, dequantizing FP4 pairs to BF16 and accumulating via the llvm.amdgcn.fdot2 intrinsic.

Parameters:

  • out_dtype (DType): Element type of the output matrix.
  • BLOCK_N (Int): Number of output columns computed per thread.