Instructions to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("EigenLabs/gemma-4-31B-it-qat-q4_0-MLX") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX"
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- OpenClaw new
How to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- MLX LM
How to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use EigenLabs/gemma-4-31B-it-qat-q4_0-MLX with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default EigenLabs/gemma-4-31B-it-qat-q4_0-MLX
Run Hermes
hermes
Configure OpenClaw
# Install OpenClaw:
npm install -g openclaw@latest# Register the local server and set it as the default model:
openclaw onboard --non-interactive --mode local \
--auth-choice custom-api-key \
--custom-base-url http://127.0.0.1:8080/v1 \
--custom-model-id "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX" \
--custom-provider-id mlx-lm \
--custom-compatibility openai \
--custom-text-input \
--accept-risk \
--skip-healthRun OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"Gemma 4 31B IT — QAT q4_0, grid-faithful MLX (20 GB)
Built with Gemma. A grid-faithful MLX conversion of Google's QAT q4_0 checkpoint of Gemma 4 31B IT — the quantization grid the model was quantization-aware-trained for, emitted directly in MLX's native affine format. Runs on Apple Silicon via mlx-lm and MLX-Swift with stock kernels.
Why grid-faithful matters
Google QAT-trained these weights against the q4_0 grid (int4, group
size 32, symmetric): ~53% of weights sit exactly on grid points. Re-quantizing
with a generic asymmetric min-max quantizer builds a different grid and
snaps those weights to the wrong points — we measured +6.3% deviation from
the model Google validated. Instead, this conversion computes the q4_0 codes
(d = absmax/−8, q = round(w/d)+8) and emits them as native MLX affine
triplets (scales = d, biases = −8·d, gs32) — mathematically the same grid.
Measured fidelity (rel-RMS, sampled across all depths):
| Reference | This artifact | Naive MLX min-max |
|---|---|---|
| q4_0-intended model (what Google validated) | 0.135% (bf16-scale rounding only) | 6.32% |
| BF16 QAT master | 5.03% (≈ the 4.99% the QAT targets) | 6.15% |
Layout (mirrors Google's shipped GGUF / compressed-tensors exactly)
| Tensor class | Precision |
|---|---|
| All decoder linears (q/k/v/o, gate/up/down, 60 layers) | 4-bit gs32, q4_0-faithful |
embed_tokens (tied lm_head) |
6-bit gs64 (mirrors Q6_K) |
Norms, QAT layer_scalar, rope |
unquantized |
| Vision tower | bf16, unquantized (as Google ships it) |
Benchmarks (Apple M5 Max, 40-core GPU, 614 GB/s)
- Decode: ~26 tok/s single-stream (≈90% of the memory-bandwidth ceiling for a dense 31B at ~5 bpw)
- Peak memory: 19.7 GB
Usage
pip install mlx-lm
python -m mlx_lm generate --model EigenLabs/gemma-4-31B-it-qat-q4_0-MLX \
--prompt "Explain quantization-aware training in one paragraph."
Vision tensors are included with original names: text-only loaders skip them; mlx-vlm can consume them for multimodal use.
Provenance & terms
Converted from google/gemma-4-31B-it-qat-q4_0-unquantized with a
deterministic, calibration-free converter (no further training). Weight values
are bit-derived from Google's QAT release; use is subject to the
Gemma Terms of Use. Fidelity numbers are
weight-space; the conversion is designed to inherit the QAT checkpoint's
validated quality by construction rather than re-evaluating it.
- Downloads last month
- 210
4-bit
Model tree for EigenLabs/gemma-4-31B-it-qat-q4_0-MLX
Base model
google/gemma-4-31B
Start the MLX server
# Install MLX LM: uv tool install mlx-lm# Start a local OpenAI-compatible server: mlx_lm.server --model "EigenLabs/gemma-4-31B-it-qat-q4_0-MLX"