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):TileTensorlayout ofpacked, a plain rank-2[N, K//2]uint8buffer. - βs_layout (
TensorLayout):TileTensorlayout ofscales, a plain rank-2[N, K//16]float8_e4m3fnbuffer. - βout_layout (
TensorLayout):TileTensorlayout ofout_w, a plain rank-2[N, K]buffer ofout_type.
Args:
- βout_w (
TileTensor[out_type, out_layout, MutAnyOrigin]): Output weight buffer of shape[N, K]and dtypeout_type, written one element per thread. - βpacked (
TileTensor[DType.uint8, w_layout, ImmutAnyOrigin]): Input packed FP4 weights asuint8of shape[N, K//2], two E2M1 nibbles per byte with the low nibble first. - βscales (
TileTensor[DType.float8_e4m3fn, s_layout, ImmutAnyOrigin]): Per-block FP8-E4M3 scales of shape[N, K//16], applied asabs(scale)over each 16-element K block.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!