Module mxfp4_e8m0

Module mxfp4_e8m0 

Source
Expand description

2026-09-25: Native MXFP4 host unpack: packed E2M1 nibbles + E8M0 scales.

Owner: metrale-core. Invariants:

  • E8M0 bytes 0 and 255 decode to 0.0; every other byte b to 2^(b-127).
  • Within a byte, the even flat index is the low nibble.

The Kimi-K3 host path (metrale_model_weights::kimi_k3_host::mxfp4) calls this rather than keeping its own unpack. The device scale decode mx_block_scale<true> (kernels/gb10/common/mx_block_scale.cuh) must stay byte-exact with fp8_e8m0_to_f32.

The Kimi-K3 GPU GEMM compiles deepseek-v4-flash/nvfp4/moe_w4a16_grouped_gemm.cu through the [sources] use list of kernels/gb10/kimi-k3/*/KERNEL.toml; do not copy that file into kimi-k3.

Constants§

E2M1
2026-09-25: E2M1 nibble → f32, indexed by the 4-bit code (bit 3 is the sign).
GROUP_SIZE
2026-09-25: Native MXFP4 group size; the GPU lander weight_map::quantized_mxfp4_e8m0_pair refuses any other.

Functions§

dequant_nvfp4_e8m0_to_bf16
2026-09-25: Same unpack, then numeric::f32_to_bf16 per element.
dequant_nvfp4_e8m0_to_f32
2026-09-25: Unpack packed E2M1 [n, k/2] + E8M0 scales to f32 [n, k].
fp8_e8m0_to_f32
2026-09-25: Convert one E8M0 scale byte to f32 with a single table load.