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).

Python function

interleaved_block_scales_shape

interleaved_block_scales_shape()​

max.nn.moe.interleaved_block_scales_shape(rows, cols)

source

Returns the SM100 interleaved layout’s shape for [rows, cols] scales.

The layout is [rows / 128, cols / 4, 32, 4, 4], the shape block_scales_interleave() produces. Scale row r, column c is stored at [r // 128, c // 4, r % 32, (r % 128) // 32, c % 4], so a range of whole row granules or whole column granules of the interleaved tensor is the interleave of the matching slice of the row-major scales.

Parameters:

  • rows (int) – The number of scale rows, one per weight output row.
  • cols (int) – The number of scale columns, one per 32-element block.

Returns:

The rank-5 interleaved shape.

Raises:

ValueError – If rows is not a multiple of 128 or cols is not a multiple of 4.

Return type:

list[int]