veloxquant_mlx.cache.qjl_cache module¶
QJL-backed KV cache: pure 1-bit Johnson-Lindenstrauss key compression.
Wraps QJLQuantizer in the
VeloxQuant KVCache ABC
(append_key/append_value/attend), storing per-token JL sign bits and a
scalar norm for keys, and per-token int8 + fp16 scale for values. This is
a “standalone” method (see
STANDALONE_METHODS): it does not
implement the mlx_lm serving protocol.
- class veloxquant_mlx.cache.qjl_cache.QJLKVCache(config)[source]¶
Bases:
KVCacheMinimal KV cache using pure 1-bit QJL for key compression.
- Parameters:
config (
Any) – KVCacheConfig instance.jl_dimsets the sketch sizem; when unset it defaults tohead_dim. The estimator is unbiased but its variance falls as1/m, som = head_dimgives noisy scores (correlation with exactq.k~0.64 at d=128, ~0.88 atm = 4 * head_dim). Setjl_dimhigher when attention quality matters.