Repository navigation
ggml : fix dimension and stride truncation in ggml_permute - #29227
Merged
Merged
Conversation
|
Hi @leejet, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
1 task done
LadislavSopko
pushed a commit
to 0ics-srls/llama.cpp
that referenced
this pull request
Oct 5, 2026
nicheng251
added a commit
to nicheng251/bonsai-turboquant-llama.cpp
that referenced
this pull request
Oct 23, 2026
Port five small upstream fixes that apply to code this fork ships: - fattn-vec: sync the warp at the end of the VKQ loop (ggml-org#30573). The next iteration's KQ write reused the shared buffer while other lanes were still reading it. - cpy: the transposed fast path requires a contiguous destination (ggml-org#27663). It wrote to a non-contiguous dst as if it were dense. - llama-kv-cache: only upload k_rot when the tensor has a buffer (ggml-org#27967). An unquantized K cache has no k_rot buffer and context shift crashed. - ggml_permute: keep dims and strides 64-bit (ggml-org#29227). The int temporaries truncated large tensors. - convert: run contiguous conversions four elements per thread (ggml-org#29155). Verified: FLASH_ATTN_EXT turbo 25/25, 27B Bonsai PTQ1_0 model smoke with q8_0 K + turbo3 V (prefill 547 tok/s, decode 31.2 tok/s at 2K; 30.0 at 17.4K). The stock q8_0/q8_0 long-sweep crash is not caused by the WAR hazard: it still aborts after 361 cases with this fix.
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
Preserve tensor dimensions and byte strides in
ggml_permuteusingint64_tandsize_t, avoiding truncation throughint.Additional information
ggml_permute()copies tensor dimensions (int64_t) and byte strides (size_t) through temporaryintarrays. Values exceedingINT32_MAXare truncated before being assigned back to the output tensor.For example, an F32 tensor shaped
[1536, 2048, 288, 1]has:This exceeds
INT32_MAX(2,147,483,647). On the affected platform, conversion tointproduces-671088640. Converting that negative value back to 64-bitsize_tproduces an enormous, invalid stride.Requirements