llama : fix KV shift for qwen2vl - #13870
Merged
Merged
Conversation
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
phuongncn
pushed a commit
to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4
that referenced
this pull request
Apr 28, 2026
* server: add support for vision model webui: add support for vision model * server : remove hack for extra parallel slot#10187 * llama : fix KV shift for qwen2vl ggml-org#13870 * add no-context-shift parameter --------- Co-authored-by: firecoperana <firecoperana>
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
Anyesh
added a commit
to Anyesh/llama.cpp
that referenced
this pull request
May 20, 2026
Two extensions land the kv_block save/load across the modern model spectrum: 1. llama_get_kv_cache (in llama-context.cpp) now unwraps llama_memory_hybrid and llama_memory_hybrid_iswa via their get_mem_attn() accessor, returning the attention sub-cache. Recurrent layers in hybrid models carry a fixed- size state that does not need eviction or recovery, so block save/load operating on the attention component alone is sufficient. 2. The seq_add() and get_can_shift() guards for n_pos_per_embd > 1 were outdated. build_rope_shift already has an mrope workaround (line 1739, ref ggml-org#13870) that treats the temporal shift as a NeoX-style whole-vector rotation. Cells store a single temporal pos plus a separate ext payload for spatial axes; shifting only the temporal pos is semantically correct. seq_div is left guarded because EVOKE does not use it. Verified end-to-end with kv_restore on chihiro: Qwen2.5-7B-Instruct pure attention + std RoPE PASS Qwen3.5-9B hybrid Mamba/Attention + mrope PASS Qwen3.6-35B-A3B MoE + mrope + thinking PASS Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
phibya
pushed a commit
to ziee-ai/llama.cpp
that referenced
this pull request
May 29, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
fewtarius
pushed a commit
to fewtarius/CachyLLama
that referenced
this pull request
May 30, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
AlexiAlp
pushed a commit
to minghaop/llama.cpp
that referenced
this pull request
Jun 2, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
JEF1056
pushed a commit
to JEF1056/llama-cpp-turboquant
that referenced
this pull request
Jun 8, 2026
…3-VL) - kv-cache: allow get_can_shift() to return true for LLAMA_ROPE_TYPE_MROPE and LLAMA_ROPE_TYPE_IMROPE; build_rope_shift() NEOX-mode workaround already handles whole-vector K rotation for text tokens (ref PR ggml-org#13870) - server: remove blanket n_cache_reuse=0 disable for multimodal models; llama_memory_can_shift() gates shifting without a separate has_mtmd check - server: remove !has_mtmd gate from can_cache_reuse and dead GGML_ASSERT/GGML_ABORT guards; image cells are skipped in the loop below - server: skip LLAMA_TOKEN_NULL tokens in the chunk-shifting loop so spatial M-RoPE positions are never relocated; add NULL guards to the inner match loop so text runs never span across media chunks - server: use pos_next() to convert token indices to actual KV positions for common_context_seq_rm/add; M-RoPE images advance the position counter by max(nx,ny) not n_tokens so raw indices give wrong ranges after images Magic applied with Wibey CLI (https://wibey.walmart.com/cli) Co-Authored-By: Wibey CLI <genai-coding-assistants@walmart.com>
Anyesh
added a commit
to Anyesh/llama.cpp
that referenced
this pull request
Jun 29, 2026
Two extensions land the kv_block save/load across the modern model spectrum: 1. llama_get_kv_cache (in llama-context.cpp) now unwraps llama_memory_hybrid and llama_memory_hybrid_iswa via their get_mem_attn() accessor, returning the attention sub-cache. Recurrent layers in hybrid models carry a fixed- size state that does not need eviction or recovery, so block save/load operating on the attention component alone is sufficient. 2. The seq_add() and get_can_shift() guards for n_pos_per_embd > 1 were outdated. build_rope_shift already has an mrope workaround (line 1739, ref ggml-org#13870) that treats the temporal shift as a NeoX-style whole-vector rotation. Cells store a single temporal pos plus a separate ext payload for spatial axes; shifting only the temporal pos is semantically correct. seq_div is left guarded because EVOKE does not use it. Verified end-to-end with kv_restore on chihiro: Qwen2.5-7B-Instruct pure attention + std RoPE PASS Qwen3.5-9B hybrid Mamba/Attention + mrope PASS Qwen3.6-35B-A3B MoE + mrope + thinking PASS Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> (cherry picked from commit a29599f)
fukuro-kun
pushed a commit
to fukuro-kun/fukuro-llama-cpp-turboquant
that referenced
this pull request
Jul 5, 2026
* llama : fix KV shift for qwen2vl * add ref to the PR
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.
Fix #13865
Provided a model with 3 mrope sections, a rotated vector looks like this:
[time, time+x, time+y]This works with the assumption that mrope with
x == y == 0is identical to doing a neox rope with theta =+timeFor example, when we want to shift the
timetotime-1, that mean we shift from[time, time+x, time+y]to[time-1, time-1+x, time-1+y]; We can simply apply neox rope with theta =-1to archive the same effect