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

Mojo function

block_scales_interleave_fp4_kernel

def block_scales_interleave_fp4_kernel[scales_dtype: DType, input_scales_layout: Layout, output_scales_layout: Layout, *, SF_VECTOR_SIZE: Int = Int(16), num_max_threads: Int = Int(1024)](input_scales: LayoutTensor[scales_dtype, input_scales_layout, ImmutAnyOrigin], output_scales: LayoutTensor[scales_dtype, output_scales_layout, MutAnyOrigin])

GPU kernel that reinterleaves rank-2 scale factors into the 5D TCGEN layout.

Each thread reads one scale factor from the flat input and writes it into the interleaved output at the swizzled position required by the tensor-core scale-factor feed.

Parameters:

  • ​scales_dtype (DType): Element type of the scale-factor tensors.
  • ​input_scales_layout (Layout): Layout of the input scale-factor tensor.
  • ​output_scales_layout (Layout): Layout of the output scale-factor tensor.
  • ​SF_VECTOR_SIZE (Int): Number of elements covered by each block scale factor (defaults to 16).
  • ​num_max_threads (Int): Maximum number of threads per block for the launch grid (defaults to 1024).