Instructions to use mlx-community/GLM-5.2-DQ4plus-q8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/GLM-5.2-DQ4plus-q8 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("mlx-community/GLM-5.2-DQ4plus-q8") 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) - Transformers
How to use mlx-community/GLM-5.2-DQ4plus-q8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mlx-community/GLM-5.2-DQ4plus-q8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mlx-community/GLM-5.2-DQ4plus-q8") model = AutoModelForCausalLM.from_pretrained("mlx-community/GLM-5.2-DQ4plus-q8") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use mlx-community/GLM-5.2-DQ4plus-q8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mlx-community/GLM-5.2-DQ4plus-q8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/GLM-5.2-DQ4plus-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mlx-community/GLM-5.2-DQ4plus-q8
- SGLang
How to use mlx-community/GLM-5.2-DQ4plus-q8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mlx-community/GLM-5.2-DQ4plus-q8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/GLM-5.2-DQ4plus-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mlx-community/GLM-5.2-DQ4plus-q8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/GLM-5.2-DQ4plus-q8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Pi
How to use mlx-community/GLM-5.2-DQ4plus-q8 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/GLM-5.2-DQ4plus-q8"
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": "mlx-community/GLM-5.2-DQ4plus-q8" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use mlx-community/GLM-5.2-DQ4plus-q8 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 "mlx-community/GLM-5.2-DQ4plus-q8"
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 mlx-community/GLM-5.2-DQ4plus-q8
Run Hermes
hermes
- MLX LM
How to use mlx-community/GLM-5.2-DQ4plus-q8 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "mlx-community/GLM-5.2-DQ4plus-q8"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "mlx-community/GLM-5.2-DQ4plus-q8" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mlx-community/GLM-5.2-DQ4plus-q8", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use mlx-community/GLM-5.2-DQ4plus-q8 with Docker Model Runner:
docker model run hf.co/mlx-community/GLM-5.2-DQ4plus-q8
| license: mit | |
| library_name: mlx | |
| tags: | |
| - mlx | |
| - transformers | |
| pipeline_tag: text-generation | |
| base_model: zai-org/GLM-5.2 | |
| # mlx-community/GLM-5.2-DQ4plus-q8 | |
| This model [mlx-community/GLM-5.2-DQ4plus-q8](https://huggingface.co/mlx-community/GLM-5.2-DQ4plus-q8) was converted to MLX format from [zai-org/GLM-5.2](https://huggingface.co/zai-org/GLM-5.2) using mlx-lm version **0.31.3** (with PR #1410). | |
| This is created for people using a single Apple Mac Studio M3 Ultra with 512 GB. The 4-bit version of GLM-5.2 fits comfortably. But we can do better. Using research results, we aim to get better results from a slightly larger and smarter quantization. It should also not be so large that it leaves no memory for a useful context window. | |
| You can find more similar MLX model quants for Apple Mac Studio with 512 GB at https://huggingface.co/bibproj | |
| ```bash | |
| pip install mlx-lm | |
| mlx_lm.generate --model mlx-community/GLM-5.2-DQ4plus-q8 --prompt "Hallo" | |
| ``` | |
| --- | |
| ## What is this DQ4plus-q8? | |
| In the Arxiv paper [Quantitative Analysis of Performance Drop in DeepSeek Model Quantization](https://arxiv.org/abs/2505.02390) the authors write, | |
| > We further propose `DQ3_K_M`, a dynamic 3-bit quantization method that significantly outperforms traditional `Q3_K_M` variant on various benchmarks, which is also comparable with 4-bit quantization (`Q4_K_M`) approach in most tasks. | |
| and | |
| > dynamic 3-bit quantization method (`DQ3_K_M`) that outperforms the 3-bit quantization implementation in `llama.cpp` and achieves performance comparable to 4-bit quantization across multiple benchmarks. | |
| The resulting multi-bitwidth quantization has been well tested and documented. | |
| --- | |
| ## How can you create your own DQ4plus-q8 quants? | |
| This time the recipe is a bit different from that of a normal DQ3_K_M. To make to the quant perform better under stress, only the `up` and `gate` expert tensors are quantized to 4-bit, and the `down` expert to a mix of 5-bit and 6-bit. All the other tensors are kept at 8-bit. You could say that this quant has an 8-bit "brain" and 4-bit/5-bit/6-bit experts. | |
| In the `convert.py` file of mlx-lm on your system ( [you can see the original code here](https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/convert.py) ), replace the code inside `def mixed_quant_predicate()` with something like | |
| ```python | |
| # Build a mixed quant like "DQ4plus-q8" similar to the "DQ3" of Arxiv paper https://arxiv.org/abs/2505.02390 | |
| # Quantitative Analysis of Performance Drop in DeepSeek Model Quantization | |
| q_bits = 8 | |
| # For "switch experts" | |
| if "switch_mlp.up_proj" in path: | |
| q_bits = 4 | |
| if "switch_mlp.gate_proj" in path: | |
| q_bits = 4 | |
| if "switch_mlp.down_proj" in path: | |
| q_bits = 5 | |
| # Blocks up to 5 are higher quality | |
| if index < 5: | |
| q_bits = 6 | |
| # Every 5th block is "medium" quality | |
| if (index % 5) == 0: | |
| q_bits = 6 | |
| print("path:", path, "index:", index, "q_bits:", q_bits) | |
| return {"group_size": group_size, "bits": q_bits, "mode": mode} | |
| ``` | |
| Then create your GLM-5.2-DQ4plus-q8 quant with | |
| ```bash | |
| mlx_lm.convert --hf-path zai-org/GLM-5.2 --mlx-path GLM-5.2-DQ4plus-q8 -q --quant-predicate mixed_3_4 | |
| ``` | |
| --- | |
| Enjoy! | |