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

convert_ref_scales_to_mxfp8_format

def convert_ref_scales_to_mxfp8_format[MType: CoordLike, NType: CoordLike, KType: CoordLike, ref_a_scales_tt_layout: TensorLayout, ref_b_scales_tt_layout: TensorLayout, a_scales_tt_layout: TensorLayout, b_scales_tt_layout: TensorLayout, //, ref_scales_type: DType, scales_type: DType, *, REF_BLOCK_SIZE: Int, SF_VECTOR_SIZE: Int](m: MType, n: NType, k: KType, ref_a_scales: TileTensor[ref_scales_type, ref_a_scales_tt_layout, Engine=ref_a_scales.Engine, linear_idx_type=ref_a_scales.linear_idx_type], ref_b_scales: TileTensor[ref_scales_type, ref_b_scales_tt_layout, Engine=ref_b_scales.Engine, linear_idx_type=ref_b_scales.linear_idx_type], a_scales: TileTensor[scales_type, a_scales_tt_layout, Engine=a_scales.Engine, linear_idx_type=a_scales.linear_idx_type], b_scales: TileTensor[scales_type, b_scales_tt_layout, Engine=b_scales.Engine, linear_idx_type=b_scales.linear_idx_type])

Converts reference float32 block scales into the 5D MXFP8 E8M0 scale-factor layout.

Reads the per-block float32 reference scales for the A (M x K) and B (N x K) operands, converts each to float8_e8m0fnu, and writes them into the corresponding 5D scale-factor tensors expected by block-scaled matmul kernels.

Parameters:

  • ​MType (CoordLike): CoordLike type carrying the M dimension size.
  • ​NType (CoordLike): CoordLike type carrying the N dimension size.
  • ​KType (CoordLike): CoordLike type carrying the K dimension size.
  • ​ref_a_scales_tt_layout (TensorLayout): TensorLayout of the 2D reference A scales.
  • ​ref_b_scales_tt_layout (TensorLayout): TensorLayout of the 2D reference B scales.
  • ​a_scales_tt_layout (TensorLayout): TensorLayout of the 5D output A scales.
  • ​b_scales_tt_layout (TensorLayout): TensorLayout of the 5D output B scales.
  • ​ref_scales_type (DType): Element type of the reference scales (must be float32).
  • ​scales_type (DType): Element type of the output scales (must be float8_e8m0fnu).
  • ​REF_BLOCK_SIZE (Int): Block size (in elements) used by the reference scales.
  • ​SF_VECTOR_SIZE (Int): Number of elements each scale factor covers in the output layout.

Args:

Was this page helpful?