opencl: add int8 dp4 dense and MoE prefill optimization for Adreno GPUs - #25537
Merged
Conversation
lhez
force-pushed
the
hq/dp4a-prefill-moe
branch
2 times, most recently
from
July 10, 2026 21:07
1a5011f to
7fd1258
Compare
lhez
force-pushed
the
hq/dp4a-prefill-moe
branch
from
July 10, 2026 23:57
7fd1258 to
c9d5ec1
Compare
lhez
force-pushed
the
hq/dp4a-prefill-moe
branch
from
July 11, 2026 00:19
c9d5ec1 to
5149b40
Compare
lhez
approved these changes
Jul 11, 2026
max-krasnyansky
approved these changes
Jul 11, 2026
Geminihaha
added a commit
to Geminihaha/llama.cpp
that referenced
this pull request
Jul 13, 2026
Keep this branch's OpenCL backend; take upstream everywhere else. The only upstream OpenCL change in this merge is 1d1d9a9 "opencl: add int8 dp4 dense and MoE prefill optimization for Adreno GPUs (ggml-org#25537)". Its new dp4a kernels call dot_acc_sat_4x8packed_ss_int (a cl_khr_integer_dot_product intrinsic) unconditionally. Adreno 6xx (Adreno 660) does not expose cl_khr_integer_dot_product — only the older cl_qcom_dot_product8 — so those kernels fail to compile (clBuildProgram err=-11, "implicit declaration of dot_acc_sat_4x8packed_ss_int"). They are loaded eagerly with a fatal build, so this aborts EVERY model load on 6xx. The optimization is also X2E-gated at dispatch (q4k_dense_dp4a_on defaults to adreno_gen == X2E), so it can never run on 6xx even if it compiled — it is pure regression there. So the OpenCL backend files (ggml-opencl.cpp, CMakeLists.txt, cvt.cl, gemv_moe_*_ns.cl) are kept at this branch's version and the 16 new dp4a/quant_a/moe_* kernel files are dropped; all other upstream changes are merged. Verified on gemma-4-E2B-it-qat: loads and generates coherently (-ngl 99 -fa on, f16 KV, no err=-11/crash); test-backend-ops FLASH_ATTN_EXT 2551/2571 (0 crashes; gemma GQA+quant-KV still routed to CPU; 20 failures are the pre-existing hsk=40 dim-3-broadcast cases). MUL_MAT_ID has 305 failures, but those are pre-existing on this branch (OpenCL backend is now byte-identical to the pre-merge HEAD, and upstream did not touch the MoE CPU reference or the MUL_MAT_ID tests) and do not affect dense gemma.
wanghqc
added a commit
to qualcomm/llama.cpp
that referenced
this pull request
Jul 15, 2026
Brings the branch to current upstream tip (24 commits). The only upstream commit touching ggml-opencl is 1d1d9a9 -- our own dp4a PR (ggml-org#25537), which came back squash-merged and review-modified. Reconciled with the carve we sent upstream (hq/dp4a-prefill-moe) as the three-way base, since both sides descend from it: - the 16 dp4a kernel files came back BYTE-IDENTICAL to what we sent, so this branch keeps its own supersets of them (ragged variants, wimg, quarter tile-skip granularity) unchanged; - ggml-opencl.cpp: kept this branch's versions -- they are strictly newer (per-gen fa_c8_cluster / fa_c8_default_on from the capability work, the program-cache build_program_from_source_ex signature, the K-image and g8_c32 decode dispatches). Upstream's side is the older carve. - CMakeLists.txt: dropped a duplicate gemm_moe_q8_0_f32_ns entry that this branch had listed twice; upstream's review had already removed it.
CowboyTim
pushed a commit
to aardbeiplantje/llama.cpp
that referenced
this pull request
Jul 21, 2026
…Us (ggml-org#25537) * opencl: add int8 dp4 dense and moe GEMM * opencl: refactor --------- Co-authored-by: Li He <lih@qti.qualcomm.com>
satindergrewal
pushed a commit
to satindergrewal/llama.cpp
that referenced
this pull request
Aug 12, 2026
…Us (ggml-org#25537) * opencl: add int8 dp4 dense and moe GEMM * opencl: refactor --------- Co-authored-by: Li He <lih@qti.qualcomm.com>
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
Additional information
Here is a quick perf on X2-90, pp512, ON vs OFF same binary, without QPM bin kernels:
For X1-85: q4_K/q6_K MoE X1 gate wins +20–23%, dense tile +56%.
Right now, it is default-on for Adreno X2E, and there are some regresses on X1's narrower ALU / lower occupancy. X1 keeps the f16 path mostly.
Requirements