Expand description
Int8 block quantization (Q8: blocks of 32 weights sharing one f32 scale).
Structs§
- Offsets
- PageVec
- A zero-initialised, page-aligned buffer whose allocation is a whole number of pages, so GPU APIs can map it without copying.
- PairAct
- Quantized activations interleaved per token pair for 2x2 int8 matrix-multiply instructions
(SMMLA): pair
pholds tokens2pand2p + 1(an odd count repeats the last token).q: per 8 values, 8 of the first token then 8 of the second (2 * n_inbytes per pair);s(per block of 32) andh(per half block) as[first, second, first, second]. - Q4Matrix
- QAct
- Quantized activations
[t, n_in]: int8 values and one scale per block. - QBuf
- Storage for quantized data: either owned (quantized at load time) or borrowed from a
pre-quantized checkpoint that outlives the matrix (the model borrows its
ModelFiles). - QMatrix
- A quantized
[n_out, n_in]matrix: int8 values plus one scale per 32-element block.
Enums§
- QKind
- Quantized storage formats, as recorded in and read from pre-quantized checkpoints.
Constants§
- PAGE
- Page size assumed for GPU zero-copy wrapping (16 KiB covers Apple Silicon; a multiple of 4 KiB).
- QBLOCK
Functions§
- dequantize_
rows - Dequantizes rows
r0..r1ofmintoout(f32, row-major,(r1-r0) * n_in). - dequantize_
rows_ q4 - Dequantizes rows
r0..r1ofmintoout(f32 row-major). - f16_
to_ f32 - from_
mlx_ q4 - Repacks an MLX affine 4-bit matrix (
w = scale * q + biasper group ofgroupelements, eight nibbles per little-endian u32, low nibble first) into Q4_0 layout plus per-group offsets:scale * q + bias = scale * (q - 8) + (bias + 8 * scale). The nibbles carry over unchanged. - mlx_
dequant_ row - Dequantizes one row of an MLX affine matrix (any bit width dividing 32) into
out. - quantize_
act - quantize_
bf16 - Quantizes a bf16 row-major matrix. Symmetric round-to-nearest, scale = absmax / 127 per block.
- quantize_
q4