--- quantized_by: AesSedai pipeline_tag: text-generation base_model: zai-org/GLM-4.5 license: mit base_model_relation: quantized --- This repository contains some custom quants of GLM-4.5 that focus on a couple of different schemas compared to the usual quantization schemas. The idea being that given the huge size of the FFN tensors compared to the rest of the tensors in the model, it should be possible to achieve a better quality while keeping the overall size of the entire model smaller compared to a similar naive quantization. The following charts showcase a very wide variety of GLM-4.5 quants that were tested for KL Divergence using the reference logits and corpus included in this repo: `GLM-4.5-KLD-8192-ref-logits-ed-combined-all-micro-Q8_0.bin` and `combined_all_micro.txt` A full CSV with the data is included as well in `glm-4.5-quantization-output.csv`. The naming convention is (inconsistently) as follows, generally: `[Default Type]-[FFN_UP]-[FFN_GATE]-[FFN_DOWN]`, eg: `Q6_K-IQ2_S-IQ2_S-IQ3_S`. This means: - Q6_K is the default type (attention, shared expert, etc.) - IQ2_S was used for the FFN_UP and FFN_GATE conditional expert tensors - IQ3_S was used for the FFN_DOWN conditional expert tensors Generally speaking, quants following the above convention tend to have a better KLD and PPL compared to quants from other providers. Visualized here are the Mean KLD and Mean PPL of the quants on the Pareto frontier (so, best for a given size). Full graphs are available in the `plots-glm-4.5-8192` folder. ![KLD vs File Size](plots-glm-4.5-8192/01_kld_vs_filesize-pareto.png "Chart showing KLD improving as BPW increases.") ![PPL vs File Size](plots-glm-4.5-8192/02_ppl_vs_filesize-pareto.png "Chart showing Perplexity improving as BPW increases.") Provided here are a few quants, separated into `llama.cpp` and `ik_llama.cpp` folders for convenience (though, `ik_llama.cpp` is capable of running the quants in `llama.cpp`, but the opposite is not true). ## `llama.cpp` imatrix Quantizations of zai-org/GLM-4.5 This quant collection can be run on `llama.cpp` or `kobold.cpp` like normal. ## Q6_K-IQ2_S-IQ2_S-IQ3_S: 128.18 GiB (3.07 BPW), Final estimate: PPL = 4.786993 ± 0.031213, KLD = 0.145117 ± 0.002232 ## GLM-4.5-Q6_K-Q2_K-Q2_K-Q3_K: 129.57 GiB (3.11 BPW), Final estimate: PPL = 4.700384 ± 0.030202, KLD = 0.164863 ± 0.002339 ## GLM-4.5-Q8_0-IQ3_XXS-IQ3_XXS-IQ3_S: 144.68 GiB (3.47 BPW), Final estimate: PPL = 4.729934 ± 0.030769, KLD = 0.116520 ± 0.002072 ## `ik_llama.cpp` imatrix Quantizations of zai-org/GLM-4.5 This quant collection **REQUIRES** [ik_llama.cpp](https://github.com/ikawrakow/ik_llama.cpp/) fork to support the ik's latest SOTA quants and optimizations! Do **not** download these big files and expect them to run on mainline vanilla llama.cpp, ollama, LM Studio, KoboldCpp, etc! *NOTE* `ik_llama.cpp` can also run your existing GGUFs from bartowski, unsloth, mradermacher, etc if you want to try it out before downloading my quants. Some of ik's new quants are supported with [Nexesenex/croco.cpp](https://github.com/Nexesenex/croco.cpp) fork of KoboldCPP with Windows builds for CUDA 12.9. Also check for [Windows builds by Thireus here.](https://github.com/Thireus/ik_llama.cpp/releases) which have been CUDA 12.8. See [Ubergarm's GLM-4.5 quants](https://huggingface.co/ubergarm/GLM-4.5-GGUF) for info on how to use the recipe or make your own quant. ## IQ2_KT: 109.269 GiB (2.619 BPW): Lost the results somewhere, oops.
👈 Recipe ```bash # 93 Repeating Layers [0-92] # Attention blk\..*\.attn_q.*=iq4_k blk\..*\.attn_k.*=iq6_k blk\..*\.attn_v.*=iq6_k blk\..*\.attn_output.*=iq5_ks # First 3 Dense Layers [0-2] blk\..*\.ffn_down\.weight=iq4_ks blk\..*\.ffn_(gate|up)\.weight=iq3_ks # Shared Expert Layers [3-92] blk\..*\.ffn_down_shexp\.weight=iq6_k blk\..*\.ffn_(gate|up)_shexp\.weight=iq6_k # Routed Experts Layers [3-92] blk\..*\.ffn_down_exps\.weight=iq3_kt blk\..*\.ffn_(gate|up)_exps\.weight=iq2_kt # NextN MTP Layer [92] blk\..*\.nextn\.embed_tokens\.weight=iq4_k blk\..*\.nextn\.shared_head_head\.weight=iq6_k blk\..*\.nextn\.eh_proj\.weight=iq6_k # Non-Repeating Layers token_embd\.weight=iq4_k output\.weight=iq6_k ```
## IQ4_KSS: 176.499 GiB (4.231 BPW): Lost the results somewhere, oops.
👈 Recipe ```bash # 93 Repeating Layers [0-92] # Attention blk\.(0|1|2)\.attn_q.*=q8_0 blk\.(0|1|2)\.attn_k.*=q8_0 blk\.(0|1|2)\.attn_v.*=q8_0 blk\.(0|1|2)\.attn_output.*=q8_0 blk\..*\.attn_q.*=iq6_k blk\..*\.attn_k.*=iq6_k blk\..*\.attn_v.*=iq6_k blk\..*\.attn_output.*=iq6_k # First 3 Dense Layers [0-2] blk\..*\.ffn_down\.weight=iq5_ks blk\..*\.ffn_(gate|up)\.weight=iq4_ks # Shared Expert Layers [3-92] blk\..*\.ffn_down_shexp\.weight=q8_0 blk\..*\.ffn_(gate|up)_shexp\.weight=q8_0 # Routed Experts Layers [3-92] blk\..*\.ffn_down_exps\.weight=iq4_ks blk\..*\.ffn_(gate|up)_exps\.weight=iq4_kss # NextN MTP Layer [92] blk\..*\.nextn\.embed_tokens\.weight=iq5_ks blk\..*\.nextn\.shared_head_head\.weight=iq5_ks blk\..*\.nextn\.eh_proj\.weight=q8_0 # Non-Repeating Layers token_embd\.weight=iq4_k output\.weight=iq6_k ```
## IQ4_KS-IQ4_KS-IQ5_KS: 200.326 GiB (4.802 BPW), Final estimate: PPL = 4.618597 ± 0.029981, KLD = 0.072590 ± 0.001816
👈 Recipe ```bash Default quant level @ Q8_0 # Shared Expert Layers [3-92] blk\..*\.ffn_down_shexp\.weight=q8_0 blk\..*\.ffn_(gate|up)_shexp\.weight=q8_0 # Routed Experts Layers [3-92] blk\..*\.ffn_up_exps\.weight=iq4_ks blk\..*\.ffn_gate_exps\.weight=iq4_ks blk\..*\.ffn_down_exps\.weight=iq5_ks ```
## IQ5_K: 204.948 GiB (4.913 BPW), Final estimate: PPL = 4.665419 ± 0.030393, KLD = 0.078092 ± 0.001891
👈 Recipe ```bash # 93 Repeating Layers [0-92] # Attention blk\.(0|1|2)\.attn_q.*=q8_0 blk\.(0|1|2)\.attn_k.*=q8_0 blk\.(0|1|2)\.attn_v.*=q8_0 blk\.(0|1|2)\.attn_output.*=q8_0 blk\..*\.attn_q.*=iq5_k blk\..*\.attn_k.*=iq5_k blk\..*\.attn_v.*=iq5_k blk\..*\.attn_output.*=iq5_k # First 3 Dense Layers [0-2] blk\..*\.ffn_down\.weight=q8_0 blk\..*\.ffn_(gate|up)\.weight=q8_0 # Shared Expert Layers [3-92] blk\..*\.ffn_down_shexp\.weight=q8_0 blk\..*\.ffn_(gate|up)_shexp\.weight=q8_0 # Routed Experts Layers [3-92] blk\..*\.ffn_down_exps\.weight=iq5_k blk\..*\.ffn_(gate|up)_exps\.weight=iq4_k # NextN MTP Layer [92] blk\..*\.nextn\.embed_tokens\.weight=iq5_k blk\..*\.nextn\.shared_head_head\.weight=iq5_k blk\..*\.nextn\.eh_proj\.weight=q8_0 # Non-Repeating Layers token_embd\.weight=q8_0 output\.weight=q8_0 ```