]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
model: add GLM 5.2 Indexer support (#25407)
authorPedro Cuenca <redacted>
Fri, 24 Jul 2026 18:55:56 +0000 (20:55 +0200)
committerGitHub <redacted>
Fri, 24 Jul 2026 18:55:56 +0000 (20:55 +0200)
commit88bfee1429a2dfacec65d1b0c0852eb327991865
treea2aecc6320be17e5d3b2fd8f7ea8542a707e1d09
parent95a923a64c7d493ed1cb347d3b55d039fa3b8097
model: add GLM 5.2 Indexer support (#25407)

* Start building graph - reuse deepseek32

* Enable kv cache and rotation for glm_dsa architecture

Just follow Deepseek 3.2 for now.

* Reuse prev_top_k for "shared" indexer layers

* GLM 5.2 uses LLAMA_ROPE_TYPE_NORM for the indexer.

This is transformers' `apply_rotary_pos_emb_interleave`

* Default indexer types to GLM pattern

Previous converted GGUFs like https://huggingface.co/unsloth/GLM-5.2-GGUF write indexer weights to _all_ layers, even if they are only required for "full" types. This PR relies on a new key "%s.attention.indexer.types"; if absent, it will use the default GLM 5.2 schedule as defined in https://huggingface.co/zai-org/GLM-5.2/blob/main/config.json#L26.

Note that conversion is not saving this key yet.

* Save indexer types to gguf, restore on load

* Use ggml_lightning_indexer when cparams.fused_lid

Co-authored-by: fairydreaming <redacted>
* GLM 5 and 5.1 use full indexers

Co-authored-by: fairydreaming <redacted>
* Fix indentation

* Ensure array is zero-filled

* Prefer explicit std::fill

* Assert prev_top_k exists for shared indexer

---------

Co-authored-by: fairydreaming <redacted>
12 files changed:
conversion/glm.py
gguf-py/gguf/constants.py
gguf-py/gguf/gguf_writer.py
src/llama-arch.cpp
src/llama-arch.h
src/llama-hparams.cpp
src/llama-hparams.h
src/llama-kv-cache.cpp
src/llama-model-saver.cpp
src/llama-model.cpp
src/models/glm-dsa.cpp
src/models/models.h