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_kernel

def naive_blockwise_scaled_fp8_grouped_matmul_kernel[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, 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, accum_type: DType, 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, MutAnyOrigin], a: LayoutTensor[a_type, a_layout, ImmutAnyOrigin], b: LayoutTensor[b_type, b_layout, ImmutAnyOrigin], a_offsets: LayoutTensor[a_offsets_type, a_offsets_layout, ImmutAnyOrigin], expert_ids: LayoutTensor[expert_ids_type, expert_ids_layout, ImmutAnyOrigin], a_scales: LayoutTensor[a_scales_type, a_scale_layout, ImmutAnyOrigin], b_scales: LayoutTensor[b_scales_type, b_scale_layout, ImmutAnyOrigin])

Computes one output element per thread for the naive blockwise scaled FP8 grouped matmul GPU kernel.

Each thread handles a single (m_local, n) output element within one expert's tile, determined by block_idx.z and the a_offsets prefix sum. The thread loops over the K dimension, loading the expert's a row and b slice along with their per-block scale factors, accumulates the scaled product, and applies the optional elementwise epilogue before storing the result.

Args:

Was this page helpful?