Skip to content

opencl: add dp4a GEMM variants to vector load activation - #30753

Merged
ggerganov merged 2 commits into
ggml-org:masterfrom
qualcomm:lh/dp4a-int4-load
Oct 21, 2026
Merged

ggerganov merged 2 commits into
ggml-org:masterfrom
qualcomm:lh/dp4a-int4-load

Conversation

@lhez

@lhez lhez commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds dp4a GEMM variants that vectorize activation load in int4 for q4_0, q8_0, q4_k, q5_k, q6_k. This improves pp when Adreno kernel lib is not used. Extracted from #30179 and refactored.

Additional information

Details ### gemma-4-E4B

PR

model size params backend ngl fa lm test t/s
gemma4 E4B Q4_K - Medium 4.62 GiB 7.52 B OpenCL 99 1 none pp4096 371.83 ± 0.46

master

model size params backend ngl fa lm test t/s
gemma4 E4B Q4_K - Medium 4.62 GiB 7.52 B OpenCL 99 1 none pp4096 340.55 ± 0.50

Qwen3.8-27B

PR

model size params backend ngl fa lm test t/s
qwen35 27B Q4_K - Medium 15.92 GiB 27.32 B OpenCL 99 1 none pp4096 81.31 ± 0.03

master

model size params backend ngl fa lm test t/s
qwen35 27B Q4_K - Medium 15.92 GiB 27.32 B OpenCL 99 1 none pp4096 72.77 ± 0.01

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: Yes, Codex did the port, then refactored several iteration with Codex.

@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning OpenCL Issues specific to the OpenCL backend labels Oct 18, 2026
@lhez
lhez marked this pull request as ready for review October 18, 2026 21:08
@lhez
lhez requested a review from a team as a code owner October 18, 2026 21:08
@lhez

lhez commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@max-krasnyansky please review/ack when you get a chance.

@lhez lhez added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Oct 20, 2026
@lhez
lhez force-pushed the lh/dp4a-int4-load branch from f3176c6 to 601f79b Compare October 20, 2026 18:16
@ggerganov
ggerganov merged commit b531e4c into ggml-org:master Oct 21, 2026
18 of 20 checks passed
wanghqc added a commit to qualcomm/llama.cpp that referenced this pull request Oct 22, 2026
ggml-opencl keeps this branch's implementation where upstream added its own
version of the same feature: cooperative-K dp4a GEMM (ggml-org#30741, = cok), the
act_vload4 dp4a GEMMs (ggml-org#30753, = alds4), the narrow l4_lm / q1_0 nsg1 variants
(ggml-org#30850), the FA rework (ggml-org#30266), the expert-sort buf+offset (ggml-org#30418, kept the
aligned-copy path) and the PREC_F32 MUL_MAT_ID decline (ggml-org#30365, covered by the
src1 precision floor). The gemm_coopk_* kernels are not carried.

Taken from upstream: IM2COL_3D (ggml-org#30895), get_rows i32 and cpy i32<->f32
(ggml-org#30756), CLAMP on non-contiguous views (ggml-org#30186), the A6X fixes (ggml-org#30176: a623
detection, constant-fold workaround, no cpy pack kernel), rms_norm full
subgroup (ggml-org#30310), the rope build fix (ggml-org#30893), the mxfp4 flat GEMV row bound,
the extra q5_0/q5_1/q5_K GEMV tail clamps (ggml-org#30421) and query_valid after the
softcap in the q4_0/q8_0 FA prefill (ggml-org#30546). The q4_0 q1_vec FA decode now
applies the softcap on the dp4a path too.

Speculative decoding keeps this branch's llama_batch path: LiliCorr drafters
(ggml-org#30506) are refused at load. The server keeps the tree verify and gives the
logprobs of ggml-org#27196 the batch row each accepted token was sampled from. The two
GDN n_tokens > K tests are dropped with upstream's relaxed contract.
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
)

* opencl: add dp4a GEMM variants with vector activation loads

* opencl: rename kernels and env vars
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
)

* opencl: add dp4a GEMM variants with vector activation loads

* opencl: rename kernels and env vars
@BrewTestBot BrewTestBot mentioned this pull request Oct 28, 2026
1 task done
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 merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. OpenCL Issues specific to the OpenCL backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants