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

naive_blockwise_scaled_fp8_grouped_matmul

def naive_blockwise_scaled_fp8_grouped_matmul[c_type: DType, a_type: DType, b_type: DType, a_scales_type: DType, b_scales_type: DType, a_offsets_type: DType, expert_ids_type: DType, c_layout: Layout, a_layout: Layout, b_layout: Layout, a_scale_layout: Layout, b_scale_layout: Layout, a_offsets_layout: Layout, expert_ids_layout: Layout, //, BLOCK_DIM_N: Int = Int(32), BLOCK_DIM_M: Int = Int(16), transpose_b: Bool = True, scales_granularity_mnk: Optional[IndexList[Int(3)]] = None, elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None](c: LayoutTensor[c_type, c_layout, address_space=c.address_space, element_layout=c.element_layout, layout_int_type=c.layout_int_type, linear_idx_type=c.linear_idx_type, masked=c.masked, alignment=c.alignment], a: LayoutTensor[a_type, a_layout, address_space=a.address_space, element_layout=a.element_layout, layout_int_type=a.layout_int_type, linear_idx_type=a.linear_idx_type, masked=a.masked, alignment=a.alignment], b: LayoutTensor[b_type, b_layout, address_space=b.address_space, element_layout=b.element_layout, layout_int_type=b.layout_int_type, linear_idx_type=b.linear_idx_type, masked=b.masked, alignment=b.alignment], a_scales: LayoutTensor[a_scales_type, a_scale_layout, address_space=a_scales.address_space, element_layout=a_scales.element_layout, layout_int_type=a_scales.layout_int_type, linear_idx_type=a_scales.linear_idx_type, masked=a_scales.masked, alignment=a_scales.alignment], b_scales: LayoutTensor[b_scales_type, b_scale_layout, address_space=b_scales.address_space, element_layout=b_scales.element_layout, layout_int_type=b_scales.layout_int_type, linear_idx_type=b_scales.linear_idx_type, masked=b_scales.masked, alignment=b_scales.alignment], a_offsets: LayoutTensor[a_offsets_type, a_offsets_layout, address_space=a_offsets.address_space, element_layout=a_offsets.element_layout, layout_int_type=a_offsets.layout_int_type, linear_idx_type=a_offsets.linear_idx_type, masked=a_offsets.masked, alignment=a_offsets.alignment], expert_ids: LayoutTensor[expert_ids_type, expert_ids_layout, address_space=expert_ids.address_space, element_layout=expert_ids.element_layout, layout_int_type=expert_ids.layout_int_type, linear_idx_type=expert_ids.linear_idx_type, masked=expert_ids.masked, alignment=expert_ids.alignment], max_num_tokens_per_expert: Int, num_active_experts: Int, ctx: DeviceContext)

Dispatches the naive blockwise scaled FP8 grouped matmul kernel on the GPU.

Enqueues naive_blockwise_scaled_fp8_grouped_matmul_kernel with one expert per grid-Z slice, tiling the per-expert M_local x N output with BLOCK_DIM_M x BLOCK_DIM_N thread blocks.

Args:

Was this page helpful?