pub fn int4_matmul_fp16(
m: usize,
n: usize,
k: usize,
group_size: usize,
packed_weights: &[u8],
scale_bits: &[u16],
) -> Result<Vec<u8>, QuantizedBuildError>Expand description
Build an FP16 projection with immutable, symmetric signed four-bit weights.
packed_weights is row-major [N,K], low nibble first, two’s-complement [-8,7].
NK must be even; the packed byte slice must have exactly NK/2 bytes.
scale_bits contains positive finite binary16 scales [N,K/group_size].
Each weight is converted to FP16 then multiplied by its group’s scale before
MATMUL. Slots are 0: FP16 activations [1,M,K], 1: FP16 output [1,M,N].
TOSA 1.0 has no INT4-to-float CAST. The portable artifact therefore serializes these exact values as INT8 constants, using one byte per weight. OpenVINO and Core ML can losslessly repack them to native compressed constants at load time. This is not a TOSA INT4 tensor or NVFP4; no automatic quantization of floating weights occurs. Changing weights or scales requires rebuilding and reloading the program.