Skip to main content

palette4_matmul_fp16

Function palette4_matmul_fp16 

Source
pub fn palette4_matmul_fp16(
    m: usize,
    n: usize,
    k: usize,
    group_size: usize,
    packed_indices: &[u8],
    palette_bits: &[u16],
) -> Result<Vec<u8>, QuantizedBuildError>
Expand description

Build a projection with immutable four-bit palette indices and FP16 activations.

Indices are row-major [N,K], low nibble first. Each contiguous group_size weights has its own 16-entry binary16 palette: [N,K/group_size,16]. Entries may be arbitrary finite FP16 values (including signed zero); no clustering, quantization or scaling is performed. Slots are FP16 activations [1,M,K] and FP16 output [1,M,N].

Portable TOSA stores unpacked INT32 indices and uses GATHER. Core ML can repack these constants into constexpr_lut_to_dense at load time. This is scalar palettization, not linear INT4 or NVFP4. Constants require reload to update.