GLM-4.7-Flash MLX

MLX builds of GLM-4.7-Flash (Z.ai's 30B-A3B mixture-of-experts model with thinking and tool calls), made by Moonbox for Apple Silicon Macs. Each build is a folder and a complete mlx-vlm model: weights, config.json, Z.ai's tokenizer, chat template and generation settings. These files are not an official Z.ai release.

Files

The last column is how far each build is from the original bf16 model (see "Quality" below for what was measured).

Precision File Size sha256 Against the original
8bit 8bit/chat_template.jinja 3.1 kB d63ad536c3c8 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/config.json 0.2 MB ae0564efc5fd KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/generation_config.json 0.2 kB e19f4eb8be12 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00001.safetensors 5.11 GB 0f701ca51ef2 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00002.safetensors 4.73 GB f114a8d18a68 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00003.safetensors 4.73 GB 584eb4aae2f9 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00004.safetensors 4.73 GB 38d29af9f988 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00005.safetensors 4.73 GB 31aa3aab05ad KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00006.safetensors 4.73 GB 5a22f7a6498f KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model-00007.safetensors 3.38 GB 1adc1efa9a6d KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/model.safetensors.index.json 0.2 MB 8ef520c26e19 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/tokenizer.json 20.2 MB 19e773648cb4 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
8bit 8bit/tokenizer_config.json 0.8 kB 5ae319074179 KL 0.019 nats (p95 0.041), top-1 agreement 93.20 %, perplexity 18.12 vs 17.99
6bit 6bit/chat_template.jinja 3.1 kB d63ad536c3c8 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/config.json 0.2 MB 99bfc1fb878a KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/generation_config.json 0.2 kB e19f4eb8be12 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00001.safetensors 4.58 GB 205845fd216a KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00002.safetensors 4.65 GB cde2e43e910a KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00003.safetensors 4.65 GB dcf40591e13b KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00004.safetensors 4.65 GB 5a5fe15ea595 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00005.safetensors 4.65 GB 1f5657808ff3 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model-00006.safetensors 1.55 GB cb6dcc5aa795 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/model.safetensors.index.json 0.2 MB 29e96a2df65f KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/tokenizer.json 20.2 MB 19e773648cb4 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
6bit 6bit/tokenizer_config.json 0.8 kB 5ae319074179 KL 0.028 nats (p95 0.063), top-1 agreement 92.19 %, perplexity 18.19 vs 17.99
4bit 4bit/chat_template.jinja 3.1 kB d63ad536c3c8 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/config.json 0.2 MB 5e18683ab404 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/generation_config.json 0.2 kB e19f4eb8be12 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/model-00001.safetensors 4.71 GB 284527a4c723 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/model-00002.safetensors 4.85 GB 3447ea0c4c67 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/model-00003.safetensors 4.85 GB a1c8f1373b2e KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/model-00004.safetensors 3.73 GB 15b026c1acc8 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/model.safetensors.index.json 0.2 MB 1e96e87c8a80 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/tokenizer.json 20.2 MB 19e773648cb4 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)
4bit 4bit/tokenizer_config.json 0.8 kB 5ae319074179 KL 0.035 nats (p95 0.100), top-1 agreement 90.51 %, perplexity 18.11 vs 17.99 (dynamic)

GLM-4.7-Flash (Z.ai's 30B-A3B mixture of experts: 64 routed experts and a shared one, 4 at work for each token, Multi-head Latent Attention) converted to MLX for Apple Silicon, in three builds. Each folder is a complete mlx-vlm model: weights, config.json, Z.ai's tokenizer, chat template and generation settings. Text only.

These files were converted by Moonbox from zai-org/GLM-4.7-Flash (revision 7dd20894). They are not an official Z.ai release.

How to run

With mlx-vlm 0.8.0 or later:

from huggingface_hub import snapshot_download
from mlx_vlm import load, generate

folder = snapshot_download("moonbox-dev/GLM-4.7-Flash-MLX", allow_patterns="4bit/*") + "/4bit"
model, processor = load(folder)
msgs = [{"role": "user", "content": "Explain in two sentences why the sky is blue."}]
prompt = processor.tokenizer.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True,
                                                 enable_thinking=False)
print(generate(model, processor, prompt, max_tokens=1024, temperature=1.0, top_p=0.95).text)
  • Chat template. [gMASK]<sop>, then <|system|>, <|user|>, <|assistant|> turns. Thinking is on by default (the reply opens inside <think>); enable_thinking=False closes it at once. Tool calls are <tool_call>name<arg_key>key</arg_key><arg_value>value</arg_value>...</tool_call> (strings as they are, other values as JSON), and a tool's result is sent back as <|observation|><tool_response>...</tool_response>. The turn ends with <|user|> or <|observation|> (both are end-of-turn tokens in generation_config.json). Z.ai's sampling: temperature 1.0, top_p 0.95 for most tasks; 0.7 and 1.0 for agentic coding.
  • The output head is bfloat16 in every build. It is this model's most sensitive layer: at 4 bits it alone costs about 14 points of next-token agreement, and the common plain 4-bit (every layer 4 bits) is far from the original (below).
  • No multi-token prediction. The checkpoint's MTP layer is left out: mlx-vlm 0.8.0 drops it on load and has no drafter for it. Measured on the 4-bit, a step that verifies two tokens costs 1.27x a plain one and the layer about 0.18x, so a drafter could give 1.1-1.3x at 60-90 % acceptance.
Build Size Runs on Layout
8bit 32.1 GB 64 GB Macs and up (48 GB: slow) 8 bits, group 64; the head bfloat16
6bit 24.7 GB 48 GB Macs and up (32 GB: slow) 6 bits, group 64; the head bfloat16
4bit 18.2 GB 32 GB Macs and up (24 GB: slow, other apps squeezed) dynamic: attention, the shared expert and layer 0's dense MLP 8 bits, the embedding 6, the routed experts 4; the head bfloat16
  • Memory and speed on a 24 GB MacBook Air (M5), through Moonbox's server (greedy, thinking off; a short answer, 512- and 4K-token prompts). Only the 4bit runs on this Mac; the others' numbers are estimates (memory: the weights plus what the 4-bit holds besides them; decode: scaled by the bytes a token reads).
Build Peak Decode (short / after 4K) Prefill 4K
8bit 33.0 GB (estimated) ~27 tok/s (estimated, this Mac's bandwidth)
6bit 25.6 GB (estimated) ~33 tok/s (estimated)
4bit 19.0 GB 33.9 / 28.7 tok/s 517 tok/s

Quality

MLX affine quantization; against the bf16 original (perplexity 17.99), teacher-forced through mlx-vlm's own layers one layer at a time, on 16,368 positions of English prose, Python and chat transcripts in the model's own template. The mark this lab uses is top-1 90 % (KL 0.01 ideal). This mixture of experts moves further from the original than a dense model at the same bits: even with only the head kept bfloat16, 8 bits leave a mean KL near 0.02, and leaving any other single part (attention, embedding, shared expert) bfloat16 instead changes it by under 0.001.

Build Mean KL (nats) KL p95 Top-1 agreement Perplexity
8bit 0.019 0.041 93.20 % 18.12
6bit 0.028 0.063 92.19 % 18.19
4bit 0.035 0.100 90.51 % 18.11

Measured the same way: a plain 4-bit (every layer 4 bits, group 64, 16.85 GB) at KL 0.413 and top-1 71.3 %; the mlx-community 4-bit, read from its files, at 0.418 and 71.0 % (lmstudio-community's 4-bit has the same layout and size); plain 8 and 6-bit (head quantized too) at 92.7 % and 90.6 %; other dynamic 4-bit layouts at 89.8-90.9 % for 17.7-19.3 GB. No 3-bit is published: the best dynamic one measured (15.8 GB) reached 87.1 %, and a plain 3-bit breaks down (3.6 %).

How these were made

From GLM-4.7-Flash at revision 7dd20894a6, read from the Hub tensor by tensor, by Moonbox's converter (lab/zoo/glm-4-7-flash/convert.py in Moonbox's repository): mlx-vlm's own sanitize and layout (each layer's 64 experts stacked, the latent attention's kv_b_proj split into its two halves, the router and its correction bias kept as they are), MLX affine quantization. The checkpoint's multi-token-prediction layer is left out (mlx-vlm drops it on load). Each build was checked against the original before upload (teacher-forced, layer by layer through mlx-vlm's own layers); the sha256 column above is what the files must hash to.

License

MIT, as the original model card declares. These files are a derivative of the original model: its weights were converted and quantized as described above. The original model card follows unchanged.


Original model card

GLM-4.7-Flash

๐Ÿ‘‹ Join our Discord community.
๐Ÿ“– Check out the GLM-4.7 technical blog, technical report(GLM-4.5).
๐Ÿ“ Use GLM-4.7-Flash API services on Z.ai API Platform.
๐Ÿ‘‰ One click to GLM-4.7.

Introduction

GLM-4.7-Flash is a 30B-A3B MoE model. As the strongest model in the 30B class, GLM-4.7-Flash offers a new option for lightweight deployment that balances performance and efficiency.

Performances on Benchmarks

Benchmark GLM-4.7-Flash Qwen3-30B-A3B-Thinking-2507 GPT-OSS-20B
AIME 25 91.6 85.0 91.7
GPQA 75.2 73.4 71.5
LCB v6 64.0 66.0 61.0
HLE 14.4 9.8 10.9
SWE-bench Verified 59.2 22.0 34.0
ฯ„ยฒ-Bench 79.5 49.0 47.7
BrowseComp 42.8 2.29 28.3

Evaluation Parameters

Default Settings (Most Tasks)

  • temperature: 1.0
  • top-p: 0.95
  • max new tokens: 131072

For multi-turn agentic tasks (ฯ„ยฒ-Bench and Terminal Bench 2), please turn on Preserved Thinking mode.

Terminal Bench, SWE Bench Verified

  • temperature: 0.7
  • top-p: 1.0
  • max new tokens: 16384

ฯ„^2-Bench

  • Temperature: 0
  • Max new tokens: 16384

For ฯ„^2-Bench evaluation, we added an additional prompt to the Retail and Telecom user interaction to avoid failure modes caused by users ending the interaction incorrectly. For the Airline domain, we applied the domain fixes as proposed in the Claude Opus 4.5 release report.

Serve GLM-4.7-Flash Locally

For local deployment, GLM-4.7-Flash supports inference frameworks including vLLM and SGLang. Comprehensive deployment instructions are available in the official Github repository.

vLLM and SGLang only support GLM-4.7-Flash on their main branches.

vLLM

  • using pip (must use pypi.org as the index url):
pip install -U vllm --pre --index-url https://pypi.org/simple --extra-index-url https://wheels.vllm.ai/nightly
pip install git+https://github.com/huggingface/transformers.git

SGLang

  • Install the supported versions of SGLang and Transformers (using uv is recommended):
uv pip install sglang==0.3.2.dev9039+pr-17247.g90c446848 --extra-index-url https://sgl-project.github.io/whl/pr/
uv pip install git+https://github.com/huggingface/transformers.git@76732b4e7120808ff989edbd16401f61fa6a0afa

transformers

using with transformers as

pip install git+https://github.com/huggingface/transformers.git

and then run:

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_PATH = "zai-org/GLM-4.7-Flash"
messages = [{"role": "user", "content": "hello"}]
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_dict=True,
    return_tensors="pt",
)
model = AutoModelForCausalLM.from_pretrained(
    pretrained_model_name_or_path=MODEL_PATH,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
inputs = inputs.to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=128, do_sample=False)
output_text = tokenizer.decode(generated_ids[0][inputs.input_ids.shape[1]:])
print(output_text)

vLLM

vllm serve zai-org/GLM-4.7-Flash \
     --tensor-parallel-size 4 \
     --speculative-config.method mtp \
     --speculative-config.num_speculative_tokens 1 \
     --tool-call-parser glm47 \
     --reasoning-parser glm45 \
     --enable-auto-tool-choice \
     --served-model-name glm-4.7-flash

SGLang

python3 -m sglang.launch_server \
  --model-path zai-org/GLM-4.7-Flash \
  --tp-size 4 \
  --tool-call-parser glm47  \
  --reasoning-parser glm45 \
  --speculative-algorithm EAGLE \
  --speculative-num-steps 3 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 4 \
  --mem-fraction-static 0.8 \
  --served-model-name glm-4.7-flash \
  --host 0.0.0.0 \
  --port 8000
  • For Blackwell GPUs, include --attention-backend triton --speculative-draft-attention-backend triton in your SGLang launch command.

Citation

If you find our work useful in your research, please consider citing the following paper:

@misc{5team2025glm45agenticreasoningcoding,
      title={GLM-4.5: Agentic, Reasoning, and Coding (ARC) Foundation Models}, 
      author={GLM Team and Aohan Zeng and Xin Lv and Qinkai Zheng and Zhenyu Hou and Bin Chen and Chengxing Xie and Cunxiang Wang and Da Yin and Hao Zeng and Jiajie Zhang and Kedong Wang and Lucen Zhong and Mingdao Liu and Rui Lu and Shulin Cao and Xiaohan Zhang and Xuancheng Huang and Yao Wei and Yean Cheng and Yifan An and Yilin Niu and Yuanhao Wen and Yushi Bai and Zhengxiao Du and Zihan Wang and Zilin Zhu and Bohan Zhang and Bosi Wen and Bowen Wu and Bowen Xu and Can Huang and Casey Zhao and Changpeng Cai and Chao Yu and Chen Li and Chendi Ge and Chenghua Huang and Chenhui Zhang and Chenxi Xu and Chenzheng Zhu and Chuang Li and Congfeng Yin and Daoyan Lin and Dayong Yang and Dazhi Jiang and Ding Ai and Erle Zhu and Fei Wang and Gengzheng Pan and Guo Wang and Hailong Sun and Haitao Li and Haiyang Li and Haiyi Hu and Hanyu Zhang and Hao Peng and Hao Tai and Haoke Zhang and Haoran Wang and Haoyu Yang and He Liu and He Zhao and Hongwei Liu and Hongxi Yan and Huan Liu and Huilong Chen and Ji Li and Jiajing Zhao and Jiamin Ren and Jian Jiao and Jiani Zhao and Jianyang Yan and Jiaqi Wang and Jiayi Gui and Jiayue Zhao and Jie Liu and Jijie Li and Jing Li and Jing Lu and Jingsen Wang and Jingwei Yuan and Jingxuan Li and Jingzhao Du and Jinhua Du and Jinxin Liu and Junkai Zhi and Junli Gao and Ke Wang and Lekang Yang and Liang Xu and Lin Fan and Lindong Wu and Lintao Ding and Lu Wang and Man Zhang and Minghao Li and Minghuan Xu and Mingming Zhao and Mingshu Zhai and Pengfan Du and Qian Dong and Shangde Lei and Shangqing Tu and Shangtong Yang and Shaoyou Lu and Shijie Li and Shuang Li and Shuang-Li and Shuxun Yang and Sibo Yi and Tianshu Yu and Wei Tian and Weihan Wang and Wenbo Yu and Weng Lam Tam and Wenjie Liang and Wentao Liu and Xiao Wang and Xiaohan Jia and Xiaotao Gu and Xiaoying Ling and Xin Wang and Xing Fan and Xingru Pan and Xinyuan Zhang and Xinze Zhang and Xiuqing Fu and Xunkai Zhang and Yabo Xu and Yandong Wu and Yida Lu and Yidong Wang and Yilin Zhou and Yiming Pan and Ying Zhang and Yingli Wang and Yingru Li and Yinpei Su and Yipeng Geng and Yitong Zhu and Yongkun Yang and Yuhang Li and Yuhao Wu and Yujiang Li and Yunan Liu and Yunqing Wang and Yuntao Li and Yuxuan Zhang and Zezhen Liu and Zhen Yang and Zhengda Zhou and Zhongpei Qiao and Zhuoer Feng and Zhuorui Liu and Zichen Zhang and Zihan Wang and Zijun Yao and Zikang Wang and Ziqiang Liu and Ziwei Chai and Zixuan Li and Zuodong Zhao and Wenguang Chen and Jidong Zhai and Bin Xu and Minlie Huang and Hongning Wang and Juanzi Li and Yuxiao Dong and Jie Tang},
      year={2025},
      eprint={2508.06471},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2508.06471}, 
}
Downloads last month

-

Downloads are not tracked for this model. How to track
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for moonbox-dev/GLM-4.7-Flash-MLX

Quantized
(116)
this model

Paper for moonbox-dev/GLM-4.7-Flash-MLX