vllm.models.inkling2.nvidia.ops.block_scales
¶
Operand layouts of the TRT-LLM-gen expert GEMMs.
Block scales of an [R, C] operand are stored in tiles of 4 columns and
128 rows (R128c4, for GEMM token tiles of 128 rows and more) or 8 rows (R8c4):
scale (r, c) lives at [r // 128, c // 4, r % 32, r % 128 // 32, c % 4]
or [r // 8, c // 4, r % 8, c % 4]. Expert weight rows are shuffled in
blocks of 32 for the GEMM's transposed epilogue.
Functions:
-
shuffle_rows–[..., R, C]-> the same shape with rows8 * i + jof each block -
swizzle_block_scales–[..., R, C]row-major scales -> the same shape, R128c4.
_scale_offsets(row, cols, COLS, TILE)
¶
Offsets of scales (row, cols) of a COLS-column scale matrix for
GEMM token tiles of TILE rows (0: row-major).
Source code in vllm/models/inkling2/nvidia/ops/block_scales.py
shuffle_rows(x)
¶
[..., R, C] -> the same shape with rows 8 * i + j of each block
of 32 moved to 4 * j + i (FlashInfer's shuffle_matrix_a).
Source code in vllm/models/inkling2/nvidia/ops/block_scales.py
swizzle_block_scales(scales)
¶
[..., R, C] row-major scales -> the same shape, R128c4.