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
def naive_block_scaled_matmul[c_type: DType, a_type: DType, b_type: DType, a_scales_type: DType, b_scales_type: DType, //, *, scaling_kind: UMMAKind, SF_VECTOR_SIZE: Int, accum_type: DType = .float32, transpose_b: Bool = True, BLOCK_DIM: Int = Int(16)](c: TileTensor[c_type, Engine=c.Engine, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, linear_idx_type=b.linear_idx_type], a_scales: TileTensor[a_scales_type, Engine=a_scales.Engine, linear_idx_type=a_scales.linear_idx_type], b_scales: TileTensor[b_scales_type, Engine=b_scales.Engine, linear_idx_type=b_scales.linear_idx_type], ctx: DeviceContext, alpha: Float32 = 1)
Reference block-scaled matmul that emulates TCGEN scale-factor accumulation on SM100 hardware.
Validates input and scale dimensions, then enqueues the
naive_block_scaled_matmul_kernel with a 16x16 thread block grid.
Parameters:
- c_type (
DType): Element type of the output matrix (inferred). - a_type (
DType): Element type of the LHS input matrix (inferred). - b_type (
DType): Element type of the RHS input matrix (inferred). - a_scales_type (
DType): Element type of thea_scalesblock scale-factor tensor (inferred). - b_scales_type (
DType): Element type of theb_scalesblock scale-factor tensor (inferred). - scaling_kind (
UMMAKind):UMMAKindvariant selecting the block-scaled MMA instruction. - SF_VECTOR_SIZE (
Int): Number of elements covered by each block scale factor. - accum_type (
DType): Accumulator element type (defaults toDType.float32). - transpose_b (
Bool): Whetherbis stored transposed (defaults toTrue). - BLOCK_DIM (
Int): Thread block tile dimension in rows and columns (defaults to 16).
Args:
- c (
TileTensor[c_type, Engine=c.Engine, linear_idx_type=c.linear_idx_type]): Output matrix of shape[M, N]. - a (
TileTensor[a_type, Engine=a.Engine, linear_idx_type=a.linear_idx_type]): LHS input matrix of shape[M, K]for FP8 or[M, K//2]for packed FP4uint8. - b (
TileTensor[b_type, Engine=b.Engine, linear_idx_type=b.linear_idx_type]): RHS input matrix of shape[N, K]for FP8 or[N, K//2]for packed FP4uint8, stored transposed. - a_scales (
TileTensor[a_scales_type, Engine=a_scales.Engine, linear_idx_type=a_scales.linear_idx_type]): Block scale factors forain the 5D TCGEN interleaved layout. - b_scales (
TileTensor[b_scales_type, Engine=b_scales.Engine, linear_idx_type=b_scales.linear_idx_type]): Block scale factors forbin the 5D TCGEN interleaved layout. - ctx (
DeviceContext): Device context used to enqueue the kernel. - alpha (
Float32): Scalar multiplier applied to the matmul result (defaults to 1.0).