You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stores the KV cache in Q4_0 (4-bit) to cut KV-cache memory, and applies a precomputed per-(kv-head, channel) bias to the K vector before it is quantized, reducing the symmetric-quantization error for channels with a nonzero activation mean. Zero decode-time cost (one subtract at cache write). Works on hybrid (attention + recurrent/SSM) models as of #53.
What it does
Stores the KV cache in Q4_0 (4-bit) to cut KV-cache memory, and applies a precomputed per-(kv-head, channel) bias to the K vector before it is quantized, reducing the symmetric-quantization error for channels with a nonzero activation mean. Zero decode-time cost (one subtract at cache write). Works on hybrid (attention + recurrent/SSM) models as of #53.
The three PRs
make-calib-corpus.sh: generate calibration text from the model's own output (no external corpus needed).Prerequisites
llama-cli/llama-serverandllama-kv-mean-center.curl,jq,gzipfor the corpus generator.Steps
1. Generate calibration data (example helper; bring a larger, representative corpus for real use):
2. Calibrate the bias (produces a model-specific bias GGUF; calibrated with K-rotation inactive):
3. Run inference — pass the Q4_0 KV flags and the bias, and match the K-rotation state used at calibration:
Notes
--kv-mean-center); it is not stored in the model.LLAMA_ATTN_ROT_DISABLE=1; the kv-cache: mean-centering on hybrid models + calibration-basis guard (composes with K rotation) #53 basis guard refuses to load on a mismatch (this is intentional, to avoid silently-wrong centering).-fa on) for the quantized KV cache.