For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
decode_fp6_to_f32
def decode_fp6_to_f32[width: SIMDLength, //, fmt: FP6Format](code: SIMD[DType.uint8, width]) -> SIMD[DType.float32, width]
Decodes FP6 codes to float32 with branch-free bit arithmetic.
Builds the float32 bit pattern directly, so the result is bit-identical
to indexing fp6_reference_table[fmt]() for all 64 codes, including the
signed zeros. Every FP6 value is exactly representable in float32.
Construction (float32 s | 8-bit exp (bias 127) | 23-bit mantissa), with
E the exponent field, m the mantissa field, and M the mantissa width:
- Normal (
E >= 1): value2^(E - bias) * (1 + m/2^M), so the float32 exponent field isE + 127 - biasand the mantissa field ism << (23 - M). - Subnormal (
E == 0): valuem * 2^(1 - bias - M), a uniform grid. Built by convertingmto float32 (exact form < 2^M) and scaling by a power of two (also exact) rather than by bit surgery, which would need a leading-zero count. - The sign bit (code bit 5) is OR'd into float32 bit 31 after the select,
so
-0decodes to0x80000000and matches the table's-0.0.
Unlike decode_e2m1_to_f32_inject in fp4_utils, this never forms a
denormal float32 intermediate, so it is correct on flush-to-zero targets.
Parameters:
- โwidth (
SIMDLength): SIMD width (lane count) of the code vector. - โfmt (
FP6Format): The FP6 encoding of the input codes.
Args:
- โcode (
SIMD[DType.uint8, width]): One FP6 code per lane in the low 6 bits (0..63).
Returns:
SIMD[DType.float32, width]: The decoded values as SIMD[DType.float32, width], bit-identical to
indexing fp6_reference_table[fmt]().