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 module
fp6_utils
Provides low-level FP6 encode/decode utilities and scale-factor helpers.
The FP6 twin of fp4_utils, covering both OCP MX FP6 encodings (E2M3 and
E3M2). Neither FP6 encoding has Inf or NaN: all 64 codes are finite, so decode
needs no special-case branch and encode saturates rather than propagating a
non-finite input.
Both encodings share the MX block structure with MXFP4 -- 32 consecutive
elements along K share one E8M0 scale -- so MXFP6_SF_VECTOR_SIZE and
MXFP6_SF_DTYPE match their MXFP4 counterparts exactly.
comptime valuesβ
E2M3_TO_FLOAT32β
comptime E2M3_TO_FLOAT32 = SIMD(SIMD(0), SIMD(0.125), SIMD(0.25), SIMD(0.375), SIMD(0.5), SIMD(0.625), SIMD(0.75), SIMD(0.875), SIMD(1), SIMD(1.125), SIMD(1.25), SIMD(1.375), SIMD(1.5), SIMD(1.625), SIMD(1.75), SIMD(1.875), SIMD(2), SIMD(2.25), SIMD(2.5), SIMD(2.75), SIMD(3), SIMD(3.25), SIMD(3.5), SIMD(3.75), SIMD(4), SIMD(4.5), SIMD(5), SIMD(5.5), SIMD(6), SIMD(6.5), SIMD(7), SIMD(7.5), SIMD(-0.0), SIMD(-0.125), SIMD(-0.25), SIMD(-0.375), SIMD(-0.5), SIMD(-0.625), SIMD(-0.75), SIMD(-0.875), SIMD(-1), SIMD(-1.125), SIMD(-1.25), SIMD(-1.375), SIMD(-1.5), SIMD(-1.625), SIMD(-1.75), SIMD(-1.875), SIMD(-2), SIMD(-2.25), SIMD(-2.5), SIMD(-2.75), SIMD(-3), SIMD(-3.25), SIMD(-3.5), SIMD(-3.75), SIMD(-4), SIMD(-4.5), SIMD(-5), SIMD(-5.5), SIMD(-6), SIMD(-6.5), SIMD(-7), SIMD(-7.5), __list_literal__=NoneType(None))
E3M2_TO_FLOAT32β
comptime E3M2_TO_FLOAT32 = SIMD(SIMD(0), SIMD(0.0625), SIMD(0.125), SIMD(0.1875), SIMD(0.25), SIMD(0.3125), SIMD(0.375), SIMD(0.4375), SIMD(0.5), SIMD(0.625), SIMD(0.75), SIMD(0.875), SIMD(1), SIMD(1.25), SIMD(1.5), SIMD(1.75), SIMD(2), SIMD(2.5), SIMD(3), SIMD(3.5), SIMD(4), SIMD(5), SIMD(6), SIMD(7), SIMD(8), SIMD(10), SIMD(12), SIMD(14), SIMD(16), SIMD(20), SIMD(24), SIMD(28), SIMD(-0.0), SIMD(-0.0625), SIMD(-0.125), SIMD(-0.1875), SIMD(-0.25), SIMD(-0.3125), SIMD(-0.375), SIMD(-0.4375), SIMD(-0.5), SIMD(-0.625), SIMD(-0.75), SIMD(-0.875), SIMD(-1), SIMD(-1.25), SIMD(-1.5), SIMD(-1.75), SIMD(-2), SIMD(-2.5), SIMD(-3), SIMD(-3.5), SIMD(-4), SIMD(-5), SIMD(-6), SIMD(-7), SIMD(-8), SIMD(-10), SIMD(-12), SIMD(-14), SIMD(-16), SIMD(-20), SIMD(-24), SIMD(-28), __list_literal__=NoneType(None))
FP6_BYTES_PER_GROUPβ
comptime FP6_BYTES_PER_GROUP = 3
FP6_ELEMENTS_PER_GROUPβ
comptime FP6_ELEMENTS_PER_GROUP = 4
MXFP6_SF_DTYPEβ
comptime MXFP6_SF_DTYPE = DType.float8_e8m0fnu
MXFP6_SF_VECTOR_SIZEβ
comptime MXFP6_SF_VECTOR_SIZE = 32
Structsβ
- β
FP6Format: Selects between the two OCP MX FP6 element encodings.
Functionsβ
- β
compute_mxfp6_even_scale: Computes the OCP MXFP6 E8M0 scale using even-mode rounding. - β
decode_fp6_to_bf16: Decodes FP6 codes to bfloat16. - β
decode_fp6_to_f32: Decodes FP6 codes to float32 with branch-free bit arithmetic. - β
encode_f32_to_fp6: Encodes float32 values to FP6 codes with round-to-nearest-even. - β
fp6_reference_table: Returns the hand-written decode table forfmt. - β
pack_fp6_x4: Packs four FP6 codes into the low 24 bits of a word, element 0 lowest. - β
unpack_fp6_x32: Unpacks the 24 payload bytes of a 32-byte fragment into 32 FP6 codes. - β
unpack_fp6_x4: Unpacks a 24-bit group into four FP6 codes, the inverse ofpack_fp6_x4.