Module numeric

Module numeric 

Source
Expand description

2026-09-25: Host-side numeric conversions: the FP8 E4M3 decode table, the f32 -> BF16 cast and BF16 widening.

Owner: metrale-core. Invariants:

  • No CUDA and no cfg: the module compiles under every feature combination.
  • FP8_E4M3_LUT decodes the two NaN bytes (0x7F, 0xFF) to signed zero.
  • E4M3_LUT_GMOE in kernels/gb10/common/moe_fp8_grouped_gemm.cu must agree with FP8_E4M3_LUT element for element; it does, including the signed zeros.

Statics§

FP8_E4M3_LUT
2026-09-25: FP8 E4M3 -> f32 lookup table, one entry per byte value.

Functions§

bf16_bytes_to_f32
2026-09-25: Widen little-endian BF16 bytes to f32. Exact: BF16 is the top 16 bits of an f32, so this is a shift, never a rounding.
f32_to_bf16
2026-09-25: Convert f32 to BF16 with IEEE-754 round-to-nearest-even.
fp8_e4m3_to_f32
2026-09-25: Decode one FP8 E4M3 byte to f32 with a single table load.