Skip to content

Commit 7d5865a

Browse files
Patrick Hoffmannclaude
authored andcommitted
llama: accept either glm5next indexer kpool key name
The two competing GLM-5.3-Flash drafts write the same value under different GGUF keys: ggml-org#27752 uses attention.indexer.block_size, ggml-org#27754 uses attention.indexer.kpool. Semantics and the indexer_top_k % kpool == 0 constraint are identical, so read the block_size key first and fall back to kpool instead of aborting at "GLM5NEXT requires index_kpool" on a GGUF from the other converter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 735ef23 commit 7d5865a

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

gguf-py/gguf/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ class Indexer:
222222
KEY_LENGTH = "{arch}.attention.indexer.key_length"
223223
TOP_K = "{arch}.attention.indexer.top_k"
224224
BLOCK_SIZE = "{arch}.attention.indexer.block_size" # MSA
225+
KPOOL = "{arch}.attention.indexer.kpool" # glm5next alias (PR #27754)
225226
LOCAL_BLOCKS = "{arch}.attention.indexer.local_blocks" # MSA
226227
TYPES = "{arch}.attention.indexer.types"
227228

src/llama-arch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static const std::map<llm_kv, const char *> LLM_KV_NAMES = {
282282
{ LLM_KV_ATTENTION_INDEXER_KEY_LENGTH, "%s.attention.indexer.key_length" },
283283
{ LLM_KV_ATTENTION_INDEXER_TOP_K, "%s.attention.indexer.top_k" },
284284
{ LLM_KV_ATTENTION_INDEXER_BLOCK_SIZE, "%s.attention.indexer.block_size" },
285+
{ LLM_KV_ATTENTION_INDEXER_KPOOL, "%s.attention.indexer.kpool" },
285286
{ LLM_KV_ATTENTION_INDEXER_LOCAL_BLOCKS, "%s.attention.indexer.local_blocks" },
286287
{ LLM_KV_ATTENTION_INDEXER_TYPES, "%s.attention.indexer.types" },
287288
{ LLM_KV_ATTENTION_OUTPUT_GROUP_COUNT, "%s.attention.output_group_count" },

src/llama-arch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ enum llm_kv {
287287
LLM_KV_ATTENTION_INDEXER_KEY_LENGTH,
288288
LLM_KV_ATTENTION_INDEXER_TOP_K,
289289
LLM_KV_ATTENTION_INDEXER_BLOCK_SIZE,
290+
LLM_KV_ATTENTION_INDEXER_KPOOL,
290291
LLM_KV_ATTENTION_INDEXER_LOCAL_BLOCKS,
291292
LLM_KV_ATTENTION_INDEXER_TYPES,
292293
LLM_KV_ATTENTION_OUTPUT_GROUP_COUNT,

src/models/glm5next.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ void llama_model_glm5next::load_arch_hparams(llama_model_loader & ml) {
7373
ml.get_key(LLM_KV_ATTENTION_INDEXER_HEAD_COUNT, hparams.indexer_n_head, false);
7474
ml.get_key(LLM_KV_ATTENTION_INDEXER_KEY_LENGTH, hparams.indexer_head_size, false);
7575
ml.get_key(LLM_KV_ATTENTION_INDEXER_TOP_K, hparams.indexer_top_k, false);
76-
// index_kpool: tokens per compressed key, always_select_tail is implied (see build_dsa_top_k)
76+
// index_kpool: tokens per compressed key, always_select_tail is implied (see build_dsa_top_k).
77+
// Converters disagree on the key name for this value: upstream PR #27752 writes
78+
// `attention.indexer.block_size`, the competing PR #27754 writes `attention.indexer.kpool`.
79+
// The semantics and the `indexer_top_k % kpool == 0` constraint are identical, so accept
80+
// either rather than aborting on a GGUF produced by the other converter.
7781
ml.get_key(LLM_KV_ATTENTION_INDEXER_BLOCK_SIZE, hparams.indexer_block_size, false);
82+
if (hparams.indexer_block_size == 0) {
83+
ml.get_key(LLM_KV_ATTENTION_INDEXER_KPOOL, hparams.indexer_block_size, false);
84+
}
7885

7986
if (hparams.indexer_head_size > 0) {
8087
GGML_ASSERT(hparams.indexer_n_head > 0);

0 commit comments

Comments
 (0)