flashinfer.fp4_quantization

此模块提供用于 LLM 推理的 FP4 量化操作,支持各种比例因子布局和量化格式。

核心量化函数

fp4_quantize(input[, global_scale, ...])

将输入张量量化为 FP4 格式。

nvfp4_quantize(a, a_global_sf[, sfLayout, ...])

将输入张量量化为 NVFP4 格式。

nvfp4_batched_quantize(a, a_global_sf[, ...])

将批量输入张量量化为 NVFP4 格式。

nvfp4_block_scale_interleave(unswizzled_sf)

为 FP4 格式交错块比例因子张量。

e2m1_and_ufp8sf_scale_to_float(e2m1_tensor, ...)

将 E2M1 格式张量和 UFP8 比例因子转换为浮点张量。

scaled_fp4_grouped_quantize(a, mask, a_global_sf)

使用掩码将批量输入张量量化为 NVFP4 格式。

矩阵洗牌实用程序

shuffle_matrix_a(input_tensor, epilogue_tile_m)

PyTorch 等效于 trtllm-gen 的 shuffleMatrixA

shuffle_matrix_sf_a(input_tensor, ...[, ...])

Cuda 实现 trtllm-gen 的 shuffleMatrixSfA,但有一个注意事项。

类型和枚举

SfLayout(value[, names, module, qualname, ...])

NVFP4 的比例因子布局。