ggml-openvino : fix 2D/3D view input shape inference - #303
Draft
mostafafaheem wants to merge 22 commits into
Draft
ggml-openvino : fix 2D/3D view input shape inference#303mostafafaheem wants to merge 22 commits into
mostafafaheem wants to merge 22 commits into
Conversation
Author
|
@cavusmustafa @wine99 @zhaixuejun1993 Interested to know what you think about this. Side note: I was tempted to do some more changes in this PR that I found already were done in #240. It would be nice if that PR was merged after rebasing and resolving conflicts. I'd be happy to take that on if you want. |
mostafafaheem
marked this pull request as draft
August 27, 2026 19:16
Author
|
Converted to draft until end-to-end execution on Gemma 4 MMProj (model where this issue was encoutered) is correct. |
Static shapes: - get_graph_input_shape() left the s_copy / s_copy-leaf inputs dynamic ([1,1,1,-1]) even in static mode, which propagated a dynamic slot dim through GET_ROWS into the conv/GDN state, the state reshapes and the GDN output. - With -np 1 the s_copy defrag remainder gathers zero rows; short-circuit that CPY to the untouched cache instead of emitting a degenerate Slice/Concat, and skip binding its zero-byte ggml tensor as an output (the dynamic path already did the latter, the static path wrote the full cache over a 0-byte buffer). Token-count independence: - In static mode the compiled model's token count is the prefill chunk size or 1, not the captured cgraph's. Offsets derived from the captured count were therefore wrong. Anchor the GDN state slice at the end of the packed [attn | state] output and drop the rs_src_begin runtime inputs, and make VIEWs over the GDN output / conv_input pass through so the consumer does the slicing. - CONT could not identify its token axis when the graph was captured with a single token (every trailing dim has the same stride and size 1) and baked the captured shape into the prefill model. Chunked prefill: - The last chunk is padded with fabricated tokens. Attention masks them, but the recurrent path folded them into cache_r/cache_s permanently. Add a chunk_valid_len runtime input, use it to zero g and beta for padded steps (making the recurrence an exact identity) and to end the conv snapshot window at the last valid token, and disable the recurrent-cache reset after the first chunk so earlier chunks are not wiped. - get_is_prefill() and the chunk loop bound read inp_pos->ne[0] directly, but IMROPE stacks 4 position planes, so every decode step was run through the padded prefill model and the loop ran extra out-of-bounds chunks. cache_rs_reset_idx/len now stay runtime Parameters in static mode, since can_reuse_statically() does not invalidate the cached model on ComputeParams changes. Add GGML_OPENVINO_FORCE_STATIC to exercise the static path on CPU.
Add GGML_OPENVINO_NPU_COMPILE_CONFIG to the backend's cached environment so callers can configure the NPU compiler without using the generic property escape hatch. When the value is non-empty, pass it to OpenVINO as NPU_COMPILATION_MODE_PARAMS. This enables settings such as optimization-level=3 for NPU compilation while preserving the existing behavior when the variable is unset and leaving CPU and GPU configuration unchanged. Document the variable, its NPU-only scope, and the optimization-level=3 example in the OpenVINO backend runtime configuration table.
wine99
force-pushed
the
dev_backend_openvino
branch
from
August 28, 2026 01:36
01d5a57 to
40d3fdd
Compare
mostafafaheem
force-pushed
the
unsqueeze_before_view
branch
from
August 28, 2026 16:19
7941508 to
e055c16
Compare
ravi9
force-pushed
the
dev_backend_openvino
branch
from
September 3, 2026 00:04
ec98377 to
fd9bc04
Compare
ravi9
force-pushed
the
dev_backend_openvino
branch
from
September 3, 2026 21:10
fd9bc04 to
33237ab
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
process_view_input_newutil. This PR introduces anUnsqueezeto 4D in order to avoid this issue.Additional information
Requirements
ifblock