For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo function
dequant_fp4_nibble
def dequant_fp4_nibble[out_type: DType](packed_byte: UInt8, nibble_hi: Bool, scale_abs: Float32) -> Scalar[out_type]
Dequantizes one E2M1 nibble of a packed byte to out_type.
Low nibble (nibble_hi=False) is the even K element; high nibble is the odd
one. The 4-bit value indexes E2M1_TO_FLOAT32 (sign + magnitude already
baked into the 16-entry LUT) and is scaled by the block's |scale|.
Parameters:
- βout_type (
DType): Output element dtype (bf16 for the Apple W4A16 path).
Args:
- βpacked_byte (
UInt8): The two-nibble packed FP4 byte. - βnibble_hi (
Bool): True selects the high nibble (byte >> 4), False the low. - βscale_abs (
Float32): The block scale, already passed throughabs().
Returns:
Scalar[out_type]: The dequantized value E2M1_TO_FLOAT32[nibble] * scale_abs as
Scalar[out_type].
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!