Skip to content

ggm-cuda: enforce DP4A MMQ tile height multiple of warp size - #30837

Merged
JohannesGaessler merged 1 commit into
ggml-org:masterfrom
thelittlefireman:feat_static_assert_dp4a
Oct 23, 2026
Merged

JohannesGaessler merged 1 commit into
ggml-org:masterfrom
thelittlefireman:feat_static_assert_dp4a

Conversation

@thelittlefireman

Copy link
Copy Markdown
Contributor

Overview

Add static assertion for DP4A MMQ tile height

Additional information

Will I was trying to tweak some mmq config, I try this config CASE(GGML_TYPE_IQ4_NL, 512, 2, 96, 40, GGML_CUDA_MMQ_SRAM_LAYOUT_Q8_0, MMQ_ITER_K, false, true); this result in wrong computation and no test seems to detect this issue and the compiler accept it, as it should not.

On gfx906, mmq use DP4A with 64 physical lanes, and in this loop:

for (int i0 = 0; i0 < I; i0 += warp_size) {
    sum[j0/nwarps*I/warp_size + i0/warp_size] += ...;
}

With I=96 the loop use i0=0 and i0=64 but the integer division equals I/warp_size = 96/64 = 1.
For J40 with 512 threads (8 waves):

Iteration Sum index
j0=0, i0=0 0
j0=0, i0=64 1
j0=8, i0=0 1 — collision
j0=8, i0=64 2

This static assert should avoid this mistake :)

Requirements

Added static assertion to enforce DP4A MMQ tile height requirement.
@thelittlefireman
thelittlefireman requested a review from a team as a code owner October 19, 2026 20:28
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Oct 19, 2026
@thelittlefireman

Copy link
Copy Markdown
Contributor Author

@ggml-org/ggml-cuda Can you take a look at this ? Thanks :)

@JohannesGaessler
JohannesGaessler merged commit 1a24df1 into ggml-org:master Oct 23, 2026
15 checks passed
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 24, 2026
…g#30837)

Added static assertion to enforce DP4A MMQ tile height requirement.
MuFengMuXue pushed a commit to MuFengMuXue/llama.cpp-gfx906 that referenced this pull request Oct 25, 2026
…g#30837)

Added static assertion to enforce DP4A MMQ tile height requirement.

(cherry picked from commit 1a24df1)
auRose94 pushed a commit to auRose94/llama.cpp that referenced this pull request Oct 28, 2026
…g#30837)

Added static assertion to enforce DP4A MMQ tile height requirement.
@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

CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants