Instructions to use mlx-community/GLM-4.1V-9B-Thinking-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/GLM-4.1V-9B-Thinking-8bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("mlx-community/GLM-4.1V-9B-Thinking-8bit") config = load_config("mlx-community/GLM-4.1V-9B-Thinking-8bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
mlx-community/GLM-4.1V-9B-Thinking-8bit
zai-org/GLM-4.1V-9B-Thinking converted to MLX and quantized to 8-bit, for inference on Apple Silicon.
GLM-4.1V-9B-Thinking is a reasoning vision-language model that emits an explicit
<think> block before its answer. The vision path is preserved in this
conversion.
Existing MLX conversions of this model are 4-bit and 5-bit; this fills the 8-bit gap.
Quantization
| Requested bits | 8 |
| Group size | 64 |
| Mode | affine |
| Effective bits per weight | 9.15 |
| On-disk size | 11 GB |
| Shards | 3 |
Effective bits exceed the requested value because mlx-vlm quantizes only the
language model and leaves the vision tower in bf16 by design โ 181 vision
tensors, none of them quantized. The vision encoder is a small share of the
weights but disproportionately sensitive to quantization error.
language_model : 242 tensors quantized (8-bit, group size 64)
vision_tower : 181 tensors, bf16 <- unquantized
Fidelity vs the original weights
Measured against the bf16 source, tensor by tensor, over all 242 quantized tensors (9,399,435,264 parameters). No prompts or sampling โ a direct measurement of how much numerical information the quantization discarded, exact and hardware-independent.
| Metric | 8-bit |
|---|---|
| Relative L2 error | 0.73% |
| Cosine similarity | 0.999973 |
| Signal-to-quantization-noise | 42.68 dB |
| Worst single-element error | 0.005859 |
Highest-error tensors โ v_proj / k_proj and the LM head are the most
sensitive:
rel_l2=0.00829 snr= 41.63 dB language_model.lm_head
rel_l2=0.00815 snr= 41.77 dB language_model.model.layers.15.self_attn.k_proj
rel_l2=0.00811 snr= 41.82 dB language_model.model.layers.26.self_attn.v_proj
rel_l2=0.00776 snr= 42.20 dB language_model.model.layers.32.self_attn.v_proj
rel_l2=0.00774 snr= 42.22 dB language_model.model.layers.29.self_attn.v_proj
42.68 dB is the same figure measured for other 8-bit affine conversions in this series (e.g. MagenticBrain-8bit), which is what 8-bit at group size 64 should produce.
Throughput
M2 Pro / 32 GB, 64 generated tokens, greedy.
| Variant | Decode tok/s | Prompt tok/s | Peak RAM |
|---|---|---|---|
| 8-bit | 15.8 | 110.2 | 11.89 GB |
Numbers do not transfer across chips. Note this model emits a <think> block, so
end-to-end latency per answer is higher than the token rate alone suggests.
Why fidelity is reported at the weight level
Other conversions in this series report perplexity ratio, top-1 agreement and KL divergence against the bf16 source. Those were run for this model and are deliberately not reported, because the measurement turned out to be invalid here โ and that is worth stating rather than quietly omitting.
Teacher-forced on five plain-text passages, the numbers came out as perplexity ratio 3.99, top-1 agreement 0.568, KL 1.71 nats/token. Those would be alarming for an 8-bit quantization. But the same run also produced BLEU 83.92, chrF 87.67 and ROUGE-1 0.897 against bf16, and the sampled generations were byte-identical. Both cannot be true.
Breaking the aggregate down by passage explains it:
| Passage | Tokens | bf16 PPL |
|---|---|---|
| prose | 26 | 4.86 |
| Python code | 82 | 467.07 |
| legal | 33 | 16.96 |
| biology | 34 | 5.71 |
| meta | 24 | 10.92 |
Aggregate perplexity is exp(sum_nll / sum_tokens), so the code block โ 41% of
the tokens, at a perplexity of 467 for the unquantized source โ dominates
everything. The bf16 reference spans 96x across these passages. Where the
reference distribution is that flat, quantization noise flips the argmax easily,
so top-1 agreement and KL understate fidelity rather than measuring it.
The weight-level comparison above has no such dependency on prompt choice, so it is what this card reports. For a model of this class a meaningful behavioural benchmark would need multimodal reasoning inputs, not plain prose.
What was not measured
No standard benchmarks: no MMMU, MathVista, MMBench, or any reasoning eval. No judged quality. The vision path was verified to load and run, not scored on a dataset. Evaluate on your own tasks before relying on this in production.
Usage
pip install mlx-vlm
from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
model, processor = load("mlx-community/GLM-4.1V-9B-Thinking-8bit")
prompt = apply_chat_template(
processor, model.config,
"What is shown in this image? Reason step by step.",
num_images=1,
)
out = generate(model, processor, prompt, image=["image.png"], max_tokens=512)
print(out.text)
Give it room in max_tokens โ the model spends tokens inside <think> before
answering. Text-only works too: pass num_images=0 and omit image.
Note that stock mlx-lm loads the text path only; use mlx-vlm for image
input.
Credits
All credit for the model belongs to Zhipu AI / Tsinghua KEG (Z.ai). This is a format conversion and quantization; no training or fine-tuning was performed. Licensed MIT, as the original. See the original card for intended use and limitations.
- Downloads last month
- 70
8-bit