IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo function

naive_block_scaled_matmul_kernel

def naive_block_scaled_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, scaling_kind: UMMAKind, SF_VECTOR_SIZE: Int, transpose_b: Bool = True](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], alpha: Float32)

Naive GPU kernel that emulates a block-scaled matmul using TCGEN scale factors.

Both A and B must be in K-major format with 5D TCGEN scale-factor layouts. Each thread accumulates one output element by iterating over K and applying per-block scale factors.

Parameters:

  • ​c_type (DType): Element type of the output matrix c.
  • ​a_type (DType): Element type of the LHS input matrix a.
  • ​b_type (DType): Element type of the RHS input matrix b.
  • ​a_scales_type (DType): Element type of the a_scales block scale-factor tensor.
  • ​b_scales_type (DType): Element type of the b_scales block scale-factor tensor.
  • ​accum_type (DType): Element type used for the dot-product accumulator.
  • ​a_layout (TensorLayout): Memory layout of the LHS input matrix a.
  • ​b_layout (TensorLayout): Memory layout of the RHS input matrix b.
  • ​c_layout (TensorLayout): Memory layout of the output matrix c.
  • ​a_scale_layout (TensorLayout): Memory layout of the a_scales block scale-factor tensor.
  • ​b_scale_layout (TensorLayout): Memory layout of the b_scales block scale-factor tensor.
  • ​scaling_kind (UMMAKind): UMMAKind variant selecting the block-scaled MMA instruction.
  • ​SF_VECTOR_SIZE (Int): Number of elements covered by each block scale factor.
  • ​transpose_b (Bool): Whether b is stored transposed (defaults to True).

Was this page helpful?