ggml: fix ggml_is_contiguous_n for ne == 1#20092
Merged
JohannesGaessler merged 1 commit intoggml-org:masterfrom Mar 4, 2026
Merged
ggml: fix ggml_is_contiguous_n for ne == 1#20092JohannesGaessler merged 1 commit intoggml-org:masterfrom
JohannesGaessler merged 1 commit intoggml-org:masterfrom
Conversation
ggerganov
approved these changes
Mar 4, 2026
Ethan-a2
pushed a commit
to Ethan-a2/llama.cpp
that referenced
this pull request
Mar 20, 2026
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.
While debugging a test failure for #19802 I found what I believe to be a bug in
ggml_is_contiguous_n. A test case using the new fused experts from #19139 fails on an assert likeGGML_ASSERT(ggml_is_contiguous_1(a)). This assertion failure happens specifically because the test case uses only a single expert vs. the real models using >1 experts. So the test case gets a tensor like this:ne = {192, 1, 128, 1}, nb = {4, 1536, 1536, 196608}. This should be contiguous in dimensions 1, 2, and 3 but it is not according toggml_is_contiguous_1. The reason is that the code on master entirely skips dimensions that have a size of 1. But this then also skips the fix fornext_nbif a dimension does not need to be contiguous. This PR adjusts the logic to skip only the check for whether or not the tensor is contiguous if a dimension is equal to 1.