Skip to content
ModelListedExternal
Download

Gemma 4 E4B Turboquant

> [!TIP] > KV-cache quantization without any fork (recommended, 2026): upstream > llama.cpp/Ollama now cover this natively — use -ctk q80 -ctv q80 > (half KV memory, negligible quality loss: perplexity +0.002–0.05)...

KindText modelBase modelgoogle/gemma-4-E4BVersionmodel

Model source

Kind
Text model
File size
14.9 GB
Base model
google/gemma-4-E4B
Version
vmodel
Updated
Sep 18, 2026
Downloads
32
Tasks
Captioning
Source
Hugging Face

Source description

[!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_0 with OLLAMA_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.

gemma-4-E4B-TurboQuant

TurboQuant KV cache compression for google/gemma-4-E4B.

This is a documentation repository that explains how to combine gemma-4-E4B's weights with TurboQuant inference-time KV cache compression. No weights are stored here — use the base model directly and apply TurboQuant via the Python package or llama.cpp fork.

Hardware compatibility

DeviceVRAM / RAMRecommendation
Any host that runs the base modelbaseline + runtime savingsRotorQuant/TurboQuant is a KV-cache runtime modifier; pair with any weight variant

What is this?

KV cache compression reduces the memory used by the attention cache during inference. Unlike weight quantization (which is baked into the GGUF/MLX file), KV cache compression is applied at runtime — so the same base weights can be used with or without compression.

TechniqueWhere it's appliedSavings
TurboQuant KV cacheAt inference timeReduces attention memory (critical for long context)

Both can be combined for maximum efficiency.

Quickstart

Option A — Python / transformers

Install the turboquant package:

pip install turboquant

Then use it with the base model:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from turboquant import TurboQuantCache

tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E4B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    "google/gemma-4-E4B",
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)

# Apply TurboQuant to the KV cache
cache = TurboQuantCache(bits=4)  # or bits=2 for more aggressive compression

inputs = tokenizer("Hello, how are you?", return_tensors="pt").to(model.device)
outputs = model.generate(
    **inputs,
    max_new_tokens=128,
    past_key_values=cache,
    use_cache=True,
)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Option B — llama.cpp / LM Studio / Ollama (with fork)

TurboQuant KV cache types (planar3) are not in upstream llama.cpp. They require:

Once built:

llama-cli -m gemma-4-E4B.gguf \
  --cache-type-k planar3 --cache-type-v planar3 \
  -ngl 99 -fa \
  -p "Hello"

For standard runtimes (LM Studio, Ollama, upstream llama.cpp), use conventional KV cache types (q8_0, q4_0). You lose the TurboQuant-specific benefits but keep GGUF weight quantization.

Model Specifications

PropertyValue
Base Modelgoogle/gemma-4-E4B
ArchitectureDense transformer (Edge optimised)
Parameters~4B
Context Length128K
BF16 Size~8 GB
ModalitiesText + Image + Audio
Licenseapache-2.0

What is TurboQuant?

TurboQuant (ICLR 2026) applies random orthogonal rotations followed by optimal scalar quantization to the KV cache. Bit-identical prefill logits at 4-bit, up to 4-8× memory savings for long sequences.

Benchmarks (from the TurboQuant repository, Llama 3.1 8B on RTX 5090 — results vary by model and hardware):

  • 4-bit KV cache: bit-identical prefill logits
  • ~1.4-1.7× speedup on Apple Silicon
  • Up to 8× KV memory savings

Benchmarks are from the TurboQuant repository using Llama 3.1 8B. Performance on gemma-4-E4B will differ. Please open a discussion if you have independent results.

Current Ecosystem Support

RuntimeTurboQuant SupportNotes
Python transformers + turboquant✅ FullDrop-in cache class
llama.cpp upstream❌ Not mergedUse fork below
llama-cpp-turboquant fork✅ planar3, iso3GitHub
LM Studio❌ RequestedUse q8_0 as alternative
Ollama❌ Not supportedUse OLLAMA_KV_CACHE_TYPE=q8_0
vLLM❌ Not supported—
koboldcpp❌ Not supported—

Pre-quantized weight variants

If you want combined weight + KV cache compression, majentik hosts pre-quantized versions:

See Also

Variants in this family

(Showing 13 sibling variants under majentik/gemma-4-e4b-*. The current variant — TurboQuant — is bolded.)

VariantRuntimeApprox sizeUse case
RotorQuantruntime modifiern/aKV-cache root (weight-agnostic)
RotorQuant-GGUF-IQ4_XSllama.cpp~3.4 GBLossy 4-bit, low-RAM CPU/edge
RotorQuant-GGUF-Q2_Kllama.cpp~2.4 GBLossy, low-RAM CPU/edge
RotorQuant-GGUF-Q3_K_Mllama.cpp~3.1 GBSmaller 3-bit, CPU-friendly
RotorQuant-GGUF-Q4_K_Mllama.cpp~4.4 GBBalanced default
RotorQuant-GGUF-Q5_K_Mllama.cpp~5.3 GBHigher fidelity, more RAM
RotorQuant-GGUF-Q8_0llama.cpp~8.4 GBNear-lossless reference
RotorQuant-MLX-2bitmlx-lm~1.3 GBApple Silicon, smallest
RotorQuant-MLX-4bitmlx-lm~2.5 GBApple Silicon balanced
RotorQuant-MLX-8bitmlx-lm~4.7 GBApple Silicon reference
TurboQuantruntime modifiern/aKV-cache root (weight-agnostic)
TurboQuant-MLX-2bitmlx-lm~1.3 GBApple Silicon, smallest
TurboQuant-MLX-4bitmlx-lm~2.5 GBApple Silicon balanced
TurboQuant-MLX-8bitmlx-lm~4.7 GBApple Silicon reference

Sources

1 source
Hugging FacePrimaryVersion 681971d77b78b49f9f21bdb8832e084ab972a559
huggingface.co/majentik/gemma-4-E4B-turboquant/tree/681971d77b78b49f9f21bdb8832e084ab972a559

Verified Sep 18

Model artifacts

1 artifact

model.safetensors

safetensors · 14.9 GB · SHA-256 cfbd3d2f1cd7…5503 · Hugging Face

Download

Source excerpts

2 excerpts

--- license: apache-2.0 base_model: google/gemma-4-E4B tags: - turboquant - kv-cache-quantization - gemma - gemma4 - edge - quantized library_name: transformers pipeline_tag: image-text-to-text --- > [!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_0` with `OLLAMA_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](https://github.com/ggml-org/llama.cpp/pull/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. <!-- kv-upstream-note --> # gemma-4-E4B-TurboQuant **TurboQuant KV cache compression** for [google/gemma-4-E4B](https://huggingface.co/google/gemma-4-E4B). This is a **documentation repository** that explains how to combine gemma-4-E4B's weights with TurboQuant inference-time KV cache compression. No weights are stored here — use the base model directly and apply TurboQuant via the Python package or llama.cpp fork. ## Hardware compatibility | 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 | ## What is this? KV cache compression reduces the memory used by the attention cache during inference. Unlike weight quantization (which is baked into the GGUF/MLX file), KV cache compression is applied at runtime — so the same base weights can be used with or without compression. | Technique | Where it's applied | Savings | |-----------|-------------------|---------| | **TurboQuant KV cache** | At inference time | Reduces attention memory (critical for long context) | Both can be combined for maximum efficiency. ## Quickstart ### Option A — Python / transformers Install the `turboquant` pac...

Source context: 32 downloads · 8 likes · Pipeline image-text-to-text · Library transformers · Repo majentik/gemma-4-E4B-turboquant