Image-Text-to-Text
MLX
Safetensors
gemma4
rotorquant
kv-cache-quantization
gemma
multimodal
quantized
2bit
2-bit
Instructions to use majentik/gemma-4-E4B-RotorQuant-MLX-2bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use majentik/gemma-4-E4B-RotorQuant-MLX-2bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("majentik/gemma-4-E4B-RotorQuant-MLX-2bit") config = load_config("majentik/gemma-4-E4B-RotorQuant-MLX-2bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
docs: upstream-first KV-cache guidance (q8_0/q4_0, mainline Hadamard rotation); fork demoted to experimental
Browse files
README.md
CHANGED
|
@@ -14,6 +14,23 @@ license: apache-2.0
|
|
| 14 |
pipeline_tag: image-text-to-text
|
| 15 |
---
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Gemma 4 E4B - RotorQuant MLX 2-bit
|
| 18 |
|
| 19 |
**2-bit weight-quantized MLX version** of [google/gemma-4-E4B](https://huggingface.co/google/gemma-4-E4B) with RotorQuant KV-cache quantization. Optimized for Apple Silicon inference via the [MLX](https://github.com/ml-explore/mlx) framework. RotorQuant delivers 5.3x faster prefill and 28% faster decode compared to TurboQuant. The most aggressive quantization, fitting the full model in the smallest possible footprint.
|
|
|
|
| 14 |
pipeline_tag: image-text-to-text
|
| 15 |
---
|
| 16 |
|
| 17 |
+
> [!TIP]
|
| 18 |
+
> **KV-cache quantization without any fork (recommended, 2026):** upstream
|
| 19 |
+
> llama.cpp/Ollama now cover this natively — use `-ctk q8_0 -ctv q8_0`
|
| 20 |
+
> (~half KV memory, negligible quality loss: perplexity +0.002–0.05) or
|
| 21 |
+
> `-ctk q4_0 -ctv q4_0` (~quarter memory, ≈7.6% perplexity increase). In
|
| 22 |
+
> Ollama: `OLLAMA_KV_CACHE_TYPE=q8_0` with `OLLAMA_FLASH_ATTENTION=1`. Keep
|
| 23 |
+
> K and V types symmetric to stay on the fast fused Flash-Attention path.
|
| 24 |
+
> Since April 2026, mainline llama.cpp also applies Hadamard rotation to
|
| 25 |
+
> KV activations ([PR #21038](https://github.com/ggml-org/llama.cpp/pull/21038)),
|
| 26 |
+
> which greatly improves low-bit KV quality (opt-out:
|
| 27 |
+
> `LLAMA_ATTN_ROT_DISABLE=1`).
|
| 28 |
+
>
|
| 29 |
+
> The RotorQuant/TurboQuant fork flow below is **experimental/legacy**: the
|
| 30 |
+
> TurboQuant llama.cpp PR was closed without merging (June 2026) and the fork
|
| 31 |
+
> is unmaintained relative to mainline. It is NOT required to use this model.
|
| 32 |
+
<!-- kv-upstream-note -->
|
| 33 |
+
|
| 34 |
# Gemma 4 E4B - RotorQuant MLX 2-bit
|
| 35 |
|
| 36 |
**2-bit weight-quantized MLX version** of [google/gemma-4-E4B](https://huggingface.co/google/gemma-4-E4B) with RotorQuant KV-cache quantization. Optimized for Apple Silicon inference via the [MLX](https://github.com/ml-explore/mlx) framework. RotorQuant delivers 5.3x faster prefill and 28% faster decode compared to TurboQuant. The most aggressive quantization, fitting the full model in the smallest possible footprint.
|