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_matmul_kernel
def naive_blockwise_scaled_fp8_matmul_kernel[c_type: DType, a_type: DType, b_type: DType, a_scales_type: DType, b_scales_type: DType, accum_type: DType, a_layout: TensorLayout, b_layout: TensorLayout, c_layout: TensorLayout, a_scale_layout: TensorLayout, b_scale_layout: TensorLayout, BLOCK_DIM: Int, transpose_b: Bool = False, elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None, scales_granularity_mnk: Optional[IndexList[Int(3)]] = None](c: TileTensor[c_type, c_layout, MutAnyOrigin], a: TileTensor[a_type, a_layout, ImmutAnyOrigin], b: TileTensor[b_type, b_layout, ImmutAnyOrigin], a_scales: TileTensor[a_scales_type, a_scale_layout, ImmutAnyOrigin], b_scales: TileTensor[b_scales_type, b_scale_layout, ImmutAnyOrigin])
Computes one output element per thread for the naive blockwise scaled FP8 matmul GPU kernel.
Each thread accumulates the scaled dot product for a single (row, col)
output element by looping over the K dimension, loading the corresponding
a and b values and their per-block scale factors, and applying the
optional elementwise epilogue before storing the result.
Supports two scaling modes: inferred per-group scale sizes from the input
and scale tensor shapes (when scales_granularity_mnk is None), or
explicit (M, N, K) scale granularities provided via
scales_granularity_mnk.
Args:
- βc (
TileTensor[c_type, c_layout, MutAnyOrigin]): Rank-2 output accumulator tensor. - βa (
TileTensor[a_type, a_layout, ImmutAnyOrigin]): Rank-2 FP8 input matrix in K-major format. - βb (
TileTensor[b_type, b_layout, ImmutAnyOrigin]): Rank-2 FP8 weight matrix; K-major whentranspose_bis True, otherwise N-major. - βa_scales (
TileTensor[a_scales_type, a_scale_layout, ImmutAnyOrigin]): Rank-2 per-block scales forain M-major format. - βb_scales (
TileTensor[b_scales_type, b_scale_layout, ImmutAnyOrigin]): Rank-2 per-block scales forb; K-major whentranspose_bis True, otherwise N-major.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!