Skip to content

Add Q2_K reordered MMVQ and ESIMD kernels - #26336

Merged
ggerganov merged 10 commits into
ggml-org:masterfrom
aicss-genai:esimd-q2k
Aug 21, 2026
Merged

Add Q2_K reordered MMVQ and ESIMD kernels#26336
ggerganov merged 10 commits into
ggml-org:masterfrom
aicss-genai:esimd-q2k

Conversation

@malsbat

@malsbat malsbat commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Overview

Continuing the work in #25942 to add the Q2_K kernel. In order to support the reordered ESIMD it is necessary to support reordered MMVQ as the MMVQ path is enabled in multi-token calls.

Measured tg improvement of 1.54x to 1.90x (depending on hardware) using Qwen35-27B-Q2_K_M.

Additional information

Note: all measurements were captured with #25741 applied locally as the parent PR does not include the newer upstream fix. This only affects pp numbers which are not the important part of this PR.

PVC performance

Baseline (unreordered MMVQ):

export GGML_SYCL_ENABLE_OPT=0
export GGML_SYCL_PRIORITIZE_DMMV=0
export GGML_SYCL_ENABLE_ESIMD=0
model size params backend ngl sm test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none pp512 886.33 ± 4.67
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none tg128 11.48 ± 0.00

Reordered MMVQ

export GGML_SYCL_ENABLE_OPT=1
export GGML_SYCL_PRIORITIZE_DMMV=0
export GGML_SYCL_ENABLE_ESIMD=0
model size params backend ngl sm test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none pp512 883.92 ± 3.91
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none tg128 14.06 ± 0.00

DMMV

export GGML_SYCL_ENABLE_OPT=1
export GGML_SYCL_PRIORITIZE_DMMV=1
export GGML_SYCL_ENABLE_ESIMD=0
model size params backend ngl sm test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none pp512 888.42 ± 3.82
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none tg128 14.09 ± 0.00

ESIMD

export GGML_SYCL_ENABLE_OPT=1
export GGML_SYCL_PRIORITIZE_DMMV=0
export GGML_SYCL_ENABLE_ESIMD=1
model size params backend ngl sm test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none pp512 888.90 ± 1.99
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 none tg128 17.63 ± 0.13

Perplexity tests across wikitext, hellaswag, and winogrande showed no significant changes between unreordered MMVQ, reordered MMVQ, and ESIMD.

B70 for same 4 scenarios

model size params backend ngl test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 pp512 668.22 ± 1.60
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 tg128 10.74 ± 0.03
model size params backend ngl test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 pp512 678.17 ± 1.58
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 tg128 15.19 ± 0.07
model size params backend ngl test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 pp512 674.22 ± 1.05
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 tg128 17.70 ± 0.09
model size params backend ngl test t/s
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 pp512 672.23 ± 1.92
qwen35 27B Q2_K - Medium 11.21 GiB 27.32 B SYCL 100 tg128 20.43 ± 0.13

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, used Claude heavily to author new kernels based on existing patterns.

malsbat added 9 commits July 20, 2026 21:43
Configure cmake build with -DGGML_SYCL_ESIMD=ON to enable.

Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
While not an issue in the current version, this will become an
issue when additional QK ESIMD kernels are added (such as Q2_K).

Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
@malsbat

malsbat commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Same as the Q3 PR, I will rebase and mark ready for review once #25942 is merged.

@github-actions github-actions Bot added documentation Improvements or additions to documentation ggml changes relating to the ggml tensor library for machine learning SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language labels Jul 30, 2026

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With Qwen3.5-27B-UD-Q2_K_XL.gguf on B60.

Test fa Base t/s Primary t/s Increase Rate (Primary vs Base)
pp512 0 172.46 172.44 -0.01%
pp512 1 173.57 169.84 -2.15%
tg128 0 10.82 12.27 13.40%
tg128 1 10.83 12.28 13.39%

@arthw arthw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's good job!

Thank you!

@arthw arthw added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Aug 4, 2026
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
@malsbat
malsbat marked this pull request as ready for review August 13, 2026 16:58
@malsbat
malsbat requested a review from a team as a code owner August 13, 2026 16:58
@ggerganov
ggerganov merged commit ff14356 into ggml-org:master Aug 21, 2026
26 of 30 checks passed
@CISC

CISC commented Aug 21, 2026

Copy link
Copy Markdown
Member

https://github.com/ggml-org/llama.cpp/actions/runs/32461271351/job/96735363159#step:7:311

@ggerganov

Copy link
Copy Markdown
Member

Weird that the CI passed before merging

@CISC

CISC commented Aug 21, 2026

Copy link
Copy Markdown
Member

Weird that the CI passed before merging

It wasn't rebased after #26779 merged.

NickM-27 pushed a commit to NickM-27/llama.cpp that referenced this pull request Aug 21, 2026
ggerganov pushed a commit that referenced this pull request Aug 22, 2026
* Revert "Revert "sycl : add Q2_K reordered MMVQ and ESIMD kernels (#26336)" (#…"

This reverts commit 7a0e42f.

* add gate params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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. SYCL https://en.wikipedia.org/wiki/SYCL - GPU programming language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants