opencl: fix Q4_0 SOA rows and Adreno paths#1561
Conversation
e30fbfe to
7d92e51
Compare
|
Could @lhez @max-krasnyansky @shaofeiqi help review or route this Adreno OpenCL Q4_0 correctness fix when you have a chance? |
|
The author has done an excellent job here ! I have succesful tested this PR using a different (older) sd.cpp commit and different models, e.g NitroFusion and Diff-InstructStar. For both I earlier noticed similar mono-color image problems as mentioned for Flux and Z-Image. It should be emphasized that this PR now allows the use of multiple threads to use during computation in sd.cpp when using OpenCl / Adreno and Q4_0. (I had to use the -t 1 option beforehand.) Please merge as soon as possible @lhez @max-krasnyansky @shaofeiqi |
|
@happyyzy Thank you for bringing this up. I wonder if we can move this PR (and your xmem FA PR #1562) to llama.cpp repo since currently almost all development happens there and this way we can have all updates in the same place. By the way, I think you can have a separate PR for |
Summary
Fix OpenCL Q4_0 correctness issues seen when
GGML_OPENCL_SOA_Qand Adreno OpenCL kernels are enabled:GET_ROWS(Q4_0)to read SOA quant buffers instead of assuming an AoSblock_q4_0bufferGET_ROWS(Q4_0)transpose_2d()src1->view_offsThe same fix was also prepared for the older
leejet/ggmlfork used by stable-diffusion.cpp, but this branch was re-applied and build-checked against upstream master.Image evidence
The image-level reproduction was run through stable-diffusion.cpp using ggml OpenCL, because the observed failure requires full diffusion-model execution.
Test device/config:
Individual images:
Reproduction commands
The same model files and generation parameters were used before and after the patch.
Flux.2 Klein Q4_0, before
Result: command completes and saves an image, but the output is blank.
Flux.2 Klein Q4_0, after
Result: valid image output.
Z-Image Turbo Q4_0, before
Result: command completes and saves an image, but the output is blank.
Z-Image Turbo Q4_0, after
Result: valid image output.
Checks
git diff --check ggmlorg/master..HEAD cmake -S . -B /tmp/ggml_opencl_upstream_pr_build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DGGML_OPENCL=ON \ -DGGML_OPENCL_USE_ADRENO_KERNELS=ON \ -DGGML_OPENCL_EMBED_KERNELS=ON \ -DGGML_NATIVE=OFF cmake --build /tmp/ggml_opencl_upstream_pr_build --target ggml -jThe OpenCL-enabled ggml target builds successfully on this branch.