Module mxfp4_e8m0

Module mxfp4_e8m0 

Source
Expand description

DeepSeek-V4 native MXFP4 host unpack: packed E2M1 nibbles + E8M0 scales.

This is the SSOT for the CPU loop previously inlined in spark_model::weight_map::dequant_nvfp4_e8m0_to_bf16. K3 official experts (weight_packed + weight_scale) call this; they do not grow a second dequant stack. CUDA mx_block_scale<true> must stay byte-exact with fp8_e8m0_to_f32.

GPU GEMM: kimi-k3 {mxfp4,nvfp4}/KERNEL.toml [build].extra_cu points at kernels/gb10/deepseek-v4-flash/nvfp4/moe_w4a16_grouped_gemm.cu (moe_w4a16_grouped_gemm_ptrtable_e8m0). Do not copy it into kimi-k3.

Constants§

E2M1
E2M1 nibble → f32. Same table as DSV4 dequant_nvfp4_e8m0_to_bf16.
GROUP_SIZE
Native MXFP4 group size on the DSV4 GPU lander (quantized_mxfp4_e8m0).

Functions§

dequant_nvfp4_e8m0_to_bf16
Same unpack, then f32_to_bf16 — matches DSV4 host upload.
dequant_nvfp4_e8m0_to_f32
Unpack packed E2M1 [n, k/2] + E8M0 scales to f32 [n, k].
fp8_e8m0_to_f32
Convert one E8M0 scale byte to f32 (branchless LUT).