Views
No views yet
[!TIP] KV-cache quantization without any fork (recommended, 2026): upstream llama.cpp/Ollama now cover this natively — use-ctk q8_0 -ctv q8_0(~half KV memory, negligible quality loss: perplexity +0.002–0.05) or-ctk q4_0 -ctv q4_0(~quarter memory, ≈7.6% perplexity increase). In Ollama:OLLAMA_KV_CACHE_TYPE=q8_0withOLLAMA_FLASH_ATTENTION=1. Keep K and V types symmetric to stay on the fast fused Flash-Attention path. Since April 2026, mainline llama.cpp also applies Hadamard rotation to KV activations (PR #21038), which greatly improves low-bit KV quality (opt-out:LLAMA_ATTN_ROT_DISABLE=1).The RotorQuant/TurboQuant fork flow below is experimental/legacy: the TurboQuant llama.cpp PR was closed without merging (June 2026) and the fork is unmaintained relative to mainline. It is NOT required to use this model.
| Device | VRAM / RAM | Recommendation |
|---|---|---|
| Any host that runs the base model | baseline + runtime savings | RotorQuant/TurboQuant is a KV-cache runtime modifier; pair with any weight variant |
| Technique | Where it's applied | Savings |
|---|---|---|
| TurboQuant KV cache | At inference time | Reduces attention memory (critical for long context) |
turboquant package:pip install turboquant1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from turboquant import TurboQuantCache
4
5tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E4B", trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained(
7 "google/gemma-4-E4B",
8 torch_dtype=torch.bfloat16,
9 device_map="auto",
10 trust_remote_code=True,
11)
12
13# Apply TurboQuant to the KV cache
14cache = TurboQuantCache(bits=4) # or bits=2 for more aggressive compression
15
16inputs = tokenizer("Hello, how are you?", return_tensors="pt").to(model.device)
17outputs = model.generate(
18 **inputs,
19 max_new_tokens=128,
20 past_key_values=cache,
21 use_cache=True,
22)
23print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))planar3) are not in upstream llama.cpp. They require:1llama-cli -m gemma-4-E4B.gguf \
2 --cache-type-k planar3 --cache-type-v planar3 \
3 -ngl 99 -fa \
4 -p "Hello"q8_0, q4_0). You lose the TurboQuant-specific benefits but keep GGUF weight quantization.| Property | Value |
|---|---|
| Base Model | google/gemma-4-E4B |
| Architecture | Dense transformer (Edge optimised) |
| Parameters | ~4B |
| Context Length | 128K |
| BF16 Size | ~8 GB |
| Modalities | Text + Image + Audio |
| License | apache-2.0 |
-ctk/-ctv q8_0, OLLAMA_KV_CACHE_TYPE).| Runtime | TurboQuant Support | Notes |
|---|---|---|
Python transformers + turboquant | ✅ Full | Drop-in cache class |
| llama.cpp upstream | ❌ Not merged | Use fork below |
| llama-cpp-turboquant fork | ✅ planar3, iso3 | GitHub |
| LM Studio | ❌ Requested | Use q8_0 as alternative |
| Ollama | ❌ Not supported | Use OLLAMA_KV_CACHE_TYPE=q8_0 |
| vLLM | ❌ Not supported | — |
| koboldcpp | ❌ Not supported | — |
majentik/gemma-4-e4b-*. The current variant — TurboQuant — is bolded.)| Variant | Runtime | Approx size | Use case |
|---|---|---|---|
| RotorQuant-GGUF-IQ4_XS | llama.cpp | ~3.4 GB | Lossy 4-bit, low-RAM CPU/edge |
| RotorQuant-GGUF-Q2_K | llama.cpp | ~2.4 GB | Lossy, low-RAM CPU/edge |
| RotorQuant-GGUF-Q3_K_M | llama.cpp | ~3.1 GB | Smaller 3-bit, CPU-friendly |
| RotorQuant-GGUF-Q4_K_M | llama.cpp | ~4.4 GB | Balanced default |
| RotorQuant-GGUF-Q5_K_M | llama.cpp | ~5.3 GB | Higher fidelity, more RAM |
| RotorQuant-GGUF-Q8_0 | llama.cpp | ~8.4 GB | Near-lossless reference |
| RotorQuant-MLX-2bit | mlx-lm | ~1.3 GB | Apple Silicon, smallest |
| RotorQuant-MLX-4bit | mlx-lm | ~2.5 GB | Apple Silicon balanced |
| RotorQuant-MLX-8bit | mlx-lm | ~4.7 GB | Apple Silicon reference |
| TurboQuant | runtime modifier | n/a | KV-cache root (weight-agnostic) |