TurboQuant+ KV Cache Compression
by @wukai8289
TurboQuant+ compresses llama.cpp KV caches on Apple Silicon up to 6.4x with minimal quality loss, enabling larger models and longer contexts efficiently.
clawhub install turboquant-plusπ About This Skill
TurboQuant+ β KV Cache Compression for Local LLM Inference
> Accelerate local LLM inference on Apple Silicon with 3.8-6.4x KV cache compression via PolarQuant + Walsh-Hadamard rotation.
Trigger Keywords
ιε, KVεηΌ©, ζ¬ε°ζ¨η, llama.cpp, turboquant, KV cache, compression, Apple Silicon, Metal, turbo2, turbo3, turbo4Overview
TurboQuant+ implements TurboQuant (ICLR 2026) for llama.cpp with Metal GPU kernels. It compresses the transformer KV cache to squeeze larger models and longer contexts into limited Apple Silicon memory β with minimal quality loss.
Core Capabilities
Dependencies
None. Works with the llama.cpp TurboQuant fork.Configuration Guide
Basic Usage (llama-server)
# Recommended default β turbo4 symmetric
llama-server -m model.gguf --cache-type-k turbo4 --cache-type-v turbo4 -fa 1Maximum compression β turbo3 symmetric
llama-server -m model.gguf --cache-type-k turbo3 --cache-type-v turbo3 -fa 1Extreme compression β turbo2 (best with asymmetric)
llama-server -m model.gguf --cache-type-k q8_0 --cache-type-v turbo2 -fa 1
Asymmetric K/V (for Q4_K_M models)
Some low-bit weight models degrade with symmetric turbo. Use asymmetric K/V:
# K stays at q8_0, V compressed with turbo
llama-server -m model-Q4_K_M.gguf --cache-type-k q8_0 --cache-type-v turbo4 -fa 1Even more V compression
llama-server -m model-Q4_K_M.gguf --cache-type-k q8_0 --cache-type-v turbo3 -fa 1
> Note: Larger models (70B, 104B) handle symmetric turbo fine. Asymmetric mainly benefits smaller Q4_K_M models.
Long Context on Large Models
For 70B+ models at 32K+ context on 128GB Macs, raise the GPU memory cap:
# Set to 90% of 128GB
sudo sysctl iogpu.wired_limit_mb=117964Then run with turbo3 for maximum context
llama-server -m Llama-70B-Q4_K_M.gguf --cache-type-k turbo3 --cache-type-v turbo3 -c 65536 -fa 1
Recommended Configs by Scenario
| Scenario | K cache | V cache | Compression | PPL impact | |----------|---------|---------|-------------|------------| | Best quality | turbo4 | turbo4 | 3.8x | +0.23% | | Balanced | turbo3 | turbo3 | 4.6-5.1x | +1.06% | | Max compression | turbo2 | turbo2 | 6.4x | +6.48% | | Q4_K_M safe | q8_0 | turbo4 | ~3.8x V | +1.0% | | Boundary V | q8_0 | turbo2 | ~6x V | 37-91% quality recovered |
Apple Silicon Benchmarks (M5 Max 128GB)
Quality (wikitext-2)
| Cache | Compression | PPL | vs q8_0 | |-------|-------------|-----|---------| | q8_0 | 1.9x | 6.111 | baseline | | turbo4 | 3.8x | 6.125 | +0.23% | | turbo3 | 4.6x | 6.176 | +1.06% | | turbo2 | 6.4x | 6.507 | +6.48% |
Large Model Results
| Model | Config | PPL | Context | NIAH | |-------|--------|-----|---------|------| | Llama-70B Q4_K_M | turbo4/turbo4 | 3.461 | 48K | 30/30 | | Command-R+ 104B Q4_K_M | turbo3/turbo3 | 6.415 | 128K | 10/10 |
Speed
M1 Max 64GB Results (Community)
| KV | Prefill t/s | Decode t/s | vs q8_0 | |----|------------|-----------|---------| | q8_0 | 399.0 | 12.4 | β | | turbo4 | 365.0 | 16.6 | +33.9% |
Key Research Findings
1. V compression is free β Compressing V to 2-bit has zero measurable effect when K precision is maintained. Validated on Metal, CUDA RTX 4090, RTX 3090. 2. All quality loss comes from K compression β This is why asymmetric configs rescue quality. 3. Boundary layers are sensitive β Protecting first 2 + last 2 layers recovers 37-91% of quality gap. 4. turbo4 beats q4_0 in quality β Lower KL divergence, higher top-p agreement, at similar compression.