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

fp4_materialize_kernel

def fp4_materialize_kernel[out_type: DType, w_layout: TensorLayout, s_layout: TensorLayout, out_layout: TensorLayout](out_w: TileTensor[out_type, out_layout, MutAnyOrigin], packed: TileTensor[DType.uint8, w_layout, ImmutAnyOrigin], scales: TileTensor[DType.float8_e4m3fn, s_layout, ImmutAnyOrigin])

Materializes the packed-FP4 weight into a dense [N, K] out_type buffer.

One thread per output element (n, k). packed is [N, K//2] (lo-nibble first), scales is [N, K//16]. Used by the Stage-1 oracle: it dequants the weight to bf16 so the EXISTING AppleM5MatMul can consume it, proving the dequant math against a host reference before the fused loader is written.

Parameters:

  • ​out_type (DType): Output element dtype (bf16 for the Apple W4A16 path).
  • ​w_layout (TensorLayout): TileTensor layout of packed, a plain rank-2 [N, K//2] uint8 buffer.
  • ​s_layout (TensorLayout): TileTensor layout of scales, a plain rank-2 [N, K//16] float8_e4m3fn buffer.
  • ​out_layout (TensorLayout): TileTensor layout of out_w, a plain rank-2 [N, K] buffer of out_type.

Args:

Was this page helpful?