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
quantize_dynamic_scaled_async_fp4_kernel
def quantize_dynamic_scaled_async_fp4_kernel[input_dtype: DType, input_tile_rank: Int, input_tile_shape: IndexList[input_tile_rank], input_desc_shape: IndexList[input_tile_rank], output_dtype: DType, output_tile_rank: Int, output_tile_shape: IndexList[output_tile_rank], output_desc_shape: IndexList[output_tile_rank], scales_dtype: DType, scales_tile_rank: Int, scales_tile_shape: IndexList[scales_tile_rank], scales_desc_shape: IndexList[scales_tile_rank], input_swizzle_mode: TensorMapSwizzle, output_swizzle_mode: TensorMapSwizzle, scales_swizzle_mode: TensorMapSwizzle, SF_VECTOR_SIZE: Int, NUM_PIPELINES_STAGES: Int](input_tma_op: TMATensorTile[input_dtype, input_tile_rank, input_tile_shape, input_desc_shape], output_tma_op: TMATensorTile[output_dtype, output_tile_rank, output_tile_shape, output_desc_shape], scales_tma_op: TMATensorTile[scales_dtype, scales_tile_rank, scales_tile_shape, scales_desc_shape], tensor_sf: Float32)
GPU kernel that quantizes BF16 tiles to NVFP4 using TMA async copies and warp-specialized PDL.
One warpgroup issues TMA loads while another computes per-group scale factors and packs FP4 elements, then stores results back via TMA async stores.
Parameters:
- βinput_dtype (
DType): Element type of the input activation tensor. - βinput_tile_rank (
Int): Rank of the input TMA tile descriptor. - βinput_tile_shape (
IndexList[input_tile_rank]): Per-dimension shape of the input TMA tile. - βinput_desc_shape (
IndexList[input_tile_rank]): Per-dimension descriptor shape of the input TMA tile. - βoutput_dtype (
DType): Element type of the quantized output tensor. - βoutput_tile_rank (
Int): Rank of the output TMA tile descriptor. - βoutput_tile_shape (
IndexList[output_tile_rank]): Per-dimension shape of the output TMA tile. - βoutput_desc_shape (
IndexList[output_tile_rank]): Per-dimension descriptor shape of the output TMA tile. - βscales_dtype (
DType): Element type of the block scale-factor tensor. - βscales_tile_rank (
Int): Rank of the scales TMA tile descriptor. - βscales_tile_shape (
IndexList[scales_tile_rank]): Per-dimension shape of the scales TMA tile. - βscales_desc_shape (
IndexList[scales_tile_rank]): Per-dimension descriptor shape of the scales TMA tile. - βinput_swizzle_mode (
TensorMapSwizzle):TensorMapSwizzlemode for input TMA loads. - βoutput_swizzle_mode (
TensorMapSwizzle):TensorMapSwizzlemode for output TMA stores. - βscales_swizzle_mode (
TensorMapSwizzle):TensorMapSwizzlemode for scales TMA stores. - βSF_VECTOR_SIZE (
Int): Number of elements covered by each block scale factor. - βNUM_PIPELINES_STAGES (
Int): Number of pipeline stages for TMA double-buffered async copies.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!