Experimental global target bits‑per‑weight quantization of zai-org/GLM-4.6V-Flash
Using non-standard (forked) LLaMA C++ release b7540 for quantization.
Original model: zai-org/GLM-4.6V-Flash
From the original model creators:
This model is part of the GLM-V family of models, introduced in the paper GLM-4.1V-Thinking and GLM-4.5V: Towards Versatile Multimodal Reasoning with Scalable Reinforcement Learning.
- GLM-4.6V Blog: https://z.ai/blog/glm-4.6v
- Paper: https://huggingface.co/papers/2507.01006
- GitHub Repository: https://github.com/zai-org/GLM-V
- Online Demo: https://chat.z.ai/
- API Access: Z.ai Open Platform
- Desktop Assistant App: https://huggingface.co/spaces/zai-org/GLM-4.5V-Demo-App
Introduction
GLM-4.6V series model includes two versions: GLM-4.6V (106B), a foundation model designed for cloud and high-performance cluster scenarios, and GLM-4.6V-Flash (9B), a lightweight model optimized for local deployment and low-latency applications. GLM-4.6V scales its context window to 128k tokens in training, and achieves SoTA performance in visual understanding among models of similar parameter scales. Crucially, we integrate native Function Calling capabilities for the first time. This effectively bridges the gap between "visual perception" and "executable action" providing a unified technical foundation for multimodal agents in real-world business scenarios.
Beyond achieves SoTA performance across major multimodal benchmarks at comparable model scales. GLM-4.6V introduces several key features:
Native Multimodal Function Calling Enables native vision-driven tool use. Images, screenshots, and document pages can be passed directly as tool inputs without text conversion, while visual outputs (charts, search images, rendered pages) are interpreted and integrated into the reasoning chain. This closes the loop from perception to understanding to execution.
Interleaved Image-Text Content Generation Supports high-quality mixed media creation from complex multimodal inputs. GLM-4.6V takes a multimodal context—spanning documents, user inputs, and tool-retrieved images—and synthesizes coherent, interleaved image-text content tailored to the task. During generation it can actively call search and retrieval tools to gather and curate additional text and visuals, producing rich, visually grounded content.
Multimodal Document Understanding GLM-4.6V can process up to 128K tokens of multi-document or long-document input, directly interpreting richly formatted pages as images. It understands text, layout, charts, tables, and figures jointly, enabling accurate comprehension of complex, image-heavy documents without requiring prior conversion to plain text.
Frontend Replication & Visual Editing Reconstructs pixel-accurate HTML/CSS from UI screenshots and supports natural-language-driven edits. It detects layout, components, and styles visually, generates clean code, and applies iterative visual modifications through simple user instructions.
⚠️ PLEASE READ THIS BEFORE USING THESE EXPERIMENTAL VERSIONS! ⚠️
An area of personal interest is finding ways to optimize the inference performance of LLMs when deployed in resource-constrained environments like commodity hardware, desktops, laptops, mobiles, edge devices, etc. There are many approaches to accomplish this, including architecture simplification and knowledge distillation, but my focus has been primarily on quantization and pruning.
The method to produce these experimental versions involves using a custom version of llama-imatrix to generate an imatrix including the mean activations, and a custom version of llama-quantize, which computes a per-tensor weighted mean squared quantization error and a bias/projection term (if the imatrix includes activations), to automatically select the lowest error quantization recipe that achieves a global target bits‑per‑weight (bpw). More details on the implementation and test results here
There are two pull requests (#14891 & #15550) to merge these changes back into the core llama.cpp project. This may or may not ever happen so, until then, the modified versions will be available on GitHub.
For testing and comparison, I use models produced by Bartowski (see credits below) and Unsloth (Daniel and Michael Han do some really interesting stuff!) but when they don't provide versions of the required model, tests and comparisons are against standard quantization obtained by simply running llama-quantize with no further optimizations.
All experimental versions were generated using an appropriate imatrix created from datasets available at eaddario/imatrix-calibration. In llama.cpp, an imatrix is a calibration file derived from running representative text through the model and collecting activation statistics. It is used to weight quantization error so that error in more “important” directions (as estimated from activations) is penalized more heavily.
The process to generate these models is roughly as follows:
- Convert the original model's safetensors to GGUF F16*
- Estimate the Perplexity score for the F16 model (baseline) using the wikitext-2-raw-v1 dataset, and save the logits
- Generate an imatrix from the most appropriate calibration dataset
- Quantize the baseline model targeting a bpw average, allocating more bits to tensors estimated to matter more (e.g.
llama-quantize --target-bpw 4.5678 --keep-bpw-state --imatrix imatrix.gguf baseline-model-F16.gguf 12) - Quantize the baseline model targeting a bpw average, treating each tensor equally instead of prioritizing some (e.g.
llama-quantize --target-bpw 4.5678 --no-importance --keep-bpw-state --imatrix imatrix.gguf baseline-model-F16.gguf 12) - Calculate Perplexity, KL Divergence, ARC (Easy+Challenge), HellaSwag, MMLU, Truthful QA and WinoGrande scores for each quantized model
- Keep version with the best 𝜌PPL scores (i.e. highest
Cor(ln(PPL(Q)), ln(PPL(base)))) - Repeat until all desired quants are created
*BF16 would be preferred, but F16 performs better on Apple's GPUs
Advantages and disadvantages of the global target bits‑per‑weight quantization process
Advantages
Target arbitrary size models
- When specifying
--target-bpw 4.5678for instance, the algorithm will produce a model (nearly) exactly of that size, which is very useful for maximizing VRAM usage. In a system with 24GB VRAM and a 70B model, standard quants might produce a 16.8GB file (too small, quality left on table) or a 24.1GB file (won't fit). This approach can generate a 23.85GB file to utilize the hardware fully.
- When specifying
Data-driven mixed precision often can improve quality at fixed size
Instead of using hardcoded heuristics (e.g. make
attn_vQ5_K for a 70B model), that may be sub‑optimal for a given architecture or size, the quantization mix is determined by the actual error sensitivity of the specific model's weights. This, in practice, often yields a better quality/size trade-off, especially in aggressive quantization scenarios (1.5 to 3.5 bpw), or for unusual architectures.Please note:
llama.cpp’s heuristics have been tuned across many models and are highly optimized; although the target bpw method produces better quality often (>75% based on tests with 130 models from 11 different families), it can also lose in surprising cases.
Allows better like-for-like comparisons between models and families
Standard
llama.cppquantization uses hardcoded rules like: "use Q4_K_M, except bump some tensors up/down, except fall back if incompatible, except keep some tensors unquantized..." and for that reason, two different models quantized with the same Q4_K_M type can end up with very different bpw (e.g. 4.75 and 4.30).All things being equal, the performance of a model is usually proportional to its overall bpw size; models with a higher bpw tend to perform better than lower bpw models. Since model A has simply been given more bits, it will typically perform better (lower perplexity, better eval scores, etc.) even if the underlying quantization method is identical. That makes comparing the performance not a controlled experiment, because the comparison is between models with different effective compression ratios.
--target-bpwtries to address that by making the experiment more controlled: each model gets quantized to land on (approximately) the same global byte budget, so that the models' performance differences are more attributable to architecture/training differences, quantization error behaviour at the same compression ratio, optimizer’s allocation decisions, etc.
Disadvantages
Quantization process is significantly slower than standard
This approach can take 5x-10x longer as it quantizes a sample of most tensors into 15 different formats, dequantizes them back to floats, computes error diffs, and selects the best size/error option that fits the global bpw budget.
However, the
--keep-bpw-stateoption will save the above-mentioned computations to disk so that future quantizations, in the permissible bpw range for the same model, can be generated at normal speed. It also allows to interrupt the computation process and resume it at a later time.
The optimization target is only a proxy for the model's performance quality
The process minimizes a per-tensor estimated error computed from sampled rows, not actual perplexity or divergence of output distributions (a future version may address this). Since errors interact nonlinearly across layers, there are no guarantees it will select the best possible quantization recipe subject to the bpw size constraint.
Furthermore, the process can operate in two modes: giving priority to important tensors (default) or treating each tensor equally (setting the
--no-importanceoption). To my knowledge, there is no computationally feasible way to determine ahead of time which modality will yield better results, and two runs per model may be needed to obtain the best quality, but the default mode usually wins.
An imatrix with activations data is required for best results
- Activation data is required to compute the bias factor (i.e. the systematic error projected onto activation directions). If the imatrix file does not contain activation data, the quantization recipe will likely be sub-optimal.
Models
Bits per weight, size, perplexity and KL Divergence scores
| Model | BPW | Size (GB) | μPPL | 𝜌PPL | μKLD | Same Top-P |
|---|---|---|---|---|---|---|
| GLM-4.6V-Flash-F16 | 16.0014 | 18.9 | 7.526979 ±0.050699 | 100% | N/A | N/A |
| GLM-4.6V-Flash-IQ3_XXS | 3.0000 | 3.5 | 9.814848 ±0.066418 | 93.21% | 0.324350 ±0.001302 | 74.687 ±0.114 |
| GLM-4.6V-Flash-Q2_K | 2.5000 | 3.0 | 17.071584 ±0.123787 | 83.05% | 0.918796 ±0.002640 | 59.094 ±0.129 |
| GLM-4.6V-Flash-Q3_K_L | 3.7500 | 4.4 | 8.003726 ±0.053400 | 98.43% | 0.080728 ±0.000372 | 86.600 ±0.090 |
| GLM-4.6V-Flash-Q3_K_S | 3.2500 | 3.8 | 8.787968 ±0.060508 | 96.06% | 0.184846 ±0.000842 | 80.580 ±0.104 |
| GLM-4.6V-Flash-Q3_K | 3.5000 | 4.1 | 8.313340 ±0.055904 | 97.51% | 0.123896 ±0.000575 | 83.930 ±0.097 |
| GLM-4.6V-Flash-Q4_K_S | 4.2500 | 5.0 | 7.684349 ±0.051940 | 99.36% | 0.030473 ±0.000174 | 91.818 ±0.072 |
| GLM-4.6V-Flash-Q4_K | 4.5000 | 5.3 | 7.651276 ±0.051754 | 99.55% | 0.021328 ±0.000134 | 93.371 ±0.065 |
| GLM-4.6V-Flash-Q4_K_M-bartowski | 5.2400 | 6.2 | 7.623492 ±0.051562 | 99.70% | 0.013882 ±0.000093 | 94.413 ±0.060 |
| GLM-4.6V-Flash-Q4_K_M-unsloth | 5.2400 | 6.2 | 7.633401 ±0.051669 | 99.70% | 0.013953 ±0.000095 | 94.428 ±0.060 |
| GLM-4.6V-Flash-Q4_K_M-bpw | 5.2400 | 6.2 | 7.587755 ±0.051251 | 99.76% | 0.010960 ±0.000076 | 95.083 ±0.057 |
| GLM-4.6V-Flash-Q5_K_S | 5.2500 | 6.2 | 7.590681 ±0.051290 | 99.76% | 0.010859 ±0.000074 | 95.041 ±0.057 |
| GLM-4.6V-Flash-Q5_K | 5.4999 | 6.5 | 7.575238 ±0.051217 | 99.83% | 0.007906 ±0.000057 | 95.709 ±0.053 |
| GLM-4.6V-Flash-Q6_K | 6.5000 | 7.7 | 7.549683 ±0.050962 | 99.93% | 0.002867 ±0.000022 | 97.458 ±0.041 |
| GLM-4.6V-Flash-Q8_0 | 8.4999 | 10.0 | 7.528825 ±0.050761 | 99.98% | 0.000206 ±0.000001 | 99.251 ±0.023 |
ARC, HellaSwag, MMLU, Truthful QA and WinoGrande scores
Scores generated using llama-perplexity with 750 tasks per test, and a context size of 768 tokens.
For the test data used in the generation of these scores, follow the appropriate links: HellaSwag, ARC, MMLU, Truthful QA and WinoGrande
| Model | ARC | HellaSwag | MMLU | Truthful QA | WinoGrande | Avg Score |
|---|---|---|---|---|---|---|
| GLM-4.6V-Flash-IQ3_XXS | 61.8667 | 73.0666 | 36.6667 | 26.4000 | 71.3333 | 53.87 |
| GLM-4.6V-Flash-Q2_K | 56.0000 | 67.0666 | 34.9333 | 26.9333 | 63.6000 | 49.71 |
| GLM-4.6V-Flash-Q3_K_L | 63.2000 | 78.2666 | 37.6000 | 29.8667 | 72.6667 | 56.32 |
| GLM-4.6V-Flash-Q3_K_S | 64.2667 | 75.3333 | 36.5333 | 29.3333 | 70.1333 | 55.12 |
| GLM-4.6V-Flash-Q3_K | 62.4000 | 76.8000 | 36.9333 | 30.5333 | 71.7333 | 55.68 |
| GLM-4.6V-Flash-Q4_K_S | 62.5333 | 78.2666 | 38.2667 | 30.6667 | 72.6667 | 56.48 |
| GLM-4.6V-Flash-Q4_K | 62.4000 | 77.8666 | 37.7333 | 31.8667 | 72.6667 | 56.51 |
| GLM-4.6V-Flash-Q4_K_M-bartowski | 63.4667 | 78.0000 | 38.5333 | 30.4000 | 72.0000 | 56.48 |
| GLM-4.6V-Flash-Q4_K_M-unsloth | 63.3333 | 78.1333 | 38.4000 | 30.1333 | 72.2667 | 56.45 |
| GLM-4.6V-Flash-Q4_K_M-bpw | 63.2000 | 78.6666 | 38.2667 | 30.2667 | 73.6000 | 56.80 |
| GLM-4.6V-Flash-Q5_K_S | 62.8000 | 78.8000 | 38.2667 | 30.0000 | 73.3333 | 56.64 |
| GLM-4.6V-Flash-Q5_K | 62.6667 | 78.4000 | 38.1333 | 30.8000 | 73.8667 | 56.77 |
| GLM-4.6V-Flash-Q6_K | 62.8000 | 78.8000 | 38.6667 | 30.2667 | 73.6000 | 56.83 |
| GLM-4.6V-Flash-Q8_0 | 63.7333 | 79.0666 | 38.6667 | 30.1333 | 73.2000 | 56.96 |
Tokens per second benchmarks
Scores generated using llama-bench. Standard (llama-quantize with no optimization) Q4_K_M quantization included for comparison.
| model | size | params | backend | threads | test | t/s |
|---|---|---|---|---|---|---|
| GLM-4.6V-Flash-Q4_K_M-bpw | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp512 | 738.12 ±0.92 |
| GLM-4.6V-Flash-Q4_K_M-bpw | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | tg128 | 54.67 ±0.33 |
| GLM-4.6V-Flash-Q4_K_M-bpw | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp1024+tg1024 | 87.96 ±0.75 |
| GLM-4.6V-Flash-Q4_K_M-bartowski | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp512 | 745.17 ±7.55 |
| GLM-4.6V-Flash-Q4_K_M-bartowski | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | tg128 | 57.92 ±0.23 |
| GLM-4.6V-Flash-Q4_K_M-bartowski | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp1024+tg1024 | 92.82 ±0.47 |
| GLM-4.6V-Flash-Q4_K_M-unsloth | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp512 | 747.19 ±6.77 |
| GLM-4.6V-Flash-Q4_K_M-unsloth | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | tg128 | 57.79 ±0.22 |
| GLM-4.6V-Flash-Q4_K_M-unsloth | 5.73 GiB | 9.40 B | Metal,BLAS | 12 | pp1024+tg1024 | 93.57 ±0.40 |
Metrics used
Perplexity: one of the key metrics used in NLP evaluation. It measures the quality of a language model by evaluating how well it predicts the next token given a particular sequence of words. A PPL of 1 indicates an exact match between predicted and actual, whereas values greater than one indicate a degree of "surprise" the generated token differs from the expected.
Kullback–Leibler (KL) Divergence: a statistical measure of how much a probability distribution differs from another. When quantizing models (or altering the original tensors in any way for that matter), the closest we can preserve the weights' probability distribution to the original model the better, thus the closest to 0 the better.
AI2 Reasoning Challenge (ARC): a benchmark to evaluate the ability of AI models to answer complex science questions that require logical reasoning beyond pattern matching.
HellaSwag: the Harder Endings, Longer contexts, and Low-shot Activities for Situations With Adversarial Generations (bit of a mouthful!) is a benchmark designed to test commonsense natural language inference. It requires the model to predict the most likely ending of a sentence.
MMLU: the Massive Multitask Language Understanding evaluates LLMs’ general knowledge and problem-solving abilities across 57 subjects, including elementary mathematics, US history, computer science, and law.
Truthful QA: evaluates how well LLMs generate truthful responses to questions. It identifies whether AI models can avoid generating false or misleading information, particularly in areas where human knowledge is prone to misconceptions.
Winogrande: based on the Winograd Schema Challenge, is a natural language understanding task requiring models to resolve ambiguities in sentences involving pronoun references.
Credits
LLaMa C++ has a large and vibrant community of contributors (~1,200 last time I checked) that actively maintain and extend its functionality, adding new models and architectures almost as fast as they appear. Considering the breakneck speed at which the AI/ML field is advancing, this alone is a remarkable feat!
While I'm grateful to all contributors, I want to recognise three in particular:
- Colin Kealty, for the many contributions and for being one of the best sources of high quality quantized models available on Hugging Face
- Georgi Gerganov for his amazing work with llama.cpp and the ggml/gguf libraries
- Iwan Kawrakow for being one of the key authors behind the many quantization algorithms and the imatrix functionality.
- Downloads last month
- 520
Model tree for eaddario/GLM-4.6V-Flash-GGUF
Base model
zai-org/GLM-4.6V-Flash