Skip to content

vulkan: Support Q2_0 - #25430

Merged
0cc4m merged 3 commits into
ggml-org:masterfrom
jeffbolznv:q2_0
Jul 17, 2026
Merged

vulkan: Support Q2_0#25430
0cc4m merged 3 commits into
ggml-org:masterfrom
jeffbolznv:q2_0

Conversation

@jeffbolznv

Copy link
Copy Markdown
Contributor

Overview

Support Q2_0.

The backend perf tests for mat-vec-mul weren't very good at first (worse than q2_k), doubling the rows per workgroup (using rm_kq_int) made a big difference.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, codex did most of this, but I helped to tune the performance.

@jeffbolznv
jeffbolznv requested review from a team and ggerganov as code owners July 8, 2026 03:33
@github-actions github-actions Bot added testing Everything test related Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Jul 8, 2026
@jeffbolznv

Copy link
Copy Markdown
Contributor Author

Metal crash would presumably be fixed by #25419, if that gets merged soon I'm fine to wait for it.

@jeffbolznv
jeffbolznv force-pushed the q2_0 branch 2 times, most recently from 255f067 to a16d750 Compare July 13, 2026 14:54
@ggerganov

Copy link
Copy Markdown
Member

Metal crash would presumably be fixed by #25419, if that gets merged soon I'm fine to wait for it.

It's merged now.

@0cc4m 0cc4m 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.

LGTM

Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp
Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp
The backend perf tests for mat-vec-mul weren't very good at first (worse than
q2_k), doubling the rows per workgroup made a big difference.
@jeffbolznv

Copy link
Copy Markdown
Contributor Author

Had to resolve a nontrivial conflict, will need another +1 to merge.

MarkShark2 added a commit to MarkShark2/llama.cpp that referenced this pull request Jul 15, 2026
Q2_0 (ternary) GPU kernels for CUDA and Vulkan, cherry-picked from the
upstream-targeted PrismML PR branches (ggml-org#25603 cuda, ggml-org#25430 vulkan). Upstream
already carries the Q2_0 type + CPU backend (ggml-org#24448) and the qwen35 arch, so
these kernels are the only gap for running Ternary-Bonsai-27B (Q2_g64).
@0cc4m
0cc4m merged commit 788e07d into ggml-org:master Jul 17, 2026
27 checks passed
MarkShark2 added a commit to MarkShark2/llama.cpp that referenced this pull request Jul 17, 2026
Upstream landed native Q2_0 (type 42) with full Vulkan support (ggml-org#25430) and
refactored the CUDA MMQ kernel configuration (ggml-org#24127). Reconciled feat/q2_0-gpu
against both:

- Vulkan Q2_0: took upstream's implementation (identical QK2_0=64 block format;
  our branch had cherry-picked the same PR). Dropped our redundant shader/pipeline
  copies.
- CUDA Q2_0: dropped entirely (MMQ port collided with the ggml-org#24127 refactor and the
  half-kept dequant path would have routed small-batch matmuls to a mmvq kernel
  that no longer exists). Q2_0 now runs on Vulkan (BC-250) only, matching upstream;
  the 3090 has no Q2_0 path, same as mainline. Re-porting the CUDA kernel is a
  deliberate follow-up if a House config ever needs Q2_0 on CUDA.

Preserved fork features through the merge: mtp_dev pin, hy_v3 (.bias suffix +
per-layer n_ff_exp_impl), nemotron-h MTP filter, ssm d_state 96 (CUDA+Vulkan),
vk-uma-mem clamp, disk-cache, rpc-cache(-preflight), decode-timing instrumentation.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
ggerganov pushed a commit to am17an/llama.cpp that referenced this pull request Jul 28, 2026
* vulkan: Support Q2_0

The backend perf tests for mat-vec-mul weren't very good at first (worse than
q2_k), doubling the rows per workgroup made a big difference.

* reorder

* resolve merge conflict, adjust err threshold for f16->q2_0 set_rows
smalinin pushed a commit to smalinin/llama.cpp that referenced this pull request Aug 4, 2026
* vulkan: Support Q2_0

The backend perf tests for mat-vec-mul weren't very good at first (worse than
q2_k), doubling the rows per workgroup made a big difference.

* reorder

* resolve merge conflict, adjust err threshold for f16->q2_0 set_rows
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
* vulkan: Support Q2_0

The backend perf tests for mat-vec-mul weren't very good at first (worse than
q2_k), doubling the rows per workgroup made a big difference.

* reorder

* resolve merge conflict, adjust err threshold for f16->q2_0 set_rows
mndodd added a commit to mndodd/llama.cpp that referenced this pull request Aug 12, 2026
…g every type and aborting

ggml_backend_sycl_device_supports_op()'s MUL_MAT case ended in an unconditional
return true, so the backend claimed every src0 type including ones with no kernel
and no dequantizer. The scheduler took it at its word and the dispatch then hit
GGML_ABORT("unsupport data type"). A backend that aborts rather than declining is
not "unsupported", it is a crash: when upstream added Q2_0 (ggml-org#25430, a Vulkan PR)
it killed test-backend-ops -o MUL_MAT at case 72 of 1769.

That mattered because two thirds of our own added MUL_MAT coverage sits past case
72, so it had silently stopped running (findings/206).

The set is derived, not invented. MMVQ/MMQ/DMMV are optimisations that each claim
only some shapes; when none does, mul_mat falls back to dequantize -> oneDNN GEMM.
So the real predicate is "does convert.cpp have a dequantizer", and the list
mirrors ggml_get_to_fp16_sycl/ggml_get_to_fp32_sycl plus the native float types.
ggml_get_to_fp16_sycl cannot be used as the predicate directly because it ABORTs
on an unknown type rather than returning nullptr -- probing it would trigger the
crash being prevented.

Measured, -o MUL_MAT default env: 72 cases -> 658. q2_0 declined cleanly in 9
cases instead of aborting. Previously-unreachable coverage now runs: MMVQ
ncols_dst 13/14/15 0 -> 18, non-reorder multi-column 0 -> 219, MMQ n=9 probe
9 -> 62. No deployed type is declined -- q4_0/q8_0/q4_K/q5_K/q6_K all still
supported and passing; the f32/f16 "not supported" entries are the pre-existing
a->ne[3] != b->ne[3] gate, which sits after this check.

Same defect shape as the CONCAT supports_op fall-through. The remaining -o MUL_MAT
abort is upstream's CPU reference (vec.cpp:369 !isnan(sumf)) on degenerate f16
data, not ours.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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 testing Everything test related Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants