flashinfer.quantization.silu_and_mul_mxfp8_experts_quantize¶
- flashinfer.quantization.silu_and_mul_mxfp8_experts_quantize(a: Tensor, mask: Tensor, *, enable_pdl: bool | None = None) Tuple[Tensor, Tensor]¶
Fused SiLU + mul + MXFP8 quantization with a per-expert row mask.
Quantizes
silu(a[..., :K]) * a[..., K:], rounded to the input dtype, to MXFP8 (E4M3 values, one UE8M0 scale per 32 values). Requires SM100+. The outputs are the(A, SFA)operand of the secondflashinfer.gemm.grouped_gemm_nt_masked()of a MoE.- Parameters:
a (torch.Tensor) – Contiguous, 32-byte aligned
float16orbfloat16tensor of shape[B, M, 2 * K]; each row holds the gate values, then the up values.Kmust be divisible by 32.mask (torch.Tensor) – Contiguous int32 CUDA tensor of shape
[B], read on the device. Only the firstmin(mask[i], M)rows of expertiare read and written.enable_pdl (bool, optional) – Whether to enable Programmatic Dependent Launch. Auto-detected from the device capability when
None.
- Returns:
(x_q, sf)in the layout ofmxfp8_grouped_quantize():x_qhas logical shape[M, padded_K, B]with dtypefloat8_e4m3fnandsfhas logical shape[32, 4, padded_M // 128, 4, padded_K // 128, B]with dtypeuint8, wherepadded_Kandpadded_MroundKandMup to multiples of 128. Rows past the valid ones (and their scale factors) are unspecified.NaN and infinities quantize to 448, and the other values of a block with an infinity to zero.
- Return type:
Tuple[torch.Tensor, torch.Tensor]