Instructions to use pgmharikrishnan/grug-35b-v2-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use pgmharikrishnan/grug-35b-v2-MLX-4bit 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("pgmharikrishnan/grug-35b-v2-MLX-4bit") 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 pgmharikrishnan/grug-35b-v2-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "pgmharikrishnan/grug-35b-v2-MLX-4bit"
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": "pgmharikrishnan/grug-35b-v2-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use pgmharikrishnan/grug-35b-v2-MLX-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "pgmharikrishnan/grug-35b-v2-MLX-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "pgmharikrishnan/grug-35b-v2-MLX-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pgmharikrishnan/grug-35b-v2-MLX-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use pgmharikrishnan/grug-35b-v2-MLX-4bit 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 "pgmharikrishnan/grug-35b-v2-MLX-4bit"
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 pgmharikrishnan/grug-35b-v2-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use pgmharikrishnan/grug-35b-v2-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "pgmharikrishnan/grug-35b-v2-MLX-4bit"
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 "pgmharikrishnan/grug-35b-v2-MLX-4bit" \ --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"
Grug 35B v2 — MLX 4-bit
This repository provides Grug 35B v2 quantized to 4-bit format for native execution on Apple Silicon via MLX and mlx-lm.
- Original Model:
ProCreations/grug-35b-v2(Qwen3.5 MoE, 35B total / ~3B active, 256 experts × 8/tok, 40 layers) - Model Size: ~18 GB (split across 4 safetensors shards)
- Quantization Scheme: 4-bit affine quantization (
q_group_size=64,bfloat16non-quantized weights, ~4.503 bits/weight effective). MoE router layers (mlp.gate,shared_expert_gate) are kept at 8-bit by stock mlx-lm MoE policy — routing stays precise while bulk expert weights go 4-bit. - Vision: text-only conversion (vision tower excluded, same as the 27B MLX). For a vision-enabled MLX build see
leonsarmiento/grug-35b-v2-6bit-XL-mlx. - Conversion note: the official checkpoint ships unfused per-expert weights, which stock
mlx_lm.convert0.31.3 rejects. Experts were stacked/concatenated into the fused layout (experts.gate_up_proj+experts.down_proj) before the identical stock load → bf16 cast → quantize → save flow. Fusion verified exact (layer-0 expert-0 gate byte-identical pre-quantize).
Why Grug v2?
Grug v2 trains the model to compress internal reasoning into ultra-concise mental checks, eliminating <think> token bloat from the response stream while maintaining reasoning depth and tool-calling precision. v2.1 added long-hunt data, deep-think and stuck-loop escape on top of the 35B MoE base.
Apple Silicon Metal Smoke Test (Mac Studio M4 Max, 128 GB)
Single-prompt verification run (same prompt shape as the 27B card):
| Metric | Grug 35B v2 (Native MLX 4-bit) |
|---|---|
| Task | numbers_closer_than_threshold — correct itertools.combinations solution |
<think> block |
concise, single-sentence style |
| Generation | 128 tokens @ 124.8 tok/s |
| Prompt prefill | 27 tokens @ 16.2 tok/s |
| Peak memory | 19.7 GB |
<think>
Use itertools.combinations to compare every pair. abs difference < threshold indicates close pair.
</think>
```python
from itertools import combinations
def numbers_closer_than_threshold(numbers, threshold):
"""
Return True if any two numbers in the list are closer than `threshold`.
"""
for a, b in combinations(numbers, 2):
if abs(a - b) < threshold:
return True
return False
---
## Usage
### 1. Installation
```bash
pip install -U mlx-lm
2. Python API
from mlx_lm import load, generate
model_id = "pgmharikrishnan/grug-35b-v2-MLX-4bit"
model, tokenizer = load(model_id)
prompt = "Implement a python function to find the longest palindromic substring."
response = generate(
model,
tokenizer,
prompt=prompt,
max_tokens=512,
verbose=True
)
print(response)
3. Command Line Generation
mlx_lm.generate \
--model pgmharikrishnan/grug-35b-v2-MLX-4bit \
--prompt "Write a Python function to check if numbers in a list are closer than a threshold." \
--max-tokens 512
4. Local OpenAI-Compatible Serving
mlx_lm.server \
--model pgmharikrishnan/grug-35b-v2-MLX-4bit \
--port 8080
Serving note: do NOT point mlx-serve's pinned 4-model resident set at this repo without recomputing the memory budget — it is a fifth resident model on a 4-model cap (config/mlx-serve/models.conf).
Quantization Details
- Tool:
mlx_lm.convert0.31.3 flow (with unfused→fused expert pre-pass, see note above) - Bits: 4-bit (routers 8-bit, stock MoE policy)
- Group Size: 64
- Quantization Mode:
affine - Weight Dtype:
bfloat16 - Effective Bits per Weight: 4.503
Related
- 27B sibling (same recipe):
pgmharikrishnan/grug-v1.1-qwen-3.8-27b-MLX-4bit - QAT GGUF (llama.cpp, not the source of this conversion):
ProCreations/grug-35b-qat-q4-gguf
- Downloads last month
- 35
4-bit