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
enqueue_fp4_materialize
def enqueue_fp4_materialize[out_type: DType](out_w: TileTensor[out_type, Storage=out_w.Storage, address_space=out_w.address_space, linear_idx_type=out_w.linear_idx_type], packed: TileTensor[DType.uint8, Storage=packed.Storage, address_space=packed.address_space, linear_idx_type=packed.linear_idx_type], scales: TileTensor[DType.float8_e4m3fn, Storage=scales.Storage, address_space=scales.address_space, linear_idx_type=scales.linear_idx_type], ctx: DeviceContext)
Enqueues fp4_materialize_kernel: packed FP4 + scales -> dense [N, K].
out_w is [N, K], packed is [N, K//2], scales is [N, K//16]. The
grid is (ceil(K/16), ceil(N/16)) threadgroups of 16x16 threads; bounds are
checked per thread so ragged K/N are fine.
Parameters:
- βout_type (
DType): Output element dtype (bf16 for the Apple W4A16 path).
Args:
- βout_w (
TileTensor[out_type, Storage=out_w.Storage, address_space=out_w.address_space, linear_idx_type=out_w.linear_idx_type]): Output weight buffer of shape[N, K]and dtypeout_type, written by the enqueued kernel. - βpacked (
TileTensor[DType.uint8, Storage=packed.Storage, address_space=packed.address_space, linear_idx_type=packed.linear_idx_type]): Input packed FP4 weights asuint8of shape[N, K//2], two E2M1 nibbles per byte with the low nibble first. - βscales (
TileTensor[DType.float8_e4m3fn, Storage=scales.Storage, address_space=scales.address_space, linear_idx_type=scales.linear_idx_type]): Per-block FP8-E4M3 scales of shape[N, K//16], applied asabs(scale)over each 16-element K block. - βctx (
DeviceContext): Device context used to enqueue the kernel onto the GPU.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!