Text Generation
MLX
Safetensors
English
glm_moe_dsa
apple-silicon
Mixture of Experts
pruned
quantized
soul-targeted
agentic
local-agent
glm
conversational
Eval Results (legacy)
4-bit precision
Instructions to use philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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("philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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": "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX
Run Hermes
hermes
- OpenClaw new
How to use philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-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 "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philipjohnbasile/GLM-5.2-Demolition-q4a4-soul-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }'
File size: 3,327 Bytes
9c04b0e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # Can we code MLX ourselves for more decode speed? (June 2026 deep dive)
**Question:** the agentic coder's one weakness is decode speed (~11β14 tok/s). Can custom MLX/Metal code beat it?
## The wall (unchanged, re-confirmed)
Decode is **memory-bandwidth-bound** β generation speed β *bytes moved per token* (every token streams the active
expert weights through the memory bus). TTFT is compute-bound (and the M5 fixes that); decode is not. Our **#33 fused
MoE dequant-matmul Metal kernel already IS the 11β14 tok/s** β it maxed the compute side. You cannot out-*compute*
bandwidth. "More speed" = fewer bytes/token, or faster per-byte processing on M5 hardware.
## Lever 1 β NVFP4 on the M5 hardware path *(easy, no custom code, biggest, do first)*
- **We already have it** (probed: `mx.quantize(..., mode="nvfp4", group_size=16)` works on our MLX 0.31.2).
- **Round-trip fidelity:** affine-3bit mean|err| **0.159** vs **NVFP4-4bit 0.077** β *half the quantization damage.*
- **M5 hardware path:** the Neural Accelerators have a native NVFP4 dequant+matmul; a 35B-A3B MoE went **58β112 tok/s
(2Γ)** on M5 Max with NVFP4. It's 4-bit (more bytes than our 3-bit) but the hardware path + better fidelity net a win.
- **Action:** re-quantize the 4-bit layers in **#59** as NVFP4 (group 16), keep the middle 3-bit affine; measure decode.
Zero custom code β just the quant mode + a `04b/24b` NVFP4 path.
## Lever 2 β a Metal-4 **TensorOps** fused-MoE kernel *(the "code it ourselves" win, ~30β60%)*
- **#33's kernel predates the M5** β it uses plain Metal, not the **Neural Accelerators' hardware matmul** (Metal 4
TensorOps). MLX gets 30β60% on M5 by using TensorOps; a *custom* MoE kernel that does too captures that for our model.
- **How:** `mx.fast.metal_kernel` + Metal 4 **TensorOps** β slice the gather'd expert weights into tiles, tile-wise
matmul on the Neural Accelerators, keep data in cache (WWDC26 session 330 "Optimize custom ML operations with Metal
tensors" is the recipe). Fuse: expert-gather β NVFP4-dequant β matmul β accumulate, in one dispatch.
- **Effort:** real Metal work (~weeks). Reference impls exist (TurboQuant-MLX fused kernels; simdgroup-MMA int4-MoE kernels).
## Honest ceiling
Neither lever breaks the bandwidth wall β they reduce bytes (NVFP4) and speed per-byte (TensorOps on the Accelerators).
Realistic: **11β14 β ~20β28 tok/s** from NVFP4+M5 alone; **~30+** with the custom TensorOps kernel. A genuine **2β3Γ**,
not 100+. Speculative decode stays dead on this MoE (any multi-token verify reloads ~all experts β the bandwidth wall again).
## Plan (CPU now β GPU later)
1. **NVFP4 re-quant** β wire `nvfp4` (group 16) into `04b`/`24b` as the 4-bit-layer format for #59; re-quant; **measure decode** (the proof).
2. If the gain lands and we want more β **write the Metal-4 TensorOps fused-MoE kernel** (the 30β60% lever); benchmark vs #33.
3. Keep the verify-everything stack (constrained decode, compiler-steer) intact β none of this touches it.
*Sources: MLX custom Metal kernels (ml-explore docs 0.31.2) Β· `mx.fast.metal_kernel` Β· WWDC26 #330 Metal tensors Β·
Apple "LLMs with MLX + M5 Neural Accelerators" Β· TurboQuant-MLX fused kernels Β· MLX-vs-llama.cpp M5 benchmarks (yage.ai 2026) Β· our SPEED.md root-cause.*
|