Repository navigation
opencl: apply the noshuffle row‐alignment rule to q4_K, q5_K and q8_0 from q6_K (bug fix) - #28575
Merged
Merged
Conversation
lhez
marked this pull request as ready for review
September 12, 2026 06:20
max-krasnyansky
approved these changes
Sep 12, 2026
…, not just q6_K
use_adreno_kernels() gates the transposed ("noshuffle") weight layout on
ne1 % 128 == 0 for q6_K alone. q4_K, q5_K and q8_0 read the same packing and are
admitted with no alignment check, so an unaligned row count reaches a kernel
that cannot address it and the weight is read misaligned -- a wrong answer, not
a crash. Any model with an unaligned row count is affected; an odd lm_head
vocabulary is the common case.
The layout packs 2 rows per 32-bit texel and the GEMV reads it at an ne1/2 texel
stride with an exact-cover dispatch, so the bound is ne1 % 64 == 0. It is not
128: a q8_0 attention weight of ne1 = 2880 is a multiple of 64 but not of 128
and is correct, and declining it would cost prefill for nothing.
On an Adreno 840 this takes test-backend-ops MUL_MAT from 1018/1023 to
1023/1023; the five failures are q4_K and q5_K at m = 1023, k = 4096.
lhez
force-pushed
the
hq/opencl-noshuffle-row-alignment
branch
from
September 12, 2026 18:13
fa6fd27 to
16025da
Compare
lhez
approved these changes
Sep 12, 2026
1 task done
quimmedes
pushed a commit
to quimmedes/cafe-llama.cpp
that referenced
this pull request
Sep 16, 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.
Overview
This PR is to fix a bug that shows up in the three types by extending the rules in q6_k.
Additional information
Requirements