Repository navigation
llama : build the k-pool selection in the causal mask layout - #30480
Merged
Merged
Conversation
- the glm5-next indexer folded the causal mask in through a [n_kv, n_tokens] view: one reshape of the mask ahead of the add, and one of the result ahead of every layer reading the selection, including the shared-indexer layers - build the selection directly in the mask layout, as qwen4exp already does, and drop the now-degenerate reshape in its attention as well - assert the selection width matches the input it is taken from Assisted-by: pi:llama.cpp/Qwen3.8-Flash-Next
ggerganov
commented
Oct 13, 2026
ggerganov
marked this pull request as ready for review
October 13, 2026 21:22
am17an
approved these changes
Oct 14, 2026
3 of 5 tasks
danielhanchen
added a commit
to unslothai/llama.cpp
that referenced
this pull request
Oct 14, 2026
… and #264 review fixes
edwardyoon
pushed a commit
to edwardyoon/focus-llama
that referenced
this pull request
Oct 24, 2026
…in the causal mask layout
auRose94
pushed a commit
to auRose94/llama.cpp
that referenced
this pull request
Oct 28, 2026
…g#30480) * llama : build the k-pool selection in the causal mask layout - the glm5-next indexer folded the causal mask in through a [n_kv, n_tokens] view: one reshape of the mask ahead of the add, and one of the result ahead of every layer reading the selection, including the shared-indexer layers - build the selection directly in the mask layout, as qwen4exp already does, and drop the now-degenerate reshape in its attention as well - assert the selection width matches the input it is taken from Assisted-by: pi:llama.cpp/Qwen3.8-Flash-Next * cont : remove comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The glm5-next k-pool indexer folds the causal mask into the selection through a
[n_kv, n_tokens]view. That puts a reshape of the mask in front of theadd, and a second reshape of the result in front of every layer that reads the selection - including the shared-indexer layers that reuse it.build_qsa_selin qwen4exp already builds the selection directly in the causal mask layout (#29751). This does the same inbuild_kpool_select, passes the selection straight tobuild_attn_mhain both models (dropping the now-degenerate reshape inbuild_attn_qsa), and asserts that the selection width matches the input it is taken from.No numerical change - the two layouts are byte-identical (
ggml_view_4dkeepsnb[0]as the element size, so the oldview_2dplus the caller-sidereshape_4dproduced the same strides), only the two reshape nodes per indexer layer go away.Requirements