Skip to content

opencl: improve fa, allow dk512 for gemma-4, improve dk64 - #30266

Merged
max-krasnyansky merged 4 commits into
ggml-org:masterfrom
qualcomm:lh/opencl-gemma4-decode-minimal
Oct 11, 2026
Merged

max-krasnyansky merged 4 commits into
ggml-org:masterfrom
qualcomm:lh/opencl-gemma4-decode-minimal

Conversation

@lhez

@lhez lhez commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR extracts part of #26430 and enables dk = 512 with gqa = 4 and gqa = 8 for FA so gemma-4 does not fall back to CPU when FA is enabled. It also improves dk = 64 with gqa = 8 for gpt-oss-20b.

Additional information

Details

gpt-oss-20b

master

model size params backend ngl fa lm test t/s
gpt-oss 20B MXFP4 MoE 11.27 GiB 20.91 B OpenCL 99 1 none tg256 @ d16384 16.59 ± 0.08

PR

model size params backend ngl fa lm test t/s
gpt-oss 20B MXFP4 MoE 11.27 GiB 20.91 B OpenCL 99 1 none tg256 @ d16384 29.01 ± 0.08

gemma-4-E4B

master

Fallback to CPU

PR

model size params backend ngl fa lm test t/s
gemma4 E4B Q4_0 4.49 GiB 7.52 B OpenCL 99 1 none tg256 @ d16384 20.58 ± 0.39

Requirements

lhez and others added 4 commits October 9, 2026 21:02
Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
@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 10, 2026
@lhez
lhez marked this pull request as ready for review October 10, 2026 18:19
@lhez
lhez requested a review from a team as a code owner October 10, 2026 18:19
@lhez

lhez commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@max-krasnyansky please review and 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 10, 2026

@CISC CISC left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have pushed the nits myself if I could. :)

std::map<std::tuple<int, int, int>, cl_kernel> f32_f16_mq_decode;
std::map<std::tuple<int, int, int>, size_t> f32_f16_mq_decode_wg;
std::map<std::tuple<int, int, int>, int> f32_f16_mq_decode_hs;
std::set<std::tuple<int, int, int>> f32_f16_mq_decode_attempted;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::set<std::tuple<int, int, int>> f32_f16_mq_decode_attempted;
std::set<std::tuple<int, int, int>> f32_f16_mq_decode_attempted;

cl_int err;
const std::string & compile_opts = backend_ctx->kernel_compile_opts;
const std::string opencl_c_std = "CL" + std::to_string(backend_ctx->opencl_c_version.major) +
"." + std::to_string(backend_ctx->opencl_c_version.minor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"." + std::to_string(backend_ctx->opencl_c_version.minor);
"." + std::to_string(backend_ctx->opencl_c_version.minor);

This one just because it wasn't an even 4.

@max-krasnyansky
max-krasnyansky merged commit f2cc728 into ggml-org:master Oct 11, 2026
20 checks passed
@max-krasnyansky

Copy link
Copy Markdown
Member

I would have pushed the nits myself if I could. :)

Yeah, I need to figure out how to allow updates from ggml-maintainers in our fork.

@BrewTestBot BrewTestBot mentioned this pull request Oct 15, 2026
1 task done
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
…0266)

* opencl: enable Gemma-4 E4B GPU decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: extend Gemma-4 GPU decode to E2B

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: optimize DK64 GQA8 decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: optimize DK128 GQA4 decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

---------

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
…0266)

* opencl: enable Gemma-4 E4B GPU decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: extend Gemma-4 GPU decode to E2B

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: optimize DK64 GQA8 decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

* opencl: optimize DK128 GQA4 decode

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>

---------

Co-authored-by: Hongqiang Wang <wangh@qti.qualcomm.com>
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