quantize: add IQ2_NL and IQ3_NL types (CPU) - #27322
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
CISC
left a comment
There was a problem hiding this comment.
Seems like very reasonable quants to have, but who can/will review?
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co>
|
BTW we also have q2_0 with a group size of 64. A comparison might be neat. |
|
At the risk of sounding like Claude, you are absolutely right @Green-Sky! |
|
Not sure if there's something wrong on my side but like-for-like test results with Q2_0 are terrible: Full logs and scores here |
@CISC, if I got it right it will be either @JohannesGaessler or @ggerganov although there may be others I don't know about. |
The quantizer for q2_0 might not be very smart. The format is mostly for ternary trained models. (or quaternary since each weight can have 4 states). |
Overview
K-quants and I-quants operate on 256-element super-blocks. A tensor can use them only if its row length (
ncols) is an exact multiple of 256. When it isn't, the quantizer falls back to a different (usually sub-optimal) 32-element block type per tensor.Mainline 32-block types stop at 4.50 bpw (Q4_0/IQ4_NL) creating a hard floor on every misaligned tensor and therefore on the whole file wherever misaligned tensors dominate because there is nothing better to substitute to.
This PR introduces two new CPU-only types IQ2_NL (2.50 bpw) and IQ3_NL (3.50 bpw) extending the existing non-linear family downward. Being 32-block types, they apply wherever
ncols % 32 == 0.Additional information
Test models and results including PPL, KLD and inference benchmarks available at HuggingFace.
PR for CPU + Metal backend: #27324
PR for CPU + Metal + CUDA backend: #27325
PR for CPU + Metal + CUDA + Vulkan backend: #27983
Requirements