Skip to content

CUDA: MMVQ nwarps=8 for bs=1 for dense models on DGX Spark - #26843

Merged
am17an merged 3 commits into
ggml-org:masterfrom
ynankani:ynankani/mmvq_nwarp8
Aug 18, 2026
Merged

am17an merged 3 commits into
ggml-org:masterfrom
ynankani:ynankani/mmvq_nwarp8

Conversation

@ynankani

Copy link
Copy Markdown
Contributor

Overview

This change is inspired from #19478 .

For bs=1 decode on DGX Spark, the optimal config is nwarps=8 for dense models

  • 8 warps x 32 threads = 256 threads per block
  • blocks_per_iter = vdr * nwarps * warp_size / qi, so the K loop trip count for a row
    halves relative to nwarps=4:
  • for small_k narrow rows go with the default generic nwarps

For llama 3.1 8b instruct:

Type vdr qi blocks_per_iter @8w blocks_per_row (K=4096) iterations 4w -> 8w
Q4_0 2 4 128 128 2 -> 1
Q4_K 2 32 16 16 2 -> 1
Q8_0 2 8 64 128 4 -> 2
Q6_K 1 32 8 16 4 -> 2

Additional information

Performance
Model PR Master Δ
llama_3.1_8b_Q2_K 62.54 61.54 1.62%
llama_3.1_8b_Q3_K_M 48.42 47.36 2.24%
llama_3.1_8b_Q4_0 46.24 44.87 3.05%
llama_3.1_8b_Q4_1 49.39 48.3 2.26%
llama_3.1_8b_Q4_K_S 46.68 44.47 4.97%
llama_3.1_8b_Q4_K_M 44.3 42.18 5.03%
llama_3.1_8b_Q5_K_M 38.47 36.94 4.14%
llama_3.1_8b_Q6_K 33.14 31.36 5.68%
llama_3.1_8b_Q8_0 28.45 26.77 6.28%
llama_3.1_8b_IQ4_NL 50.96 48.49 5.09%

Requirements

@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Aug 10, 2026
@am17an

am17an commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Have you tested this over MoE models?

@ynankani

ynankani commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Have you tested this over MoE models?

Tried with different quant + moe. Don't see any gain/delta due to small_k guard which makes moe and NvFP4 quant to run with generic path

Model master PR Change
Qwen3.6-35B-A3B NVFP4 76.42 76.99 +0.7%
Qwen3.6-35B-A3B Q4_K_M 70.08 70.48 +0.6%
Gemma-4-26B-A4B NVFP4 38.84 38.77 -0.2%

@am17an

am17an commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Please post results with all quant types that you're changing with both MoE and Dense models at bs=1. Microbenchmarks are also ok.

@ynankani

Copy link
Copy Markdown
Contributor Author

Please post results with all quant types that you're changing with both MoE and Dense models at bs=1. Microbenchmarks are also ok.

Looks like moe is not properly gated seeing regression in some quants for moe. Let me ping here once this PR is ready for review.

Dense llam_3.1_8b looks okay

Model PR Master Δ
llama_3.1_8b_Q2_K 62.54 61.54 1.62%
llama_3.1_8b_Q3_K_M 48.42 47.36 2.24%
llama_3.1_8b_Q4_0 46.24 44.87 3.05%
llama_3.1_8b_Q4_1 49.39 48.3 2.26%
llama_3.1_8b_Q4_K_S 46.68 44.47 4.97%
llama_3.1_8b_Q4_K_M 44.3 42.18 5.03%
llama_3.1_8b_Q5_K_M 38.47 36.94 4.14%
llama_3.1_8b_Q6_K 33.14 31.36 5.68%
llama_3.1_8b_Q8_0 28.45 26.77 6.28%
llama_3.1_8b_IQ4_NL 50.96 48.49 5.09%

@ynankani

ynankani commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @am17an needed to add some extra handling based on num iterations for the K geometry. Collected some perf scores with latest changes, please review.

Performance sweep token gen dense and moe model (-p 0 -n 128 -r 10)

phi4-mini-instruct

quant master PR delta
Q4_0 92.94 94.31 1.47%
Q4_1 89.34 90.26 1.03%
Q5_0 80.28 81.7 1.77%
Q5_1 77.84 79.02 1.52%
Q8_0 54.71 55.1 0.71%
Q2_K 105.65 104.49 −1.10%
Q4_K_M 78.71 80.03 1.67%
Q5_K_M 71.97 73.5 2.11%
Q6_K 62.85 63.76 1.45%
IQ4_NL 91.58 92.55 1.06%

llama3.1-8B-instruct

quant master PR delta
Q4_0 49.5 51.53 4.09%
Q4_1 48.66 49.76 2.27%
Q5_0 42.56 44.33 4.16%
Q5_1 41.66 42.95 3.09%
Q8_0 27.97 29.28 4.69%
Q2_K 64.29 64.54 0.38%
Q4_K_M 43.41 45.69 5.27%
Q5_K_M 38.14 39.75 4.21%
Q6_K 32.34 33.84 4.65%
IQ4_NL 50.18 51.56 2.76%

gemma-4-31B 

quant master PR delta
Q4_0 12.12 12.06 −0.45%
Q4_1 11.3 11.22 −0.69%
Q5_0 10.06 10.17 1.12%
Q5_1 9.75 9.86 1.04%
Q8_0 6.58 6.78 2.98%
Q2_K 15 14.97 −0.18%
Q4_K_M 10.48 10.6 1.22%
Q5_K_M 9 9.09 1.00%
Q6_K 7.7 7.94 3.10%
IQ4_NL 11.92 11.92 0.01%

llama3.3-70B 

quant master PR delta
Q4_0 5.57 5.65 1.39%
Q4_1 5.37 5.36 −0.17%
Q5_0 4.64 4.66 0.51%
Q5_1 4.48 4.54 1.30%
Q8_0 2.86 2.92 1.98%
Q2_K 7.18 7.19 0.23%
Q4_K_M 4.58 4.65 1.55%
Q5_K_M 3.87 4.03 3.94%
Q6_K 3.36 3.44 2.31%
IQ4_NL 5.45 5.56 2.02%

gemma4-26B-A4B

quant master PR delta
Q4_0 79.63 80.66 1.30%
Q4_1 75.94 75.86 −0.11%
Q5_0 71.59 71.69 0.13%
Q5_1 69.13 69.2 0.10%
Q8_0 51.11 51.05 −0.13%
Q2_K 92.1 91.62 −0.52%
Q4_K_M 71.02 71.32 0.42%
Q5_K_M 65.37 65.56 0.29%
Q6_K 57.35 57.43 0.15%
IQ4_NL 78.13 79.6 1.88%

qwen3.6-35B-A3B

quant master PR delta
Q4_0 91.06 91.57 0.55%
Q4_1 87.78 88.54 0.87%
Q5_0 81.55 81.7 0.19%
Q5_1 79.44 79.51 0.09%
Q8_0 59.93 59.38 −0.92%
Q2_K 97.53 98.72 1.22%
Q4_K_M 82.53 83.13 0.73%
Q5_K_M 75.43 75.78 0.46%
Q6_K 68.33 68.6 0.39%
IQ4_NL 86.99 87.38 0.45%

@ynankani
ynankani marked this pull request as ready for review August 12, 2026 16:44
@ynankani
ynankani requested a review from a team as a code owner August 12, 2026 16:44
Comment thread ggml/src/ggml-cuda/mmvq.cu Resolved
@am17an am17an added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Aug 17, 2026
@am17an
am17an merged commit 25ae3a9 into ggml-org:master Aug 18, 2026
22 of 24 checks passed
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
…26843)

* CUDA: MMVQ nwarps=8 for bs=1 for dense models on DGX Spark

Signed-off-by: ynankani <[email protected]>

* skip moe experts and allow others based on k geometry (allow only small idle tail)

Signed-off-by: ynankani <[email protected]>

* rename MMVQ DGX Spark params to GB10 and fix MSVC constexpr lambda capture

Signed-off-by: ynankani <[email protected]>

---------

Signed-off-by: ynankani <[email protected]>
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
…26843)

* CUDA: MMVQ nwarps=8 for bs=1 for dense models on DGX Spark

Signed-off-by: ynankani <[email protected]>

* skip moe experts and allow others based on k geometry (allow only small idle tail)

Signed-off-by: ynankani <[email protected]>

* rename MMVQ DGX Spark params to GB10 and fix MSVC constexpr lambda capture

Signed-off-by: ynankani <[email protected]>

---------

Signed-off-by: ynankani <[email protected]>
@meitmt meitmt mentioned this pull request Oct 27, 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 merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants