Faster Gemma 4 on MLX with multi-token prediction
Summary
Ollama 0.31 significantly boosts Gemma 4's performance on Apple Silicon, achieving nearly 90% faster token generation on average across the Aider polyglot coding-agent benchmark. This speedup, enabled by default, comes from Multi-Token Prediction (MTP), where a small, fast draft model proposes several tokens that the main model then verifies in a single pass. This approach is particularly effective for predictable content like code, making coding agents more responsive. Ollama automatically tunes the optimal draft length at runtime, adapting to factors like model quantization, hardware, and text predictability to maximize tokens per second. Furthermore, a new MLX kernel contributed for batch verification accelerates Gemma 4's largest matrix multiplications by 2x to 2.5x on an M5 Max with nvfp4, by reusing weights across the batch. This improvement is currently available for Gemma 4 12B (nvfp4) in Ollama 0.31 for macOS.
Key takeaway
For AI engineers deploying Gemma 4 on Apple Silicon, especially for coding agent applications, you should immediately update to Ollama 0.31. This enables nearly 90% faster token generation via multi-token prediction and optimized MLX kernels, making your coding agents noticeably more responsive. Ensure you re-pull the "gemma4:12b-mlx" model to activate these performance improvements, gaining substantial throughput without altering model output.
Key insights
Multi-token prediction with auto-tuning and optimized batch verification dramatically accelerates LLM inference.
Principles
- Speculative decoding boosts LLM throughput.
- Auto-tuning draft length optimizes MTP.
- Batch verification kernels reduce redundant work.
Method
A draft model proposes token sequences, verified by the main model in a single pass. Ollama auto-tunes draft length based on acceptance rates and verification times, using rollback points for rejections.
In practice
- Use Ollama 0.31 for faster Gemma 4.
- Re-pull Gemma 4 12B (nvfp4) for MTP.
- Apply MTP for coding agent tasks.
Topics
- Gemma 4
- Multi-token Prediction
- Ollama
- MLX
- Speculative Decoding
- LLM Inference
Best for: Machine Learning Engineer, AI Engineer, AI Hardware Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Ollama Blog.