Skip to content

GLM DSA: reduce indexer cache size#2093

Merged
ikawrakow merged 1 commit into
mainfrom
ik/glm_dsa_reduce_indexer_cache
Jul 7, 2026
Merged

GLM DSA: reduce indexer cache size#2093
ikawrakow merged 1 commit into
mainfrom
ik/glm_dsa_reduce_indexer_cache

Conversation

@ikawrakow

Copy link
Copy Markdown
Owner

The GLM-5 indexer only operates in a subset of the model layers, the other layers reuse the indexer result from a preceding "full" layer. This is taken into account when preparing the compute graph, but not when allocating memory for the indexer cache.

This PR avoids the unnecessary cache allocation. For a context of 128k tokens and f16 indexer cache, cache size drops from 2.5 GiB to 672 MiB.

@ikawrakow
ikawrakow merged commit 05cba31 into main Jul 7, 2026
@ikawrakow ikawrakow mentioned this pull request Jul 7, 2026
ikawrakow added a commit that referenced this pull request Jul 7, 2026
@sayap

sayap commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This applies to GGUF from unsloth only right? If I understand correctly, they hacked the conversion to duplicate the indexer tensor to all layers, just so it can be loaded without ggml-org/llama.cpp#24770

With a proper GGUF, I don't notice any difference from this PR 😄

@ikawrakow

Copy link
Copy Markdown
Owner Author

This applies to GGUF from unsloth only right? If I understand correctly, they hacked the conversion to duplicate the indexer tensor to all layers, just so it can be loaded without ggml-org/llama.cpp#24770

With a proper GGUF, I don't notice any difference from this PR 😄

If the GGUF doesn't have the indexer tensors for a layer, no indexer cache was created in that layer even without this PR. So, yes, you will only see a difference with the llama.cpp-style "hacked" GGUFs that duplicate the indexer tensors in each layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants