quantize
a simple, fast quantization library usable as a rust crate or python package.
to learn more, feel free to peruse the chapters, which show how the repo's algorithms progressed over time.
use as a library
use ;
let weights = ;
let q = .unwrap;
let _ = .unwrap;
let _ = .unwrap;
let _ = Q4_32..unwrap;
let back = q.dequantize;
let _ = q.dot;
comparison
1024x1024 matrix, 50 iterations.
quality
cargo run --release --example compare
reconstruct, then matmul.
| bits/value | quantize mse | candle mse |
|---|---|---|
| 4.5 | 0.066669 | 0.060276 |
| 5.5 | 0.014429 | 0.013859 |
| 8.5 | 0.000201 | 0.000201 |
speed
cargo run --release --example throughput
pack and unpack. apple M4.
| kernel | quantize ns/value | candle ns/value |
|---|---|---|
| 4-bit quant | 0.29 | 0.46 |
| 8-bit quant | 0.24 | 0.30 |
| 4-bit dequant | 0.09 | 0.29 |
| 8-bit dequant | 0.07 | 0.26 |
ns = nanosecond, a billionth of a second. smaller is faster.