Repository navigation
Conversation
osabnis
force-pushed
the
ov-single-token-decoder-reuse
branch
from
November 28, 2026 23:37
b1ae567 to
554566f
Compare
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
GLM-4.7-Flash with
-fa offfails on GPU when a multi-token prompt follows a one-token decode. This occurs withllama-bench -d 400, where the warm-up performs a one-token decode before the 400-token depth prompt.The failure occurs because the decoder cache key does not include tensor shapes. Consequently, a decoder converted from the one-token graph is reused for the 400-token graph.
The dynamic dimensions in the converted model were derived from the one-token graph, where
Vcur = reshape_3d(kv_cmpr, 512, 1, n_tokens)cannot distinguish between dimensions 1 and 2. When the model is reused for the multi-token graph, this results in incompatible shapes during the K/V cache concatenation:This change ensures that a decoder converted from a one-token graph is not reused for graphs with multiple tokens.
Changes
GgmlOvDecoder::can_run_tokens()to check whether a converted decoder can run a graph with the requested number of tokens.can_run_tokens()alongsidehas_same_graph_io().Results
Tested with GLM-4.7-Flash Q4_K_M using:
a97d80a6aConcat ... Shape inference input shapes {[1,1,400,512],[1,400,1,64]}a97d80a6a+ this changea97d80a6a+ all 8 of our PRs, including L4 and this changeThe extra conversion happens only when the first graph has a single token. Perplexity and llama-cli start with the prompt, so they do not take this path.
Requirements