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
block_scaled_matmul
def block_scaled_matmul[c_type: DType, a_type: DType, b_type: DType, scales_dtype: DType, //, *, SF_VECTOR_SIZE: Int, transpose_b: Bool = True, transpose_a: 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, elementwise_compute_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> SIMD[dtype, width]] = None, pdl_level: PDLLevel = PDLLevel.OFF, _trace_description: StringSlice[ImmStaticOrigin] = StringSlice(""), target: StringSlice[ImmStaticOrigin] = StringSlice("cpu")](c_device: TileTensor[c_type, Storage=c_device.Storage, linear_idx_type=c_device.linear_idx_type], a_device: TileTensor[a_type, Storage=a_device.Storage, linear_idx_type=a_device.linear_idx_type], b_device: TileTensor[b_type, Storage=b_device.Storage, linear_idx_type=b_device.linear_idx_type], a_scales_device: TileTensor[scales_dtype, Storage=a_scales_device.Storage, linear_idx_type=a_scales_device.linear_idx_type], b_scales_device: TileTensor[scales_dtype, Storage=b_scales_device.Storage, linear_idx_type=b_scales_device.linear_idx_type], tensor_sf: Float32, ctx: DeviceContext)
Dispatches the SM100 block-scaled matmul for NVFP4 or MXFP8, selecting between the Mojo heuristic kernel and the vendor fallback.
For small M or MXFP8 shapes the Mojo heuristic_and_outliers_dispatch
kernel is tried first; on a dispatch miss the vendor (cuBLASLt)
block-scaled matmul is used as a fallback.
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). - βscales_dtype (
DType): Element type of the block scale-factor tensors (inferred). - βSF_VECTOR_SIZE (
Int): Number of elements covered by each block scale factor: 16 for NVFP4 or 32 for MXFP8. - βtranspose_b (
Bool): Whetherb_deviceis stored transposed (defaults toTrue). - βtranspose_a (
Bool): Whethera_deviceis stored transposed (defaults toFalse). - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional epilogue lambda applied to the matmul result after it is written toc_device(defaults toNone). - βelementwise_compute_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> SIMD[dtype, width]]): Optional compute lambda that transforms the matmul result in-flight before storage (defaults toNone). - βpdl_level (
PDLLevel): Programmatic dependency launch level for the heuristic dispatch kernel (defaults toPDLLevel.OFF). - β_trace_description (
StringSlice[ImmStaticOrigin]): Extra label appended to the trace event for profiling (defaults to""). - βtarget (
StringSlice[ImmStaticOrigin]): Trace target string identifying the device in profiling output (defaults to"cpu").
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!