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:
- βc (
LayoutTensor[c_type, c_layout, MutAnyOrigin]): Rank-2 output accumulator tensor holding all expert outputs. - βa (
LayoutTensor[a_type, a_layout, ImmutAnyOrigin]): Rank-2 FP8 input matrix in K-major format. - βb (
LayoutTensor[b_type, b_layout, ImmutAnyOrigin]): Rank-3 FP8 weight tensor indexed by expert, in K-major format. - βa_offsets (
LayoutTensor[a_offsets_type, a_offsets_layout, ImmutAnyOrigin]): Prefix-sum offsets delimiting each expert's rows ina. - βexpert_ids (
LayoutTensor[expert_ids_type, expert_ids_layout, ImmutAnyOrigin]): Expert id (or-1to skip) for each grid-Z slice. - βa_scales (
LayoutTensor[a_scales_type, a_scale_layout, ImmutAnyOrigin]): Per-block scales forain M-major format. - βb_scales (
LayoutTensor[b_scales_type, b_scale_layout, ImmutAnyOrigin]): Per-block scales forbindexed by expert.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!