Image-Text-to-Text
MLX
Safetensors
gemma4
rotorquant
kv-cache-quantization
gemma
multimodal
quantized
4bit
4-bit precision
Instructions to use majentik/gemma-4-E2B-RotorQuant-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use majentik/gemma-4-E2B-RotorQuant-MLX-4bit 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-E2B-RotorQuant-MLX-4bit") config = load_config("majentik/gemma-4-E2B-RotorQuant-MLX-4bit") # 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
- Atomic Chat
Card accuracy sweep: honest brand labeling, remove dead links, upstream KV tip
Browse files32 unmodified lines3334353637383935 unmodified lines75767778798081828384858687888990919293949541 unmodified lines1371381391401411421433 unmodified lines14714814915015115215332 unmodified lines# Gemma 4 E2B - RotorQuant MLX 4-bit**4-bit weight-quantized MLX version** of [google/gemma-4-E2B](https://huggingface.co/google/gemma-4-E2B) 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. A good balance between model quality and memory efficiency.Approximate model size: **~1.2 GB**35 unmodified linesprint(output)```## What is RotorQuant?[RotorQuant](https://github.com/scrya-com/rotorquant) is a high-performance KV-cache quantization method that achieves significantly better throughput than TurboQuant. Combined with 4-bit weight quantization in MLX, this provides a dual compression strategy with superior KV-cache performance: smaller model weights plus faster compressed KV cache for efficient long-context generation.Key advantages over TurboQuant:- **5.3x faster prefill**- **28% faster decode**- Equivalent memory savings## KV-Cache Quantization Comparison| Method | Prefill Speed | Decode Speed | Memory Savings | Reference ||---|---|---|---|---|| **TurboQuant** | 1x (baseline) | 1x (baseline) | High | [arXiv: 2504.19874](https://arxiv.org/abs/2504.19874) || **RotorQuant** | **5.3x faster** | **28% faster** | High | [GitHub](https://github.com/scrya-com/rotorquant) |## Memory Estimates (Gemma 4 E2B)41 unmodified lines| Variant | Runtime | Approx size | Use case ||---|---|---|---|| [RotorQuant](https://huggingface.co/majentik/gemma-4-e2b-rotorquant) | runtime modifier | n/a | KV-cache root (weight-agnostic) || [RotorQuant-GGUF-IQ4_XS](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-IQ4_XS) | llama.cpp | ~1.7 GB | Lossy 4-bit, low-RAM CPU/edge || [RotorQuant-GGUF-Q2_K](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-Q2_K) | llama.cpp | ~1.2 GB | Lossy, low-RAM CPU/edge || [RotorQuant-GGUF-Q3_K_M](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-Q3_K_M) | llama.cpp | ~1.6 GB | Smaller 3-bit, CPU-friendly |3 unmodified lines| [RotorQuant-MLX-2bit](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-mlx-2bit) | mlx-lm | ~655 MB | Apple Silicon, smallest || **RotorQuant-MLX-4bit** | mlx-lm | ~1.2 GB | Apple Silicon balanced || [RotorQuant-MLX-8bit](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-mlx-8bit) | mlx-lm | ~2.4 GB | Apple Silicon reference || [TurboQuant](https://huggingface.co/majentik/gemma-4-e2b-turboquant) | runtime modifier | n/a | KV-cache root (weight-agnostic) || [TurboQuant-MLX-2bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-2bit) | mlx-lm | ~655 MB | Apple Silicon, smallest || [TurboQuant-MLX-4bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-4bit) | mlx-lm | ~1.2 GB | Apple Silicon balanced || [TurboQuant-MLX-8bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-8bit) | mlx-lm | ~2.4 GB | Apple Silicon reference |32 unmodified lines3334353637383935 unmodified lines75767778798081828384858687888990919293949541 unmodified lines1371381391401411423 unmodified lines14614714814915015132 unmodified lines# Gemma 4 E2B - RotorQuant MLX 4-bit**4-bit weight-quantized MLX version** of [google/gemma-4-E2B](https://huggingface.co/google/gemma-4-E2B) with the legacy RotorQuant KV-cache fork (superseded by upstream llama.cpp KV options). 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. A good balance between model quality and memory efficiency.Approximate model size: **~1.2 GB**35 unmodified linesprint(output)```## About the RotorQuant / TurboQuant labelsRotorQuant and TurboQuant are this project's **release labels**, not distinctquantization algorithms — for any given tier, both brand repos carrybyte-identical weights produced with the standard MLX / llama.cpp quantizers.No brand-specific speedup is claimed or measured. The KV-cache fork theselabels originally referred to is legacy; for KV-cache memory savings use theupstream options described above (`-ctk/-ctv q8_0`, `OLLAMA_KV_CACHE_TYPE`).## KV-Cache Quantization Comparison| Method | Prefill Speed | Decode Speed | Memory Savings | Reference ||---|---|---|---|---|| **TurboQuant** | 1x (baseline) | 1x (baseline) | High | [arXiv: 2504.19874](https://arxiv.org/abs/2504.19874) |## Memory Estimates (Gemma 4 E2B)41 unmodified lines| Variant | Runtime | Approx size | Use case ||---|---|---|---|| [RotorQuant-GGUF-IQ4_XS](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-IQ4_XS) | llama.cpp | ~1.7 GB | Lossy 4-bit, low-RAM CPU/edge || [RotorQuant-GGUF-Q2_K](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-Q2_K) | llama.cpp | ~1.2 GB | Lossy, low-RAM CPU/edge || [RotorQuant-GGUF-Q3_K_M](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-gguf-Q3_K_M) | llama.cpp | ~1.6 GB | Smaller 3-bit, CPU-friendly |3 unmodified lines| [RotorQuant-MLX-2bit](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-mlx-2bit) | mlx-lm | ~655 MB | Apple Silicon, smallest || **RotorQuant-MLX-4bit** | mlx-lm | ~1.2 GB | Apple Silicon balanced || [RotorQuant-MLX-8bit](https://huggingface.co/majentik/gemma-4-e2b-rotorquant-mlx-8bit) | mlx-lm | ~2.4 GB | Apple Silicon reference || [TurboQuant-MLX-2bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-2bit) | mlx-lm | ~655 MB | Apple Silicon, smallest || [TurboQuant-MLX-4bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-4bit) | mlx-lm | ~1.2 GB | Apple Silicon balanced || [TurboQuant-MLX-8bit](https://huggingface.co/majentik/gemma-4-e2b-turboquant-mlx-8bit) | mlx-lm | ~2.4 GB | Apple Silicon reference |
README.md+9-11