Instructions to use Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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("Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 Brooooooklyn/Gemma-4-26B-A4B-NVFP4-mlx
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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 "Brooooooklyn/Gemma-4-26B-A4B-NVFP4-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"
Gemma-4-26B-A4B-NVFP4-mlx
An MLX transcode of NVIDIA's nvidia/gemma-4-26b-a4b-nvfp4
(a TensorRT Model Optimizer NVFP4 PTQ of Google's google/gemma-4-26b-a4b-it),
repacked so it loads and runs on Apple Silicon via mlx-node
(and other MLX runtimes that read the quantization block).
gemma-4-26b-a4b is a sparse Mixture-of-Experts model — 30 layers, 128 experts per layer,
~4B active parameters (A4B) out of ~26B total. NVIDIA's checkpoint ships the experts in a Blackwell
FP4 layout (packed-U8 NVFP4 + weight_scale / weight_scale_2 / input_scale sidecars), which is
not loadable by MLX runtimes as-is. This repo preserves NVIDIA's exact per-tensor bit allocation
while re-expressing each quantized expert in an MLX-native NVFP4 the Metal kernels understand.
Quantization recipe
NVIDIA's NVFP4 recipe here is experts-only: only the MoE expert projections are 4-bit; everything else — attention, router, the per-layer dense MLP, all norms, the tied embedding/head, and the vision tower — stays bf16. This checkpoint reproduces that allocation exactly.
| Layer group | NVIDIA (modelopt) | This checkpoint (MLX) |
|---|---|---|
MoE experts experts.{gate,up,down}_proj (128×/layer) |
NVFP4 (E2M1, 2-level, gs16) | NVFP4 — 4-bit, group size 16 |
self_attn q/k/v/o + q_norm/k_norm |
bf16 (excluded) | bf16 |
router.proj / router.scale / per_expert_scale |
bf16 (excluded) | bf16 |
dense mlp.{gate,up,down}_proj (parallel to MoE) |
bf16 (excluded) | bf16 |
embed_tokens (tied = lm_head) |
bf16 (excluded) | bf16 |
vision_tower.* / embed_vision.* |
bf16 (excluded) | bf16 |
all layernorms, final norm |
bf16 | bf16 |
Notes:
- Experts-only NVFP4 mirrors NVIDIA's allocation. In an A4B MoE the experts hold the vast majority
of the parameters, so quantizing just the experts to 4-bit captures almost all of the size win
(
49 GB bf16 → **19 GB**) while leaving the small, precision-sensitive attention / router / dense-MLP paths in bf16 — exactly the modules NVIDIA lists underexclude_modules. - The head is the bf16 tied embedding.
tie_word_embeddings: true, and NVIDIA excludeslm_head, so logits are produced by the untied-nothing tied embedding matmul in bf16 — no separate (and no quantized) head is stored. - NVFP4 experts are a faithful re-quantization of NVIDIA's. Each expert was dequantized from NVIDIA's
NVFP4 (E2M1 × per-16
E4M3block-scale × per-tensorF32) to bf16, then re-quantized to MLX NVFP4 (gs16). The dequantized experts match the bf16-itreference at cosine 0.9955; loading a micro-scaled (biasless) NVFP4 expert needs an MLX runtime with a mode-aware batched-expert loader — on mlx-node that is theswitch_gluNVFP4 path (gather_qmmmodenvfp4). - Vision weights are carried through in bf16 but the multimodal path is not verified in this repo; this checkpoint is validated for text generation.
On-disk size is ~19 GB (bf16 reference is ~49 GB).
How it was made
- Dequantize NVIDIA's NVFP4 experts → bf16, fuse
gate‖upand stack the 128 experts into the reference layoutexperts.gate_up_proj [128, 1408, 2816]+down_proj [128, 2816, 704]; carry every non-expert tensor through unchanged (they are already bf16 in NVIDIA's checkpoint). Validated vsgoogle/gemma-4-26b-a4b-it: cosine 0.9955. mlx convert(bf16, no quantization) to sanitize into MLX layout (key remapmodel.language_model.*→language_model.model.*, split the fused experts intoswitch_glu.{gate,up,down}_proj, drop the tiedlm_head, keepvision_tower.*).- Per-expert
mx.quantize(..., mode="nvfp4", group_size=16, bits=4)on theswitch_gluexperts only; writequantization+quantization_configblocks (base{nvfp4,4,16}+ per-expert overrides). All other tensors stay bf16 (no.scales→ loaded dense).
Usage (mlx-node)
import { loadSession } from '@mlx-node/lm';
const session = await loadSession('./Gemma-4-26B-A4B-NVFP4-mlx');
for await (const ev of session.sendStream('Explain what a mixture-of-experts layer is.')) {
if (!ev.done) process.stdout.write(ev.text);
}
Caveats
- Validated for text generation on mlx-node (loads + generates coherent output). Vision weights are carried in bf16 but the multimodal path is not verified here.
- Sparse MoE (128 experts, ~4B active): decode is expert-memory-bandwidth-bound. Performance is comparable to other ~26B-A4B MLX quants of this model; treat any numbers as indicative and thermally sensitive.
License & attribution
Governed by the Gemma Terms of Use, inherited from google/gemma-4-26b-a4b-it
via nvidia/gemma-4-26b-a4b-nvfp4. This repository
only re-expresses the weights in an MLX-loadable quantization; all model capability and training credit
belongs to Google (and the NVFP4 PTQ to NVIDIA).
- Downloads last month
- 45
4-bit