Skip to main content

NF4_LUT

Constant NF4_LUT 

Source
pub const NF4_LUT: [f32; 16];
Expand description

The 16 NF4 quantization levels, indexed by the unsigned 4-bit storage code.

These values are fixed by the specification and MUST NOT be altered. They are the float32 decimal expansions of the exact levels from the QLoRA reference implementation (docs/spec/quantization/nf4.md § Lookup Table).

The extra precision in the source literals is intentional: these are the exact decimal representations of the IEEE 754 binary32 values; truncating them would alter the bit pattern.

§Examples

use hurray_core::NF4_LUT;

assert_eq!(NF4_LUT[0], -1.0f32);
assert_eq!(NF4_LUT[7], 0.0f32);
assert_eq!(NF4_LUT[15], 1.0f32);
assert_eq!(NF4_LUT.len(), 16);