Skip to content

ggml: fix ggml_is_contiguous_n for ne == 1#20092

Merged
JohannesGaessler merged 1 commit intoggml-org:masterfrom
JohannesGaessler:ggml-fix-contiguous-check
Mar 4, 2026
Merged

ggml: fix ggml_is_contiguous_n for ne == 1#20092
JohannesGaessler merged 1 commit intoggml-org:masterfrom
JohannesGaessler:ggml-fix-contiguous-check

Conversation

@JohannesGaessler
Copy link
Copy Markdown
Contributor

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 like GGML_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 to ggml_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 for next_nb if 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.

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Mar 3, 2026
@JohannesGaessler JohannesGaessler merged commit 7f5ee54 into ggml-org:master Mar 4, 2026
78 checks passed
Ethan-a2 pushed a commit to Ethan-a2/llama.cpp that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants