Skip to content

CUDA: branchless Q4_K/Q5_K unpack to speed up mmvq, L2 prefetch on DGX Spark - #26705

Merged
am17an merged 10 commits into
ggml-org:masterfrom
praneshgo:pgonegandla/mmvq-q4k-q5k-branchless
Sep 7, 2026
Merged

CUDA: branchless Q4_K/Q5_K unpack to speed up mmvq, L2 prefetch on DGX Spark#26705
am17an merged 10 commits into
ggml-org:masterfrom
praneshgo:pgonegandla/mmvq-q4k-q5k-branchless

Conversation

@praneshgo

@praneshgo praneshgo commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Overview

The Q4_K/Q5_K scale unpack branches on a runtime value to pick between two layouts. nvcc can't fold that, so it predicates it and then repeats the whole thing for every column of the ncols_dst loop instead of doing it once. Swapping the branch for a mask select fixes it: predicated instructions at ncols_dst=8 go from 226 to 34, and the Q4_K kernel at 16 columns from 2256 to 1648. None of the other quant types have this problem, they already unpack unconditionally (Q3_K does the same 6-bit layout with plain shifts).

We see perf gains from batch size >=4 on RTX 5090 and >=5 on RTX 4090 (more details in the Performance drop down), however we do not see a gain with DGX Spark with branchless alone, and in fact a small regression at batch sizes 4-6. The most probable reason for this can be that the memory bandwidth on DGX Spark is much lower than that of RTX 4090 or 5090, and this means even with this optimization there is no effective time to save, since in the original code the unpack was already running while the kernel waits on the weight loads and so was not adding to the total time.

To avoid this dip and ensure an overall gain, we make Spark use prefetch. This in our results ensured increased decode throughput across several quant types which can be evident from the performance numbers below. Prefetch while improving decode throughput on DGX Spark, seemed to negatively contributed in case of GPUs with larger bandwidth like RTX 5090.
We analyzed ncu traces with prefetch enabled on RTX 5090, profiling Q8_0 on Llama-3.1-8B across ne11 1-8, with Q2_K as a control:

  • The prefetch does what it is intended to do: long_scoreboard drops on both parts.
  • However, each prefetch.global.L2 is still a global memory instruction taking an LSU slot and a queue entry, so lg_throttle goes up with it.
  • Spark has much more latency to hide in the first place, and long_scoreboard runs 1.5-2.3x higher at every ne11. It pays more queue pressure than the 5090 does, but it has enough to convert to cover it.
  • Larger ne11 kills the benefit but not the cost. Each weight gets reused across more columns, so the kernel stops being latency-bound (long_scoreboard 41.2 -> 7.9 on the 5090 going from ne11 1 to 8), while the prefetch still issues the same requests per loop iteration.
  • By ne11=8 it isn't hiding anything on the 5090, just adding instructions — long_scoreboard actually goes up there (7.90 -> 8.16) while on Spark it still drops (18.13 -> 12.22). That's where the worst non-Spark regression sits.
  • Net: +4.81% median on Spark, -1.39% on the 4090, -1.57% on the 5090.

Improvement in mmvq performance means that switch points in #26079 needs changes, which are also done in this PR.

Performance

Decode throughput in tokens/s, measured with llama-bench -p <n> -n 0 -embd 1 -r 30 -o csv on single-type --pure quantisations, so each number reflects the kernel under test rather than a model's tensor-type mix.

The mvq -> MMQ switch points are disabled in every build here, so batch sizes 1-8 all reach mul_mat_vec_q. Without that, master routes K-quants to MMQ above a per-architecture cap and any change to the vector kernel measures as exactly zero above it.

arm what it is dispatch
base upstream master mvq forced at ne11 1-8
branchless master + the branchless Q4_K/Q5_K scale unpack mvq forced at ne11 1-8
branchless + prefetch branchless plus the L2 prefetch, which is gated to DGX Spark and compiles out elsewhere mvq forced at ne11 1-8
MMQ same source as the branchless + prefetch arm, with mul_mat_vec_q disabled so everything runs MMQ MMQ forced at ne11 1-8

MMQ is built from the shipping source but is unaffected by it: mmq.cuh references neither the modified vector dot products nor the prefetch helper, so that row measures unmodified MMQ and shows where the crossover sits.

The two vs base columns are that arm against base at the same batch size. MMQ is a different kernel rather than a variant of base, so it is shown in absolute terms only; comparing it against the ship column is what locates the mvq -> MMQ crossover.

Each cell is the mean of two ABBA-ordered passes at that batch size. No cell is a median or an average across types, models or batches.

Q2_K doubles as a control. Neither change can reach it - it is excluded from the prefetch by mmvq_pf<GGML_TYPE_Q2_K>::bytes == 0, and branchless rewrites only the Q4_K/Q5_K scale unpack - so its two percentage columns should read zero, and what they actually read is the measurement floor for the table around them.

DGX Spark GB10

sm_121, ~273 GB/s unified LPDDR5, driver 610.43.02, CUDA 13.3.

DGX Spark GB10 - Llama-3.2-3B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 109.82 109.21 -0.56% 109.17 -0.59% 102.79
2 208.23 208.28 +0.03% 212.53 +2.07% 179.48
3 308.59 311.47 +0.93% 313.82 +1.70% 268.30
4 421.64 414.86 -1.61% 417.99 -0.87% 356.44
5 505.18 488.59 -3.28% 519.80 +2.89% 440.91
6 593.08 593.04 -0.01% 612.91 +3.34% 527.41
7 657.48 683.30 +3.93% 690.60 +5.04% 611.78
8 695.70 762.26 +9.57% 762.77 +9.64% 678.54
Q5_K 1 90.01 93.21 +3.56% 93.32 +3.68% 86.03
2 173.79 176.09 +1.32% 179.22 +3.12% 144.75
3 263.92 261.73 -0.83% 264.69 +0.29% 216.43
4 356.29 345.21 -3.11% 354.98 -0.37% 287.20
5 422.98 412.24 -2.54% 439.46 +3.90% 355.09
6 505.07 494.74 -2.04% 521.36 +3.23% 426.37
7 593.05 580.93 -2.04% 600.16 +1.20% 494.72
8 630.71 649.41 +2.97% 662.14 +4.98% 549.91
Q2_K 1 172.81 172.42 -0.23% 173.37 +0.32% 152.00
2 296.36 296.43 +0.02% 296.89 +0.18% 233.89
3 451.30 450.08 -0.27% 451.26 -0.01% 348.47
4 543.26 541.72 -0.28% 541.26 -0.37% 462.55
5 684.85 685.26 +0.06% 684.49 -0.05% 572.25
6 723.55 723.73 +0.02% 721.87 -0.23% 681.84
7 763.52 762.01 -0.20% 764.01 +0.06% 798.11
8 773.67 774.47 +0.10% 773.51 -0.02% 866.24
Q3_K 1 118.01 117.93 -0.06% 120.43 +2.05% 111.57
2 252.85 253.13 +0.11% 255.03 +0.86% 188.62
3 357.25 358.40 +0.32% 359.15 +0.53% 280.66
4 467.62 468.39 +0.17% 462.82 -1.03% 374.60
5 586.04 587.44 +0.24% 578.47 -1.29% 462.91
6 669.61 672.44 +0.42% 668.79 -0.12% 555.15
7 755.40 752.06 -0.44% 766.23 +1.43% 642.50
8 795.47 799.15 +0.46% 779.98 -1.95% 708.03
Q6_K 1 76.16 76.57 +0.55% 78.12 +2.58% 73.13
2 147.24 147.08 -0.11% 152.23 +3.39% 123.56
3 218.18 218.32 +0.06% 228.43 +4.70% 184.52
4 291.44 290.87 -0.20% 301.87 +3.58% 245.37
5 345.03 344.76 -0.08% 366.39 +6.19% 304.50
6 413.98 413.12 -0.21% 439.01 +6.05% 365.00
7 478.32 475.81 -0.53% 506.07 +5.80% 424.96
8 543.92 545.04 +0.21% 563.45 +3.59% 472.50
Q4_0 1 119.17 118.90 -0.22% 118.89 -0.23% 109.33
2 235.54 235.33 -0.09% 233.17 -1.01% 185.02
3 346.77 346.59 -0.05% 348.24 +0.43% 277.51
4 458.44 457.71 -0.16% 457.80 -0.14% 367.86
5 555.28 554.32 -0.17% 554.20 -0.19% 456.69
6 660.01 659.44 -0.09% 661.47 +0.22% 544.46
7 761.99 759.72 -0.30% 769.42 +0.98% 631.96
8 854.79 853.93 -0.10% 853.86 -0.11% 698.60
Q8_0 1 65.68 65.63 -0.08% 67.80 +3.22% 63.11
2 126.39 126.12 -0.22% 130.52 +3.26% 105.90
3 189.58 189.35 -0.12% 193.64 +2.14% 158.24
4 252.03 251.24 -0.31% 258.24 +2.46% 210.18
5 300.83 300.48 -0.11% 312.27 +3.80% 261.49
6 360.18 360.04 -0.04% 371.04 +3.02% 312.92
7 419.53 418.12 -0.34% 432.52 +3.10% 364.71
8 479.45 478.60 -0.18% 479.78 +0.07% 407.51
IQ4_XS 1 121.59 122.20 +0.50% 119.13 -2.03% 110.70
2 233.78 233.20 -0.25% 250.52 +7.16% 194.79
3 325.88 325.22 -0.20% 374.60 +14.95% 291.57
4 432.60 432.41 -0.04% 497.09 +14.91% 388.72
5 596.22 597.53 +0.22% 599.08 +0.48% 480.50
6 658.34 656.17 -0.33% 708.61 +7.64% 574.88
7 766.77 766.05 -0.09% 821.90 +7.19% 665.07
8 806.57 801.66 -0.61% 903.78 +12.05% 737.02

DGX Spark GB10 - Llama-3.1-8B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 50.05 49.75 -0.58% 50.29 +0.49% 48.20
2 94.80 93.44 -1.44% 96.63 +1.93% 81.33
3 139.25 139.64 +0.28% 144.67 +3.89% 121.39
4 191.83 186.19 -2.94% 192.15 +0.17% 161.40
5 230.69 219.86 -4.69% 245.71 +6.51% 200.12
6 273.41 266.37 -2.58% 292.10 +6.83% 239.80
7 307.47 308.72 +0.41% 337.71 +9.83% 278.05
8 327.37 346.87 +5.96% 374.09 +14.27% 313.11
Q5_K 1 40.12 41.62 +3.74% 42.06 +4.85% 40.07
2 76.45 76.79 +0.44% 79.63 +4.17% 66.21
3 118.73 116.05 -2.26% 119.06 +0.28% 98.83
4 159.60 154.21 -3.38% 161.73 +1.33% 131.69
5 189.39 182.29 -3.75% 202.92 +7.14% 163.58
6 227.44 220.82 -2.91% 241.38 +6.13% 195.84
7 267.53 259.52 -2.99% 281.17 +5.10% 227.74
8 287.37 289.53 +0.75% 314.94 +9.59% 256.30
Q2_K 1 82.08 82.13 +0.06% 82.44 +0.43% 75.41
2 138.14 138.45 +0.22% 138.57 +0.30% 113.82
3 233.72 233.51 -0.09% 233.77 +0.02% 170.11
4 276.09 276.31 +0.08% 276.64 +0.20% 226.17
5 322.40 322.27 -0.04% 322.55 +0.05% 280.61
6 338.85 339.06 +0.06% 338.96 +0.04% 334.28
7 357.17 357.14 -0.01% 356.83 -0.10% 388.24
8 358.59 357.61 -0.27% 357.55 -0.29% 434.08
Q3_K 1 54.64 54.62 -0.02% 57.02 +4.36% 54.40
2 121.08 120.83 -0.21% 119.38 -1.41% 86.13
3 165.17 165.30 +0.08% 173.70 +5.17% 128.80
4 229.19 229.40 +0.09% 225.50 -1.61% 171.05
5 271.17 270.49 -0.25% 289.21 +6.65% 212.24
6 312.04 312.63 +0.19% 331.88 +6.36% 254.33
7 349.79 349.62 -0.05% 365.73 +4.56% 295.18
8 371.18 370.27 -0.24% 375.14 +1.07% 331.02
Q6_K 1 34.38 34.48 +0.29% 34.97 +1.71% 33.26
2 64.53 64.61 +0.13% 68.27 +5.80% 54.52
3 95.94 95.95 +0.02% 102.72 +7.07% 81.50
4 128.01 128.02 +0.01% 136.18 +6.38% 108.17
5 150.95 151.29 +0.23% 161.51 +7.00% 134.69
6 181.88 181.80 -0.04% 198.17 +8.96% 161.01
7 208.95 209.59 +0.31% 228.42 +9.32% 187.40
8 241.11 241.76 +0.27% 256.65 +6.45% 211.44
Q4_0 1 54.42 54.47 +0.08% 54.93 +0.93% 51.80
2 105.67 106.09 +0.40% 106.18 +0.48% 85.13
3 157.64 157.54 -0.06% 158.84 +0.76% 127.14
4 210.27 209.80 -0.22% 211.61 +0.64% 169.25
5 252.13 252.17 +0.02% 257.80 +2.25% 210.39
6 302.11 301.51 -0.20% 308.66 +2.17% 250.84
7 349.49 349.81 +0.09% 360.49 +3.15% 292.33
8 395.81 397.37 +0.39% 403.77 +2.01% 327.29
Q8_0 1 29.32 29.28 -0.14% 29.99 +2.30% 28.53
2 55.24 55.26 +0.03% 58.40 +5.72% 47.05
3 82.99 83.07 +0.10% 86.96 +4.78% 70.34
4 110.09 110.15 +0.05% 115.70 +5.09% 93.53
5 133.20 133.28 +0.06% 139.75 +4.92% 116.38
6 158.88 158.95 +0.04% 166.48 +4.78% 139.32
7 183.82 184.10 +0.16% 194.57 +5.85% 162.16
8 213.53 213.45 -0.04% 219.12 +2.62% 183.12
IQ4_XS 1 56.45 56.33 -0.21% 56.80 +0.62% 53.37
2 106.98 106.97 -0.01% 116.19 +8.61% 88.84
3 147.12 147.16 +0.03% 174.70 +18.75% 132.83
4 197.26 197.51 +0.13% 231.38 +17.29% 176.53
5 279.73 279.16 -0.20% 281.34 +0.58% 219.44
6 305.37 305.79 +0.14% 333.24 +9.13% 262.28
7 355.16 353.54 -0.45% 387.48 +9.10% 304.21
8 368.71 369.05 +0.09% 433.07 +17.46% 341.05

DGX Spark GB10 - gemma-4-12B-it

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 31.48 31.12 -1.12% 31.71 +0.75% 27.85
2 59.94 57.88 -3.42% 59.83 -0.17% 50.57
3 86.25 86.44 +0.23% 89.85 +4.17% 75.59
4 117.95 115.13 -2.40% 118.19 +0.20% 98.71
5 141.95 136.67 -3.72% 149.58 +5.38% 124.04
6 166.91 165.27 -0.98% 177.02 +6.06% 148.23
7 184.22 191.05 +3.71% 202.40 +9.87% 172.34
8 195.90 216.05 +10.29% 225.51 +15.11% 196.88
Q5_K 1 25.24 26.13 +3.52% 26.50 +4.99% 22.87
2 48.35 47.69 -1.36% 49.58 +2.54% 41.23
3 73.39 72.00 -1.90% 74.24 +1.15% 61.56
4 97.85 94.53 -3.39% 99.35 +1.54% 80.87
5 116.94 112.56 -3.75% 124.01 +6.05% 101.53
6 138.05 134.91 -2.27% 146.54 +6.15% 121.23
7 161.58 159.27 -1.43% 169.22 +4.73% 141.09
8 175.09 178.60 +2.00% 190.07 +8.56% 160.69
Q2_K 1 50.52 50.52 +0.01% 50.49 -0.05% 41.09
2 86.05 86.25 +0.23% 85.93 -0.13% 71.27
3 141.85 142.05 +0.14% 141.93 +0.06% 106.58
4 165.77 165.98 +0.13% 165.65 -0.07% 138.51
5 193.41 193.54 +0.06% 193.73 +0.16% 174.18
6 203.10 202.96 -0.07% 203.33 +0.11% 208.15
7 213.44 213.31 -0.06% 213.82 +0.18% 242.16
8 216.05 216.10 +0.03% 216.02 -0.01% 275.57
Q3_K 1 33.79 33.77 -0.09% 35.53 +5.13% 30.00
2 74.05 74.24 +0.26% 74.38 +0.45% 53.96
3 102.65 102.53 -0.12% 106.71 +3.96% 80.58
4 138.12 137.86 -0.19% 137.32 -0.58% 105.33
5 165.64 165.61 -0.02% 174.45 +5.32% 132.25
6 188.31 188.33 +0.01% 198.42 +5.37% 158.39
7 210.19 210.58 +0.18% 218.31 +3.86% 184.00
8 223.99 224.44 +0.20% 226.04 +0.91% 209.62
Q6_K 1 21.55 21.62 +0.33% 21.76 +0.99% 18.81
2 40.36 40.37 +0.02% 42.63 +5.63% 33.73
3 60.06 60.08 +0.04% 64.05 +6.65% 50.30
4 79.69 79.66 -0.03% 84.34 +5.84% 66.32
5 94.06 94.06 -0.01% 100.70 +7.05% 83.01
6 113.26 113.37 +0.10% 122.82 +8.44% 99.55
7 130.40 130.48 +0.06% 141.57 +8.57% 115.52
8 150.11 150.10 -0.00% 159.58 +6.31% 131.89
Q4_0 1 33.60 33.68 +0.22% 33.97 +1.11% 29.34
2 65.20 65.31 +0.17% 65.61 +0.64% 52.88
3 97.25 97.29 +0.04% 97.92 +0.69% 79.01
4 127.84 128.22 +0.30% 129.10 +0.99% 103.17
5 154.53 154.77 +0.16% 158.57 +2.61% 129.83
6 185.16 185.07 -0.05% 189.51 +2.35% 155.25
7 213.39 213.68 +0.14% 220.93 +3.53% 180.68
8 244.07 244.46 +0.16% 249.56 +2.25% 205.46
Q8_0 1 18.40 18.45 +0.27% 18.59 +1.00% 16.27
2 34.48 34.51 +0.08% 36.50 +5.83% 29.38
3 51.84 51.86 +0.03% 54.24 +4.62% 43.89
4 68.48 68.54 +0.08% 71.92 +5.01% 57.86
5 82.74 82.69 -0.07% 86.80 +4.91% 72.52
6 98.65 98.51 -0.14% 103.44 +4.85% 86.61
7 113.59 113.64 +0.05% 120.88 +6.42% 100.74
8 133.12 133.20 +0.06% 136.35 +2.42% 115.01
IQ4_XS 1 34.23 34.29 +0.17% 33.94 -0.87% 29.21
2 66.05 65.91 -0.20% 71.50 +8.25% 54.52
3 91.16 91.19 +0.03% 107.64 +18.09% 81.43
4 121.38 121.16 -0.18% 141.91 +16.91% 106.26
5 171.14 171.06 -0.05% 171.46 +0.19% 133.54
6 187.27 187.21 -0.03% 203.29 +8.55% 159.92
7 218.44 217.66 -0.36% 236.93 +8.46% 185.31
8 229.79 229.86 +0.03% 267.99 +16.63% 211.00

DGX Spark GB10 - Qwen3.6-27B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 14.04 14.03 -0.05% 14.80 +5.47% 13.52
2 26.67 26.30 -1.39% 28.15 +5.57% 23.50
3 39.24 39.35 +0.28% 42.11 +7.32% 35.06
4 54.06 52.67 -2.58% 55.62 +2.88% 46.15
5 64.96 61.95 -4.63% 70.21 +8.08% 57.83
6 76.59 74.97 -2.12% 83.18 +8.60% 69.13
7 86.43 86.59 +0.18% 95.58 +10.59% 80.31
8 92.93 98.10 +5.56% 106.23 +14.31% 91.51
Q5_K 1 11.26 11.66 +3.58% 12.41 +10.22% 11.14
2 21.80 21.61 -0.88% 23.15 +6.21% 19.04
3 33.64 32.69 -2.83% 34.55 +2.71% 28.44
4 45.11 42.99 -4.69% 46.64 +3.40% 37.51
5 53.69 50.91 -5.18% 58.03 +8.08% 47.03
6 64.11 61.79 -3.62% 68.82 +7.35% 56.26
7 75.86 72.73 -4.13% 80.46 +6.05% 65.27
8 83.10 81.82 -1.53% 90.95 +9.45% 74.35
Q2_K 1 23.41 23.51 +0.44% 23.47 +0.26% 20.26
2 39.39 39.45 +0.15% 39.43 +0.10% 32.83
3 65.38 65.37 -0.01% 65.33 -0.08% 48.99
4 79.00 78.99 -0.01% 78.97 -0.03% 64.09
5 92.58 92.57 -0.01% 92.64 +0.06% 80.45
6 97.65 97.51 -0.13% 97.54 -0.11% 96.33
7 103.14 102.96 -0.18% 103.13 -0.01% 111.77
8 104.21 104.00 -0.20% 104.17 -0.03% 126.98
Q3_K 1 15.48 15.49 +0.05% 16.92 +9.24% 15.02
2 34.13 34.16 +0.10% 34.82 +2.01% 24.26
3 46.57 46.63 +0.13% 49.40 +6.07% 36.26
4 63.87 63.91 +0.06% 63.51 -0.56% 47.68
5 75.07 75.13 +0.09% 83.84 +11.69% 59.88
6 86.23 86.14 -0.10% 95.88 +11.19% 71.54
7 99.32 99.16 -0.16% 105.04 +5.75% 83.12
8 106.82 106.59 -0.21% 109.12 +2.16% 94.65
Q6_K 1 9.54 9.56 +0.17% 10.07 +5.60% 9.16
2 18.32 18.31 -0.04% 19.62 +7.10% 15.77
3 27.27 27.24 -0.08% 29.46 +8.05% 23.58
4 36.17 36.17 -0.01% 38.82 +7.31% 31.14
5 42.92 42.91 -0.02% 45.86 +6.85% 38.97
6 51.92 51.96 +0.08% 56.80 +9.40% 46.63
7 59.75 59.74 -0.01% 65.45 +9.55% 54.23
8 69.21 69.20 -0.01% 73.86 +6.72% 61.83
Q4_0 1 15.31 15.31 -0.03% 15.61 +1.93% 14.20
2 29.92 29.91 -0.03% 30.30 +1.28% 24.62
3 44.59 44.56 -0.08% 45.26 +1.50% 36.74
4 58.76 58.72 -0.06% 59.71 +1.61% 48.30
5 70.90 70.94 +0.05% 73.45 +3.59% 60.57
6 85.09 84.97 -0.14% 88.13 +3.57% 72.43
7 98.09 98.10 +0.01% 102.79 +4.79% 84.07
8 112.00 111.84 -0.15% 116.33 +3.86% 95.65
Q8_0 1 8.15 8.17 +0.34% 8.68 +6.51% 7.96
2 15.69 15.70 +0.05% 16.74 +6.67% 13.73
3 23.58 23.57 -0.04% 24.99 +5.98% 20.54
4 31.13 31.12 -0.05% 33.17 +6.54% 27.15
5 37.87 37.89 +0.05% 39.79 +5.07% 33.96
6 45.12 45.15 +0.07% 47.54 +5.35% 40.66
7 52.11 52.16 +0.10% 55.43 +6.36% 47.28
8 61.12 61.12 +0.01% 62.91 +2.93% 53.96
IQ4_XS 1 16.10 16.09 -0.06% 16.23 +0.79% 14.75
2 30.16 30.16 +0.00% 32.91 +9.10% 25.92
3 41.63 41.62 -0.01% 49.13 +18.02% 38.68
4 55.24 55.23 -0.01% 65.05 +17.76% 50.83
5 78.31 78.38 +0.09% 78.88 +0.73% 63.80
6 85.43 85.46 +0.03% 93.56 +9.52% 76.28
7 99.32 99.33 +0.01% 105.12 +5.84% 88.50
8 104.24 104.36 +0.12% 118.20 +13.39% 100.70

RTX 5090

sm_120, 1792 GB/s, driver 620.23, CUDA 12.9.

RTX 5090 - Llama-3.2-3B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 434.51 445.36 +2.50% 443.53 +2.08% 365.16
2 757.26 800.44 +5.70% 797.42 +5.30% 564.81
3 1091.18 1152.01 +5.57% 1135.94 +4.10% 837.56
4 1252.51 1419.28 +13.31% 1408.61 +12.46% 1107.28
5 1368.78 1671.36 +22.11% 1659.63 +21.25% 1340.44
6 1440.16 1767.67 +22.74% 1753.03 +21.72% 1600.05
7 1542.23 1852.28 +20.10% 1858.64 +20.52% 1854.79
8 1686.82 1909.67 +13.21% 1944.78 +15.29% 2129.53
Q5_K 1 393.41 399.85 +1.64% 396.57 +0.80% 330.59
2 699.38 718.39 +2.72% 720.12 +2.97% 519.13
3 1001.20 1033.61 +3.24% 1034.42 +3.32% 766.16
4 1212.49 1301.13 +7.31% 1300.02 +7.22% 1011.50
5 1322.02 1548.45 +17.13% 1527.26 +15.52% 1248.75
6 1405.14 1667.38 +18.66% 1638.42 +16.60% 1488.81
7 1558.58 1774.12 +13.83% 1741.57 +11.74% 1726.40
8 1650.29 1878.63 +13.84% 1846.54 +11.89% 1978.22
Q2_K 1 478.69 484.29 +1.17% 487.47 +1.83% 387.47
2 819.02 832.36 +1.63% 831.24 +1.49% 562.02
3 1073.99 1074.91 +0.09% 1088.88 +1.39% 833.24
4 1247.00 1238.49 -0.68% 1255.47 +0.68% 1111.38
5 1408.34 1412.95 +0.33% 1419.06 +0.76% 1366.29
6 1529.01 1517.91 -0.73% 1545.86 +1.10% 1616.25
7 1634.49 1622.10 -0.76% 1655.84 +1.31% 1867.89
8 1702.96 1713.80 +0.64% 1705.27 +0.14% 2119.41
Q3_K 1 366.99 369.26 +0.62% 370.67 +1.00% 313.11
2 672.19 679.19 +1.04% 682.27 +1.50% 546.93
3 932.20 949.43 +1.85% 948.71 +1.77% 803.69
4 1172.54 1191.00 +1.57% 1163.00 -0.81% 1058.21
5 1348.53 1382.91 +2.55% 1352.28 +0.28% 1305.08
6 1467.96 1502.10 +2.33% 1483.32 +1.05% 1539.87
7 1650.89 1633.91 -1.03% 1641.98 -0.54% 1793.38
8 1653.74 1665.53 +0.71% 1664.33 +0.64% 2052.78
Q6_K 1 351.45 350.29 -0.33% 355.24 +1.08% 288.48
2 628.37 631.80 +0.55% 642.29 +2.22% 460.94
3 908.87 914.20 +0.59% 923.87 +1.65% 674.74
4 1151.98 1161.46 +0.82% 1180.32 +2.46% 892.71
5 1289.04 1293.21 +0.32% 1316.06 +2.10% 1111.20
6 1465.96 1476.81 +0.74% 1495.19 +1.99% 1306.40
7 1598.63 1612.85 +0.89% 1628.01 +1.84% 1521.56
8 1607.98 1608.96 +0.06% 1620.28 +0.76% 1729.04
Q4_0 1 454.01 451.94 -0.46% 453.60 -0.09% 351.71
2 807.98 802.04 -0.74% 805.60 -0.29% 526.50
3 1192.64 1188.73 -0.33% 1189.81 -0.24% 784.71
4 1553.36 1527.06 -1.69% 1547.22 -0.40% 1044.64
5 1861.97 1831.30 -1.65% 1850.40 -0.62% 1278.37
6 2150.74 2124.73 -1.21% 2147.76 -0.14% 1520.65
7 2320.98 2312.15 -0.38% 2322.56 +0.07% 1773.04
8 2353.75 2370.41 +0.71% 2363.68 +0.42% 2003.61
Q8_0 1 301.50 311.13 +3.19% 304.17 +0.89% 262.00
2 558.56 566.89 +1.49% 568.65 +1.81% 434.94
3 821.31 836.70 +1.87% 836.13 +1.80% 647.66
4 1085.44 1106.51 +1.94% 1104.61 +1.77% 858.38
5 1270.99 1295.95 +1.96% 1300.92 +2.35% 1050.07
6 1508.24 1540.13 +2.11% 1532.97 +1.64% 1229.37
7 1735.33 1759.64 +1.40% 1761.40 +1.50% 1453.76
8 1937.22 1971.20 +1.75% 1961.11 +1.23% 1655.09
IQ4_XS 1 445.77 449.31 +0.79% 450.44 +1.05% 366.27
2 840.13 846.87 +0.80% 845.11 +0.59% 577.47
3 1239.22 1248.86 +0.78% 1251.18 +0.96% 855.72
4 1587.49 1564.72 -1.43% 1587.39 -0.01% 1132.66
5 1840.58 1864.74 +1.31% 1864.83 +1.32% 1387.91
6 2042.48 2058.90 +0.80% 2068.93 +1.30% 1616.53
7 2262.65 2280.25 +0.78% 2262.83 +0.01% 1881.39
8 2458.27 2411.96 -1.88% 2432.60 -1.04% 2131.44

RTX 5090 - Llama-3.1-8B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 252.72 256.86 +1.64% 256.88 +1.65% 213.57
2 448.25 476.06 +6.21% 476.13 +6.22% 356.31
3 614.91 665.23 +8.18% 665.56 +8.24% 528.43
4 701.48 804.90 +14.74% 807.23 +15.08% 685.18
5 762.02 899.30 +18.02% 898.46 +17.91% 846.93
6 815.33 987.50 +21.12% 986.14 +20.95% 1003.83
7 861.85 1028.13 +19.29% 1027.61 +19.23% 1169.42
8 882.24 1081.51 +22.59% 1079.96 +22.41% 1344.71
Q5_K 1 220.73 222.16 +0.65% 221.03 +0.13% 185.20
2 396.08 405.44 +2.36% 403.66 +1.91% 314.59
3 561.32 581.08 +3.52% 578.64 +3.09% 467.41
4 672.96 736.12 +9.39% 730.76 +8.59% 622.53
5 741.46 841.04 +13.43% 824.43 +11.19% 767.78
6 776.24 929.20 +19.70% 916.27 +18.04% 919.23
7 834.20 964.18 +15.58% 973.22 +16.67% 1064.41
8 862.38 1011.58 +17.30% 1017.13 +17.94% 1214.73
Q2_K 1 316.84 312.76 -1.29% 311.88 -1.56% 243.52
2 538.03 532.17 -1.09% 528.23 -1.82% 362.19
3 652.00 643.22 -1.35% 637.77 -2.18% 534.48
4 746.70 743.27 -0.46% 732.53 -1.90% 712.51
5 836.86 832.68 -0.50% 823.38 -1.61% 876.27
6 844.80 842.47 -0.28% 841.76 -0.36% 1041.93
7 898.46 914.11 +1.74% 922.29 +2.65% 1213.15
8 911.23 933.11 +2.40% 949.78 +4.23% 1379.59
Q3_K 1 217.58 219.67 +0.96% 215.43 -0.99% 186.56
2 400.73 402.99 +0.56% 397.06 -0.92% 335.13
3 558.80 547.70 -1.99% 549.76 -1.62% 500.67
4 664.39 670.87 +0.97% 672.24 +1.18% 661.38
5 730.94 740.41 +1.30% 734.59 +0.50% 814.79
6 812.18 820.20 +0.99% 841.42 +3.60% 979.32
7 887.07 883.75 -0.37% 898.29 +1.27% 1132.86
8 894.96 888.56 -0.71% 905.29 +1.15% 1281.64
Q6_K 1 185.86 183.92 -1.05% 188.16 +1.23% 161.45
2 351.49 346.27 -1.49% 355.01 +1.00% 274.34
3 496.50 501.08 +0.92% 504.57 +1.62% 408.27
4 625.28 628.15 +0.46% 633.62 +1.33% 541.12
5 680.93 684.19 +0.48% 690.77 +1.44% 676.33
6 759.80 758.06 -0.23% 768.11 +1.09% 814.08
7 816.69 814.48 -0.27% 827.11 +1.28% 942.33
8 875.23 872.87 -0.27% 883.16 +0.91% 1072.62
Q4_0 1 249.61 258.33 +3.49% 258.75 +3.66% 212.02
2 464.07 486.16 +4.76% 485.99 +4.72% 334.96
3 680.12 705.55 +3.74% 707.15 +3.97% 496.53
4 874.32 901.64 +3.12% 905.37 +3.55% 657.36
5 1003.82 1040.24 +3.63% 1041.92 +3.79% 829.18
6 1136.80 1177.10 +3.54% 1179.70 +3.77% 974.26
7 1230.12 1275.38 +3.68% 1275.97 +3.73% 1138.41
8 1322.66 1373.27 +3.83% 1372.32 +3.76% 1292.41
Q8_0 1 155.42 155.56 +0.09% 155.34 -0.05% 140.17
2 298.11 295.94 -0.73% 292.34 -1.94% 242.70
3 439.90 437.97 -0.44% 430.86 -2.06% 362.35
4 575.96 567.35 -1.50% 572.86 -0.54% 476.99
5 676.01 670.85 -0.76% 665.60 -1.54% 578.07
6 780.85 793.04 +1.56% 786.13 +0.68% 692.36
7 868.47 887.72 +2.22% 879.60 +1.28% 804.22
8 993.99 997.09 +0.31% 999.42 +0.55% 916.76
IQ4_XS 1 261.53 263.10 +0.60% 263.16 +0.62% 220.83
2 473.98 473.55 -0.09% 476.18 +0.46% 362.51
3 696.36 694.07 -0.33% 690.57 -0.83% 527.94
4 886.61 891.17 +0.52% 891.21 +0.52% 700.56
5 1050.59 1050.74 +0.01% 1054.71 +0.39% 861.19
6 1138.06 1144.72 +0.59% 1138.27 +0.02% 1030.92
7 1299.57 1298.51 -0.08% 1295.53 -0.31% 1187.53
8 1351.14 1376.15 +1.85% 1374.61 +1.74% 1343.52

RTX 5090 - gemma-4-12B-it

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 137.24 137.75 +0.37% 135.67 -1.14% 109.09
2 252.34 258.67 +2.51% 252.49 +0.06% 204.58
3 346.39 367.77 +6.17% 356.78 +3.00% 312.54
4 392.18 443.00 +12.96% 436.92 +11.41% 417.44
5 439.16 492.66 +12.18% 492.20 +12.08% 518.51
6 474.46 560.64 +18.16% 549.22 +15.76% 617.43
7 507.69 602.95 +18.76% 595.01 +17.20% 718.00
8 532.33 642.73 +20.74% 632.66 +18.85% 803.71
Q5_K 1 121.03 121.80 +0.63% 123.66 +2.18% 103.88
2 222.80 231.25 +3.79% 227.60 +2.15% 192.43
3 310.24 339.78 +9.52% 335.51 +8.15% 287.82
4 380.13 421.38 +10.85% 414.45 +9.03% 382.84
5 441.63 486.02 +10.05% 479.84 +8.65% 472.70
6 471.47 549.29 +16.51% 542.86 +15.14% 554.97
7 499.24 578.97 +15.97% 584.96 +17.17% 639.54
8 520.02 596.31 +14.67% 625.29 +20.24% 724.58
Q2_K 1 164.54 164.46 -0.05% 163.32 -0.74% 119.89
2 285.48 285.85 +0.13% 282.78 -0.95% 215.36
3 355.31 354.22 -0.31% 354.25 -0.30% 323.25
4 408.41 416.11 +1.89% 416.55 +1.99% 425.53
5 473.10 474.20 +0.23% 476.62 +0.74% 530.15
6 495.97 497.12 +0.23% 500.23 +0.86% 639.22
7 541.63 546.07 +0.82% 546.87 +0.97% 740.83
8 552.22 570.53 +3.32% 566.68 +2.62% 836.58
Q3_K 1 122.14 122.76 +0.50% 119.85 -1.87% 105.53
2 227.25 228.28 +0.45% 222.85 -1.94% 208.99
3 313.57 310.04 -1.13% 310.49 -0.98% 311.26
4 380.62 370.95 -2.54% 378.09 -0.66% 413.96
5 443.23 434.24 -2.03% 440.46 -0.62% 511.56
6 501.87 481.10 -4.14% 493.61 -1.65% 609.70
7 548.94 527.11 -3.98% 549.71 +0.14% 688.54
8 539.59 542.71 +0.58% 551.78 +2.26% 792.31
Q6_K 1 108.47 108.39 -0.08% 109.70 +1.13% 89.47
2 206.72 209.34 +1.27% 209.45 +1.32% 166.54
3 302.89 304.25 +0.45% 304.31 +0.47% 252.53
4 376.96 378.54 +0.42% 378.07 +0.30% 335.27
5 431.06 429.75 -0.30% 429.76 -0.30% 410.74
6 470.30 469.72 -0.12% 469.33 -0.21% 489.74
7 511.49 510.30 -0.23% 510.68 -0.16% 566.63
8 556.10 554.74 -0.25% 554.86 -0.22% 645.39
Q4_0 1 143.05 143.17 +0.08% 143.19 +0.10% 113.76
2 274.28 274.48 +0.08% 274.92 +0.23% 207.62
3 399.13 399.75 +0.16% 399.98 +0.21% 309.20
4 511.55 511.58 +0.01% 512.25 +0.14% 411.85
5 608.34 608.59 +0.04% 610.43 +0.34% 510.00
6 681.34 681.19 -0.02% 682.05 +0.10% 609.28
7 736.07 738.41 +0.32% 737.79 +0.23% 706.98
8 809.84 811.65 +0.22% 812.48 +0.33% 802.98
Q8_0 1 92.56 92.87 +0.34% 92.84 +0.31% 80.99
2 179.67 179.69 +0.01% 179.57 -0.06% 152.46
3 267.35 267.44 +0.03% 267.12 -0.09% 228.02
4 349.65 349.80 +0.04% 350.00 +0.10% 302.97
5 414.78 415.35 +0.14% 415.11 +0.08% 376.84
6 490.57 490.33 -0.05% 490.22 -0.07% 450.80
7 572.38 572.02 -0.06% 572.22 -0.03% 524.53
8 620.49 620.71 +0.04% 620.73 +0.04% 595.30
IQ4_XS 1 141.68 141.58 -0.07% 141.63 -0.04% 118.07
2 277.80 276.99 -0.29% 277.52 -0.10% 214.99
3 406.42 406.59 +0.04% 406.80 +0.09% 322.35
4 520.72 519.88 -0.16% 520.19 -0.10% 427.41
5 634.94 635.20 +0.04% 634.67 -0.04% 531.59
6 692.12 692.06 -0.01% 691.77 -0.05% 634.68
7 791.38 792.50 +0.14% 791.61 +0.03% 736.99
8 832.29 833.64 +0.16% 832.10 -0.02% 834.76

RTX 5090 - Qwen3.6-27B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 74.20 71.25 -3.98% 72.46 -2.35% 58.50
2 137.92 134.68 -2.35% 133.49 -3.21% 105.81
3 194.13 197.77 +1.88% 194.43 +0.16% 157.11
4 221.32 237.63 +7.37% 237.34 +7.24% 208.75
5 245.46 277.38 +13.00% 275.75 +12.34% 256.03
6 254.18 302.84 +19.14% 301.77 +18.72% 301.86
7 266.39 314.58 +18.09% 316.47 +18.80% 350.05
8 279.58 322.84 +15.48% 323.63 +15.76% 396.99
Q5_K 1 63.51 64.53 +1.60% 63.72 +0.32% 50.72
2 119.40 121.10 +1.42% 122.81 +2.86% 94.68
3 173.78 178.08 +2.47% 180.71 +3.99% 141.86
4 209.30 225.90 +7.93% 223.13 +6.61% 184.27
5 238.64 260.73 +9.26% 261.12 +9.42% 228.35
6 243.66 277.89 +14.05% 291.70 +19.72% 275.93
7 260.64 292.01 +12.04% 308.70 +18.44% 313.57
8 267.36 303.68 +13.59% 312.20 +16.77% 359.24
Q2_K 1 92.53 91.97 -0.61% 94.40 +2.02% 64.94
2 160.47 159.12 -0.84% 164.74 +2.66% 112.29
3 197.27 191.93 -2.71% 202.54 +2.67% 167.95
4 229.80 223.35 -2.81% 234.50 +2.05% 222.04
5 257.72 252.43 -2.05% 259.84 +0.82% 275.43
6 261.25 259.43 -0.70% 263.27 +0.77% 326.31
7 278.01 275.52 -0.90% 285.88 +2.83% 370.23
8 282.83 277.20 -1.99% 281.19 -0.58% 422.12
Q3_K 1 68.12 66.84 -1.89% 66.32 -2.65% 55.81
2 127.60 125.74 -1.46% 123.93 -2.87% 107.49
3 176.98 173.54 -1.95% 171.67 -3.00% 160.91
4 216.21 210.26 -2.75% 209.49 -3.10% 213.52
5 246.26 242.20 -1.65% 243.00 -1.32% 263.76
6 267.34 260.66 -2.50% 267.74 +0.15% 314.88
7 279.32 272.19 -2.56% 276.38 -1.05% 365.55
8 283.03 275.75 -2.57% 288.97 +2.10% 414.19
Q6_K 1 55.30 55.16 -0.26% 56.03 +1.32% 46.27
2 106.42 104.94 -1.40% 106.78 +0.34% 84.95
3 155.64 153.73 -1.22% 153.20 -1.57% 126.87
4 197.87 200.61 +1.39% 196.79 -0.55% 162.17
5 220.90 223.62 +1.23% 220.27 -0.29% 204.29
6 244.88 245.51 +0.26% 239.77 -2.09% 249.98
7 254.51 257.70 +1.25% 256.41 +0.75% 290.59
8 267.59 269.21 +0.61% 267.88 +0.11% 330.72
Q4_0 1 73.97 75.87 +2.56% 76.10 +2.88% 58.06
2 142.44 143.02 +0.40% 143.45 +0.71% 103.66
3 212.47 211.98 -0.23% 212.33 -0.06% 155.08
4 270.92 270.72 -0.08% 271.14 +0.08% 205.80
5 326.16 320.36 -1.78% 326.23 +0.02% 250.97
6 377.18 371.55 -1.49% 377.91 +0.19% 302.48
7 412.85 410.00 -0.69% 413.29 +0.11% 353.25
8 441.33 441.75 +0.09% 442.18 +0.19% 402.13
Q8_0 1 46.74 46.70 -0.10% 45.88 -1.84% 39.68
2 89.45 89.51 +0.07% 89.45 -0.00% 74.41
3 133.17 133.26 +0.07% 133.21 +0.03% 111.32
4 176.11 176.16 +0.03% 176.23 +0.07% 147.87
5 209.95 209.98 +0.02% 209.89 -0.03% 183.25
6 245.56 245.61 +0.02% 245.61 +0.02% 219.16
7 279.72 279.60 -0.04% 279.73 +0.00% 254.95
8 317.76 317.74 -0.01% 317.78 +0.01% 290.05
IQ4_XS 1 77.66 77.91 +0.32% 77.95 +0.37% 61.17
2 148.02 148.06 +0.03% 148.08 +0.04% 111.80
3 216.36 216.78 +0.19% 216.72 +0.16% 167.35
4 281.06 281.08 +0.00% 281.07 +0.00% 221.51
5 341.16 340.94 -0.06% 339.89 -0.37% 273.49
6 370.56 370.66 +0.03% 370.19 -0.10% 324.90
7 425.62 425.44 -0.04% 423.20 -0.57% 374.91
8 447.21 447.62 +0.09% 441.55 -1.27% 430.57

RTX 4090

sm_89, 1008 GB/s, driver 591, CUDA 12.9.

RTX 4090 - Llama-3.2-3B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 328.89 329.44 +0.17% 329.01 +0.04% 282.86
2 596.72 601.29 +0.77% 601.70 +0.83% 451.96
3 857.63 868.93 +1.32% 869.27 +1.36% 661.56
4 1069.35 1098.12 +2.69% 1098.25 +2.70% 862.88
5 1239.35 1298.81 +4.80% 1299.01 +4.81% 1050.90
6 1382.71 1505.31 +8.87% 1505.66 +8.89% 1237.40
7 1502.42 1664.05 +10.76% 1663.90 +10.75% 1415.06
8 1560.90 1817.87 +16.46% 1817.88 +16.46% 1589.46
Q5_K 1 289.32 289.35 +0.01% 289.53 +0.07% 252.85
2 521.89 527.90 +1.15% 528.51 +1.27% 414.65
3 757.14 767.41 +1.36% 767.16 +1.32% 608.48
4 957.62 983.70 +2.72% 983.70 +2.72% 795.69
5 1133.12 1187.13 +4.77% 1186.98 +4.75% 969.75
6 1293.71 1372.45 +6.09% 1373.20 +6.14% 1144.46
7 1419.32 1531.57 +7.91% 1532.41 +7.97% 1307.87
8 1501.87 1678.02 +11.73% 1678.02 +11.73% 1469.59
Q2_K 1 435.37 434.37 -0.23% 435.39 +0.00% 360.97
2 750.40 750.14 -0.03% 750.48 +0.01% 545.02
3 982.44 982.46 +0.00% 982.40 -0.00% 794.06
4 1176.57 1180.19 +0.31% 1180.32 +0.32% 1031.80
5 1317.73 1318.32 +0.04% 1318.06 +0.02% 1251.10
6 1474.53 1474.18 -0.02% 1474.14 -0.03% 1466.60
7 1526.74 1527.07 +0.02% 1526.62 -0.01% 1671.94
8 1641.17 1641.50 +0.02% 1640.48 -0.04% 1868.71
Q3_K 1 362.32 362.21 -0.03% 362.27 -0.01% 303.04
2 642.96 643.27 +0.05% 642.95 -0.00% 465.77
3 818.36 818.86 +0.06% 818.36 -0.00% 681.30
4 1012.87 1013.60 +0.07% 1013.52 +0.06% 888.40
5 1254.82 1256.09 +0.10% 1255.04 +0.02% 1081.05
6 1415.44 1415.73 +0.02% 1414.69 -0.05% 1271.61
7 1411.94 1413.28 +0.09% 1412.36 +0.03% 1452.29
8 1530.72 1531.02 +0.02% 1529.05 -0.11% 1629.04
Q6_K 1 254.59 254.48 -0.04% 254.27 -0.13% 221.80
2 474.26 474.10 -0.03% 473.89 -0.08% 356.42
3 690.96 690.69 -0.04% 690.57 -0.06% 524.04
4 895.24 895.32 +0.01% 895.66 +0.05% 686.97
5 1038.06 1037.55 -0.05% 1037.66 -0.04% 840.33
6 1205.40 1204.99 -0.03% 1205.06 -0.03% 993.13
7 1364.63 1363.90 -0.05% 1364.24 -0.03% 1139.07
8 1503.64 1502.82 -0.05% 1503.77 +0.01% 1282.19
Q4_0 1 331.87 331.85 -0.01% 331.27 -0.18% 282.47
2 605.31 604.74 -0.10% 603.89 -0.24% 440.48
3 880.41 879.46 -0.11% 879.89 -0.06% 644.90
4 1132.88 1132.34 -0.05% 1132.19 -0.06% 842.59
5 1355.37 1354.42 -0.07% 1355.38 +0.00% 1027.77
6 1558.27 1557.87 -0.03% 1557.89 -0.02% 1210.37
7 1756.81 1755.15 -0.09% 1756.21 -0.03% 1382.85
8 1948.55 1947.74 -0.04% 1948.52 -0.00% 1552.15
Q8_0 1 212.01 212.06 +0.02% 212.08 +0.03% 190.89
2 394.02 393.87 -0.04% 393.79 -0.06% 323.91
3 578.97 578.81 -0.03% 579.27 +0.05% 476.77
4 754.34 754.23 -0.01% 754.29 -0.01% 625.48
5 911.76 910.99 -0.08% 911.89 +0.02% 767.41
6 1081.67 1081.65 -0.00% 1081.12 -0.05% 907.65
7 1233.53 1233.72 +0.02% 1233.63 +0.01% 1042.96
8 1351.27 1350.95 -0.02% 1350.59 -0.05% 1175.23
IQ4_XS 1 333.58 333.62 +0.01% 333.40 -0.05% 289.68
2 623.01 622.83 -0.03% 622.30 -0.11% 468.73
3 900.57 900.78 +0.02% 900.08 -0.05% 686.72
4 1158.82 1158.90 +0.01% 1159.09 +0.02% 895.67
5 1389.78 1388.60 -0.09% 1388.54 -0.09% 1088.64
6 1609.09 1608.44 -0.04% 1608.93 -0.01% 1280.86
7 1811.61 1811.08 -0.03% 1810.57 -0.06% 1462.02
8 1959.38 1958.15 -0.06% 1956.90 -0.13% 1637.81

RTX 4090 - Llama-3.1-8B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 174.42 174.49 +0.04% 174.61 +0.11% 157.84
2 318.49 325.99 +2.35% 325.76 +2.28% 257.98
3 472.56 477.81 +1.11% 477.85 +1.12% 380.08
4 615.48 624.11 +1.40% 624.04 +1.39% 500.15
5 726.00 743.29 +2.38% 743.56 +2.42% 613.12
6 817.98 881.79 +7.80% 881.53 +7.77% 726.16
7 861.80 996.37 +15.61% 996.67 +15.65% 836.88
8 884.40 1094.17 +23.72% 1094.78 +23.79% 946.16
Q5_K 1 148.82 148.96 +0.09% 148.95 +0.09% 136.77
2 278.84 279.82 +0.35% 279.89 +0.38% 232.52
3 409.45 411.18 +0.42% 410.95 +0.37% 343.02
4 534.74 538.34 +0.67% 537.68 +0.55% 451.65
5 642.47 658.91 +2.56% 658.36 +2.47% 554.91
6 743.15 773.33 +4.06% 772.80 +3.99% 658.08
7 798.70 878.79 +10.03% 878.68 +10.01% 758.81
8 843.21 972.51 +15.33% 972.68 +15.36% 857.42
Q2_K 1 258.02 257.70 -0.12% 257.75 -0.11% 222.46
2 461.56 461.34 -0.05% 461.43 -0.03% 355.43
3 640.71 641.09 +0.06% 641.50 +0.12% 521.96
4 745.34 745.09 -0.03% 745.97 +0.08% 682.91
5 841.16 841.80 +0.08% 842.00 +0.10% 835.09
6 891.77 891.71 -0.01% 891.57 -0.02% 985.85
7 907.94 907.61 -0.04% 907.67 -0.03% 1132.58
8 971.38 972.57 +0.12% 972.15 +0.08% 1274.69
Q3_K 1 206.91 206.83 -0.04% 206.79 -0.06% 180.56
2 383.99 383.78 -0.06% 383.48 -0.13% 267.42
3 496.12 495.97 -0.03% 495.89 -0.05% 393.61
4 610.24 610.07 -0.03% 610.33 +0.01% 517.11
5 758.11 758.02 -0.01% 758.19 +0.01% 634.55
6 842.13 841.79 -0.04% 841.69 -0.05% 752.29
7 837.05 836.97 -0.01% 837.91 +0.10% 865.76
8 889.94 889.83 -0.01% 890.90 +0.11% 977.49
Q6_K 1 128.19 128.18 -0.01% 128.18 -0.01% 117.55
2 241.95 241.88 -0.03% 241.83 -0.05% 190.68
3 356.31 356.33 +0.00% 356.28 -0.01% 282.04
4 469.12 469.14 +0.00% 469.04 -0.02% 371.96
5 560.52 560.50 -0.00% 560.39 -0.02% 458.21
6 655.94 656.24 +0.05% 656.06 +0.02% 544.69
7 763.41 763.82 +0.05% 763.78 +0.05% 629.13
8 851.21 850.89 -0.04% 851.04 -0.02% 711.66
Q4_0 1 175.17 175.22 +0.03% 175.16 -0.00% 157.54
2 327.66 327.89 +0.07% 327.89 +0.07% 263.46
3 479.96 480.01 +0.01% 479.90 -0.01% 388.00
4 627.84 627.74 -0.02% 627.53 -0.05% 510.19
5 754.07 753.95 -0.02% 753.55 -0.07% 625.93
6 897.73 897.84 +0.01% 897.76 +0.00% 741.74
7 1020.99 1020.82 -0.02% 1019.81 -0.12% 854.43
8 1151.58 1152.02 +0.04% 1151.80 +0.02% 963.94
Q8_0 1 103.31 103.34 +0.03% 103.33 +0.02% 97.25
2 198.21 198.26 +0.02% 198.19 -0.01% 175.72
3 291.91 291.92 +0.00% 291.86 -0.02% 260.16
4 384.71 384.71 -0.00% 384.62 -0.02% 343.44
5 462.68 462.35 -0.07% 462.52 -0.04% 423.65
6 551.24 550.58 -0.12% 550.92 -0.06% 503.92
7 631.47 631.20 -0.04% 631.13 -0.05% 582.96
8 724.43 724.06 -0.05% 724.16 -0.04% 660.24
IQ4_XS 1 182.88 182.74 -0.07% 182.68 -0.11% 164.50
2 342.49 342.42 -0.02% 342.34 -0.04% 278.07
3 499.56 499.33 -0.05% 499.22 -0.07% 409.27
4 655.24 655.33 +0.01% 655.20 -0.01% 537.02
5 796.16 796.20 +0.00% 795.87 -0.04% 657.72
6 938.78 938.30 -0.05% 935.42 -0.36% 779.03
7 1067.06 1067.18 +0.01% 1064.76 -0.22% 895.70
8 1187.71 1187.72 +0.00% 1186.49 -0.10% 1011.09

RTX 4090 - gemma-4-12B-it

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 103.04 102.87 -0.17% 102.95 -0.09% 86.06
2 193.56 195.06 +0.77% 195.06 +0.78% 153.33
3 280.30 285.12 +1.72% 284.71 +1.57% 226.00
4 366.94 373.58 +1.81% 373.36 +1.75% 296.61
5 426.42 439.22 +3.00% 439.33 +3.03% 363.44
6 479.09 521.73 +8.90% 522.18 +8.99% 430.08
7 514.05 585.86 +13.97% 586.37 +14.07% 494.24
8 517.05 640.92 +23.96% 641.14 +24.00% 557.76
Q5_K 1 88.77 88.76 -0.01% 88.71 -0.07% 76.82
2 167.04 169.05 +1.21% 169.09 +1.23% 140.98
3 247.14 248.02 +0.35% 247.76 +0.25% 208.34
4 318.03 324.85 +2.15% 324.69 +2.09% 273.68
5 381.50 394.65 +3.45% 394.49 +3.40% 335.66
6 437.13 461.90 +5.67% 461.69 +5.62% 397.71
7 463.47 522.95 +12.84% 523.38 +12.93% 457.31
8 494.87 579.33 +17.07% 579.21 +17.04% 515.83
Q2_K 1 146.50 146.52 +0.02% 146.54 +0.03% 121.08
2 268.13 268.13 +0.00% 268.19 +0.02% 215.01
3 364.64 364.57 -0.02% 364.70 +0.02% 315.78
4 428.75 428.72 -0.01% 428.71 -0.01% 412.46
5 491.20 491.22 +0.00% 491.13 -0.01% 502.80
6 526.12 526.08 -0.01% 526.22 +0.02% 591.70
7 524.89 525.72 +0.16% 524.91 +0.01% 678.00
8 566.21 566.20 -0.00% 565.36 -0.15% 760.87
Q3_K 1 121.15 121.14 -0.00% 121.13 -0.02% 94.12
2 223.33 223.27 -0.03% 223.32 -0.00% 163.61
3 290.50 290.50 +0.00% 290.56 +0.02% 241.03
4 358.46 358.40 -0.02% 358.41 -0.01% 316.21
5 435.45 435.61 +0.04% 435.63 +0.04% 387.43
6 487.27 487.19 -0.02% 487.19 -0.02% 457.60
7 487.27 487.37 +0.02% 487.17 -0.02% 526.06
8 522.07 522.17 +0.02% 522.11 +0.01% 592.51
Q6_K 1 76.76 76.77 +0.01% 76.77 +0.01% 64.74
2 147.16 147.21 +0.03% 147.18 +0.01% 115.37
3 215.69 215.72 +0.01% 215.65 -0.02% 170.80
4 283.44 283.62 +0.06% 283.52 +0.03% 224.73
5 336.85 336.86 +0.00% 336.88 +0.01% 276.67
6 392.66 392.66 +0.00% 392.73 +0.02% 328.28
7 455.01 455.10 +0.02% 454.84 -0.04% 378.53
8 504.30 504.45 +0.03% 504.33 +0.01% 427.15
Q4_0 1 103.09 103.08 -0.01% 103.05 -0.03% 88.05
2 195.87 195.72 -0.08% 195.79 -0.04% 158.52
3 287.00 286.96 -0.01% 286.97 -0.01% 233.66
4 375.21 375.13 -0.02% 375.04 -0.05% 306.83
5 447.34 447.17 -0.04% 447.23 -0.02% 375.92
6 532.30 532.38 +0.02% 532.36 +0.01% 444.10
7 601.78 601.69 -0.01% 601.60 -0.03% 510.71
8 677.83 677.55 -0.04% 677.58 -0.04% 575.28
Q8_0 1 62.64 62.67 +0.04% 62.66 +0.03% 57.76
2 120.97 120.98 +0.01% 120.96 -0.00% 109.46
3 178.12 178.13 +0.01% 178.12 +0.00% 162.11
4 234.47 234.51 +0.02% 234.46 -0.00% 213.62
5 283.54 283.53 -0.00% 283.53 -0.01% 263.38
6 334.77 334.81 +0.01% 334.72 -0.01% 312.86
7 382.93 382.91 -0.00% 382.76 -0.04% 361.07
8 438.75 438.60 -0.03% 438.53 -0.05% 408.36
IQ4_XS 1 106.46 106.53 +0.07% 106.52 +0.06% 93.45
2 204.22 204.31 +0.04% 204.25 +0.01% 173.54
3 298.52 298.52 +0.00% 298.49 -0.01% 255.40
4 389.83 390.03 +0.05% 389.93 +0.03% 334.68
5 471.63 471.92 +0.06% 471.77 +0.03% 409.31
6 550.44 550.01 -0.08% 550.55 +0.02% 483.61
7 624.85 624.86 +0.00% 624.83 -0.00% 555.04
8 691.06 691.28 +0.03% 691.15 +0.01% 623.34

RTX 4090 - Qwen3.6-27B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 51.65 51.98 +0.64% 52.01 +0.71% 44.24
2 97.72 98.33 +0.62% 98.34 +0.64% 72.94
3 143.65 144.67 +0.71% 144.69 +0.72% 108.41
4 187.70 190.39 +1.43% 190.36 +1.41% 143.21
5 220.14 230.72 +4.81% 230.75 +4.82% 176.66
6 247.99 268.45 +8.25% 268.46 +8.25% 210.10
7 260.73 303.74 +16.50% 303.72 +16.49% 243.01
8 270.44 334.03 +23.51% 334.17 +23.57% 275.93
Q5_K 1 44.03 44.09 +0.12% 44.10 +0.15% 38.77
2 82.68 83.99 +1.59% 84.01 +1.61% 67.22
3 123.78 124.28 +0.41% 124.31 +0.43% 99.90
4 161.02 163.39 +1.47% 163.42 +1.49% 132.03
5 192.01 197.46 +2.84% 197.46 +2.84% 162.98
6 223.59 232.51 +3.99% 232.55 +4.01% 193.95
7 243.80 265.73 +8.99% 265.82 +9.03% 224.43
8 256.21 295.94 +15.51% 295.96 +15.51% 254.37
Q2_K 1 76.32 76.34 +0.02% 76.38 +0.07% 63.01
2 139.74 139.76 +0.02% 139.79 +0.04% 106.32
3 196.10 196.05 -0.03% 196.11 +0.00% 157.60
4 231.82 231.95 +0.06% 231.95 +0.06% 207.34
5 262.50 262.42 -0.03% 262.38 -0.04% 254.69
6 273.56 273.32 -0.09% 273.42 -0.05% 302.15
7 283.63 283.52 -0.04% 283.43 -0.07% 348.68
8 299.79 299.66 -0.04% 299.84 +0.02% 393.75
Q3_K 1 61.82 61.84 +0.02% 61.81 -0.03% 49.53
2 115.34 115.38 +0.03% 115.39 +0.04% 77.10
3 156.29 156.30 +0.01% 156.33 +0.02% 114.43
4 194.97 195.03 +0.03% 195.02 +0.02% 151.12
5 236.45 236.43 -0.01% 236.51 +0.02% 186.19
6 261.69 261.25 -0.17% 261.67 -0.01% 221.35
7 261.26 261.03 -0.09% 261.19 -0.03% 255.78
8 278.36 278.13 -0.08% 278.18 -0.07% 289.90
Q4_0 1 51.89 51.88 -0.01% 51.90 +0.03% 44.25
2 98.60 98.61 +0.01% 98.62 +0.02% 77.55
3 146.06 146.09 +0.02% 146.09 +0.02% 115.24
4 191.94 191.99 +0.03% 191.98 +0.02% 152.18
5 233.38 233.37 -0.00% 233.32 -0.03% 187.68
6 276.72 276.77 +0.02% 276.74 +0.01% 223.14
7 316.56 316.51 -0.02% 316.52 -0.01% 258.01
8 354.34 354.36 +0.00% 354.34 -0.00% 292.35
IQ4_XS 1 54.32 54.35 +0.04% 54.34 +0.02% 47.49
2 103.09 103.11 +0.01% 103.12 +0.03% 84.86
3 152.05 152.09 +0.03% 152.15 +0.06% 125.93
4 199.64 199.75 +0.05% 199.70 +0.03% 166.01
5 243.65 243.73 +0.03% 243.75 +0.04% 204.61
6 285.60 285.54 -0.02% 285.57 -0.01% 243.08
7 328.00 327.98 -0.01% 328.09 +0.03% 280.84
8 367.43 367.36 -0.02% 367.41 -0.00% 317.70

Q6_K, Q8_0 not measured here - they exceed this card's memory.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: AI was used to partially assist while making the code edits and to understand the contexts of the code base.

@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 7, 2026
@praneshgo

Copy link
Copy Markdown
Contributor Author

@gaugarg-nv @ORippler can you please review this PR? Thanks.

@ORippler

Copy link
Copy Markdown
Collaborator

We see perf gains from batch size >=4 on RTX 5090 and >=5 on RTX 4090 (more details in the Performance drop down), however we do not see a gain with DGX Spark, and in fact a small regression at batch sizes 4-6, which is why the change is gated off there. The most probable reason for this can be that the memory bandwidth on DGX Spark is much lower than that of RTX 4090 or 5090, and this means even with this optimization there is no effective time to save, since in the original code the unpack was already running while the kernel waits on the weight loads and so was not adding to the total time.

This should be determined/validated/invalidated based on nsight compute. Feel free to ping me offline if you need help interpreting. Intuitively, hoisting=less work, and less work should almost never incur slowdowns

@pich

pich commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

I tested PR #26705 on Qwen3.8-27B, using my custom 5.01 BPW iMatrix/NVFP4 hybrid quant on an RTX PRO 4000 Blackwell SFF 24 GB. On the same 40K-context benchmark, current master averaged 41.76 tok/s, while master + #26705 reached 43.11 tok/s, a +3.22% end-to-end improvement. Acceptance rate and generated output were identical, so in my test this looks like a clean kernel-level speedup with no sampling-quality trade-off

@pich

pich commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

A follow-up to my earlier 40K result: I kept commit 7061f25 from this PR in the final runtime and released the model used for the test.

The isolated five-run A/B was:

master: 41.76 tok/s
master + #26705: 43.11 tok/s
gain: +3.22%

Acceptance remained 78.73% and all response hashes matched, so this was a kernel-level gain rather than a different speculative continuation. The result was smaller than the RTX 5090 number reported here, which makes sense because only part of my mixed quant uses Q5_K. The remaining tensors are mainly NVFP4, Q6_K and Q8_0.

In the later 256K production-profile sweep, the #26001 + #26048 + #26705 bundle reached 45.866 tok/s versus 45.422 for clean b10454, or +0.98%. I am keeping that number separate because it used a different runtime gate.

Hardware: RTX PRO 4000 Blackwell SFF, 24,467 MiB, sm120a, CUDA 12.9.86, driver 610.57.04. Qwen3.8-27B, 5.01 BPW iMatrix/NVFP4 hybrid, embedded MTP, Q4_0 target KV.

Full measurements and arguments:
https://piszczek.pl/blog/qwen38-27b-256k-50-tps-24gb-gpu

GGUF:
https://huggingface.co/cdiamond/Qwen3.8-27B-iMatrix-NVFP4-MTP-GGUF

@praneshgo

Copy link
Copy Markdown
Contributor Author

We see perf gains from batch size >=4 on RTX 5090 and >=5 on RTX 4090 (more details in the Performance drop down), however we do not see a gain with DGX Spark, and in fact a small regression at batch sizes 4-6, which is why the change is gated off there. The most probable reason for this can be that the memory bandwidth on DGX Spark is much lower than that of RTX 4090 or 5090, and this means even with this optimization there is no effective time to save, since in the original code the unpack was already running while the kernel waits on the weight loads and so was not adding to the total time.

This should be determined/validated/invalidated based on nsight compute. Feel free to ping me offline if you need help interpreting. Intuitively, hoisting=less work, and less work should almost never incur slowdowns

I looked at q4k_n5_base (no changes) and q4k_n5_brchless (changes made in this PR) ncu-rep files as an example to better identify reasons for no gain in perf on DGX Spark. n here denotes number of matmul cols (also same as ne11). For this testing, I did not use the CUDA_ARCH == GGML_CUDA_CC_DGX_SPARK conditional used in the PR, so as to see the true branchless behavior on DGX Spark.

The number of executed instructions go down from ~32 mil (base) to ~23 mil (branchless) as expected. However, the number of elapsed cycles as per the ncu-rep files largely remained the same: 465,637 (base) → 453,280 (branchless) in spite of close to 30% fewer instructions. That 2.7% difference is also about the launch-to-launch spread I see on the same binary, so it is within noise.

The issue slots busy % (% of peak sustained active) reduced from ~36% to ~26% and warp cycles per issued instruction go from 9.59 (base) to 14.69 (branchless). This means kernel issues less often and waits longer per instruction. Even if we free some cycles by optimizing the unpack, they just become part of the stall.

@praneshgo
praneshgo marked this pull request as ready for review August 19, 2026 05:43
@praneshgo
praneshgo requested a review from a team as a code owner August 19, 2026 05:43
@ORippler

Copy link
Copy Markdown
Collaborator

The number of executed instructions go down from ~32 mil (base) to ~23 mil (branchless) as expected. However, the number of elapsed cycles as per the ncu-rep files largely remained the same: 465,637 (base) → 453,280 (branchless) in spite of close to 30% fewer instructions. That 2.7% difference is also about the launch-to-launch spread I see on the same binary, so it is within noise.

So if we are not regressing on DGX/RTX Spark, we should enable this as it will increase power-efficiency of the system (stalling is cheaper than issuing an instruction, aka every instruction counts)

@praneshgo

praneshgo commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

The number of executed instructions go down from ~32 mil (base) to ~23 mil (branchless) as expected. However, the number of elapsed cycles as per the ncu-rep files largely remained the same: 465,637 (base) → 453,280 (branchless) in spite of close to 30% fewer instructions. That 2.7% difference is also about the launch-to-launch spread I see on the same binary, so it is within noise.

So if we are not regressing on DGX/RTX Spark, we should enable this as it will increase power-efficiency of the system (stalling is cheaper than issuing an instruction, aka every instruction counts)

I am in fact seeing a very slight decline in perf if we add this change on DGX Spark (around 2-3%). I ran a few experiments by locking and unlocking clocks, checked by enabling/disabling graphs and checked if coalescing is responsible for this drop, seems like none of them explain it completely. So, until this is figured out, it may be better to keep this change gated for DGX Spark.

@praneshgo
praneshgo force-pushed the pgonegandla/mmvq-q4k-q5k-branchless branch from 7061f25 to 3d77a86 Compare August 26, 2026 08:49
@praneshgo praneshgo changed the title CUDA: Update Q4_K and Q5_K to use branchless computation, which stops the scale unpack being re-executed for every column in mmvq, improving perf at batch sizes > 1 CUDA: Adding Spark to use prefetch and update Q4_K and Q5_K to use branchless computation, which stops the scale unpack being re-executed for every column in mmvq, improving perf at batch sizes > 1 Aug 27, 2026
@praneshgo

Copy link
Copy Markdown
Contributor Author

To avoid the dip due to branchless change alone and ensure an overall gain, we make Spark use prefetch. This in our results ensured increased decode throughput across several quant types which can be evident from the performance numbers below. Prefetch while improving decode throughput on DGX Spark, seemed to negatively contributed in case of GPUs with larger bandwidth like RTX 5090.

We analyzed ncu traces with prefetch enabled on RTX 5090, profiling Q8_0 on Llama-3.1-8B across ne11 1-8, with Q2_K as a control:

  • The prefetch does what it is intended to do: long_scoreboard drops on both parts.
  • However, each prefetch.global.L2 is still a global memory instruction taking an LSU slot and a queue entry, so lg_throttle goes up with it.
  • Spark has much more latency to hide in the first place, and long_scoreboard runs 1.5-2.3x higher at every ne11. It pays more queue pressure than the 5090 does, but it has enough to convert to cover it.
  • Larger ne11 kills the benefit but not the cost. Each weight gets reused across more columns, so the kernel stops being latency-bound (long_scoreboard 41.2 -> 7.9 on the 5090 going from ne11 1 to 8), while the prefetch still issues the same requests per loop iteration.
  • By ne11=8 it isn't hiding anything on the 5090, just adding instructions — long_scoreboard actually goes up there (7.90 -> 8.16) while on Spark it still drops (18.13 -> 12.22). That's where the worst non-Spark regression sits.
  • Net: +4.81% median on Spark, -1.39% on the 4090, -1.57% on the 5090.

Improvement in mmvq performance means that switch points in #26079 needs changes, which are also done in this PR.

@gaugarg-nv gaugarg-nv 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.

The change looks good to me. Can you see how this impacts SpecDec perf, specifically measure MTP and Dflash2 with Qwen3.6-35 and Qwen3.8-27B?

Comment thread ggml/src/ggml-cuda/mmvq.cu Outdated
// Q2_K is left out: prefetching does not raise its L2 hit rate, so the requests only add pressure

static __device__ __forceinline__ void mmvq_prefetch_l2(const void * p) {
#if !defined(GGML_USE_HIP)

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.

We should also add check for MUSA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Added the MUSA check in the latest commit.

Comment thread ggml/src/ggml-cuda/mmvq.cu Outdated
// Q2_K is left out: prefetching does not raise its L2 hit rate, so the requests only add pressure

static __device__ __forceinline__ void mmvq_prefetch_l2(const void * p) {
#if !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA)

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.

Non-spark CUDA build fails too with warning #177-D: function "mmvq_prefetch_l2" was declared but never referenced.

Moving the helper under the same NVIDIA Spark architecture guard would remove the warning and also avoid exposing PTX to HIP/MUSA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checking the errors. Will fix soon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the code by defining the mmvq L2 prefetch only under the Spark guard as per the suggestion. This should ideally fix the build warning/failure.

@praneshgo
praneshgo force-pushed the pgonegandla/mmvq-q4k-q5k-branchless branch from 134360d to 63daa18 Compare August 31, 2026 16:01
@praneshgo

praneshgo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

The change looks good to me. Can you see how this impacts SpecDec perf, specifically measure MTP and Dflash2 with Qwen3.6-35 and Qwen3.8-27B?

Measured the speculative decoding impact as asked.

End-to-end decode throughput through llama-server, 6 prompts of 256 tokens, temperature 0 and a fixed seed, on three models: Qwen3.5-9B (mtp9) and Qwen3.6-27B (mtp27) with MTP, and Qwen3.8-27B with a DFlash2 draft, all Q4_K_M. Both arms share a base commit and differ only by this PR's two files, each with its own switch points active. These are upgrade numbers, not isolated kernel measurements.

Performance

Update: the RTX 5090 numbers below were measured with Q4_K switch point <= 6. That switch point is now back to 5 — see comment-5507374664 for the updated 5090 table. GB10 and 4090 are unaffected, as the change is inside the Blackwell block only.

RTX 5090

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 +0.49% +0.62% +0.66%
3 +1.17% +2.70% +2.08%
4 +3.85% +6.06% +5.25%
6 +2.07% +2.47% -7.13%
8 -0.78% +0.97% +0.15%

DGX Spark GB10

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 +1.34% +1.93% +2.43%
3 +1.74% +4.52% +4.34%
4 +2.91% +3.47% +3.75%
6 +4.83% +6.43% +6.17%
8 +3.46% +7.94% +7.61%

RTX 4090

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 -0.01% +0.71% +0.22%
3 +0.32% +0.97% -0.11%
4 +0.41% +0.48% +0.02%
6 -0.66% +2.27% +2.13%
8 +14.36% +6.10% +8.87%

The three architectures do not gain in the same place, and each one tracks its own switch points.

Blackwell peaks at ne11 = 4, where both arms are on the vector kernel and the only difference is the branchless unpack. By 8 both arms have moved to MMQ, which is why the row at 8 is flat.

Ada is flat through 4 and jumps at 8. The per-type sweeps put the branchless gain at +0.7 to +2.7% at batch 4 but +12 to +24% at batch 8, so nothing shows until verification reaches the top of the range. DFlash2 runs there by default - its trained block size is 8, so that is where it verifies unless the draft length is capped below it.

GB10 climbs steadily and never jumps, since no switch point moves on that part. An isolation build with only the branchless unpack gives +1.73% of the +2.91% on mtp9 at ne11 = 4, and +3.05% of the +7.61% on dflash2 at 8, so the prefetch supplies the rest and its share grows with batch.

ne11 = 6 on Blackwell is the one batch where the two arms run different kernels: master caps Q4_K/Q5_K at <= 5 and sends batch 6 to MMQ, while this PR keeps the vector kernel through 6. The dflash2 target prefers MMQ there, so it loses; the two MTP configs do not, and stay positive.

mmvq was the default to begin with, for ne11 <= 8, and a switch point is a carve-out handing specific types to MMQ, taken only when no tested model still prefers the vector kernel. One table has to serve every model, so the switch point is the greatest of the per-model switch points for that quant. The kernel got faster, so the cap moved. The criterion did not change.

@gaugarg-nv please review.

@gaugarg-nv

Copy link
Copy Markdown
Contributor

Do I understand correctly that ne11 == draft_length + 1?

What is causing perf regression in dflash2 for ne11 =6?
Is AR across these runs same? I want to make sure perf difference is due to change in kernel and not due to different AR.

@praneshgo

praneshgo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

On RTX 5090, after moving the Q4_K switch point back to 5 (was 6 earlier in the PR), the 7% dip seen in case of Qwen3.8-27B(dflash2) now becomes close to 0. Perf numbers on other tested HW, including DGX Spark and 4090, remain unchanged and are mentioned in the description as well as comment-5492301911

End-to-end decode throughput, this PR vs master, measured through llama-server.

GPU Qwen3.5-9B (mtp, draft len 3 => ne11=4) Qwen3.6-27B (mtp, draft len 3 => ne11=4) Qwen3.8-27B (dflash2, draft len 7 => ne11=8)
RTX 5090 +3.99% +5.71% -0.43%
DGX Spark GB10 +2.91% +3.47% +7.61%
RTX 4090 +0.41% +0.48% +8.87%
Detailed Performance results

RTX 5090

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 +0.94% +0.89% +0.73%
3 +1.28% +2.52% +2.46%
4 +3.99% +5.71% +5.70%
6 -1.43% +4.94% -0.19%
8 -0.32% +0.02% -0.43%

Mentioning DGX Spark and 4090 results, which are the same as those from comment-5492301911, so that all data is in one place.

DGX Spark GB10

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 +1.34% +1.93% +2.43%
3 +1.74% +4.52% +4.34%
4 +2.91% +3.47% +3.75%
6 +4.83% +6.43% +6.17%
8 +3.46% +7.94% +7.61%

RTX 4090

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 -0.01% +0.71% +0.22%
3 +0.32% +0.97% -0.11%
4 +0.41% +0.48% +0.02%
6 -0.66% +2.27% +2.13%
8 +14.36% +6.10% +8.87%

@gaugarg-nv

Copy link
Copy Markdown
Contributor

Performance improvements are solid for Nvidia GPUs.
@ggml-org/ggml-hip could you please test it on AMD GPUs?

@gaugarg-nv

Copy link
Copy Markdown
Contributor

@IMbackK Possible for you test it on AMD GPUs?

@IMbackK IMbackK self-assigned this Sep 3, 2026
Comment thread ggml/src/ggml-cuda/mmvq.cu Outdated
case GGML_TYPE_Q4_K:
case GGML_TYPE_Q5_K:
return ne11 <= 7;
// branchless unpack pushes Q4_K and Q5_K past the cap, so they now take the default

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.

this kind of comment should be avoided

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this and another comment of the same kind in the latest commit.

@IMbackK

IMbackK commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Its perf positve on HIP

Details
GPU Model Microbatch size Test t/s master t/s pgonegandla/mmvq-q4k-q5k-branchless Speedup
MI100 gemma4 26B.A4B Q6_K 1 pp128 81.75 91.20 1.12
MI100 gemma4 26B.A4B Q6_K 2 pp128 140.83 156.30 1.11
MI100 gemma4 26B.A4B Q6_K 4 pp128 155.24 179.94 1.16
MI100 gemma4 26B.A4B Q6_K 7 pp128 191.62 219.86 1.15
MI100 gemma4 26B.A4B Q6_K 8 pp128 215.52 235.29 1.09
MI100 gpt-oss 20B MXFP4 MoE 1 pp128 143.08 159.31 1.11
MI100 gpt-oss 20B MXFP4 MoE 2 pp128 203.35 230.16 1.13
MI100 gpt-oss 20B MXFP4 MoE 4 pp128 252.78 279.80 1.11
MI100 gpt-oss 20B MXFP4 MoE 7 pp128 261.86 292.02 1.12
MI100 gpt-oss 20B MXFP4 MoE 8 pp128 284.86 317.40 1.11
MI100 lfm2moe 8B.A1B F16 1 pp128 183.20 183.58 1.00
MI100 lfm2moe 8B.A1B F16 2 pp128 237.81 238.36 1.00
MI100 lfm2moe 8B.A1B F16 4 pp128 261.75 261.48 1.00
MI100 lfm2moe 8B.A1B F16 7 pp128 306.99 308.35 1.00
MI100 lfm2moe 8B.A1B F16 8 pp128 318.33 319.62 1.00
MI100 lfm2moe 8B.A1B Q4_0 1 pp128 304.77 300.68 0.99
MI100 lfm2moe 8B.A1B Q4_0 2 pp128 488.01 480.00 0.98
MI100 lfm2moe 8B.A1B Q4_0 4 pp128 509.93 508.14 1.00
MI100 lfm2moe 8B.A1B Q4_0 7 pp128 660.71 655.81 0.99
MI100 lfm2moe 8B.A1B Q4_0 8 pp128 711.23 704.86 0.99
MI100 lfm2moe 8B.A1B Q4_K_M 1 pp128 265.58 265.65 1.00
MI100 lfm2moe 8B.A1B Q4_K_M 2 pp128 387.33 405.90 1.05
MI100 lfm2moe 8B.A1B Q4_K_M 4 pp128 417.79 420.13 1.01
MI100 lfm2moe 8B.A1B Q4_K_M 7 pp128 543.10 542.23 1.00
MI100 lfm2moe 8B.A1B Q4_K_M 8 pp128 602.87 597.89 0.99
MI100 lfm2moe 8B.A1B Q5_K_M 1 pp128 249.43 248.22 1.00
MI100 lfm2moe 8B.A1B Q5_K_M 2 pp128 367.97 384.98 1.05
MI100 lfm2moe 8B.A1B Q5_K_M 4 pp128 391.55 395.56 1.01
MI100 lfm2moe 8B.A1B Q5_K_M 7 pp128 491.41 505.45 1.03
MI100 lfm2moe 8B.A1B Q5_K_M 8 pp128 541.59 557.09 1.03
MI100 lfm2moe 8B.A1B Q6_K 1 pp128 232.27 230.73 0.99
MI100 lfm2moe 8B.A1B Q6_K 2 pp128 356.03 350.37 0.98
MI100 lfm2moe 8B.A1B Q6_K 4 pp128 380.35 373.54 0.98
MI100 lfm2moe 8B.A1B Q6_K 7 pp128 448.37 443.39 0.99
MI100 lfm2moe 8B.A1B Q6_K 8 pp128 491.12 483.40 0.98
MI100 lfm2moe 8B.A1B Q8_0 1 pp128 255.42 257.42 1.01
MI100 lfm2moe 8B.A1B Q8_0 2 pp128 384.44 384.90 1.00
MI100 lfm2moe 8B.A1B Q8_0 4 pp128 421.99 424.40 1.01
MI100 lfm2moe 8B.A1B Q8_0 7 pp128 535.66 536.27 1.00
MI100 lfm2moe 8B.A1B Q8_0 8 pp128 586.52 588.84 1.00
MI100 llama 8B Q2_K_M 1 pp128 99.42 99.95 1.01
MI100 llama 8B Q2_K_M 2 pp128 139.45 141.00 1.01
MI100 llama 8B Q2_K_M 4 pp128 193.81 195.01 1.01
MI100 llama 8B Q2_K_M 7 pp128 326.61 329.40 1.01
MI100 llama 8B Q2_K_M 8 pp128 380.67 383.90 1.01
MI100 llama 8B Q3_K_M 1 pp128 91.70 93.03 1.01
MI100 llama 8B Q3_K_M 2 pp128 131.57 142.21 1.08
MI100 llama 8B Q3_K_M 4 pp128 211.61 214.91 1.02
MI100 llama 8B Q3_K_M 7 pp128 348.23 352.87 1.01
MI100 llama 8B Q3_K_M 8 pp128 407.08 412.31 1.01
MI100 llama 8B Q4_0 1 pp128 100.79 123.24 1.22
MI100 llama 8B Q4_0 2 pp128 171.87 195.85 1.14
MI100 llama 8B Q4_0 4 pp128 252.21 264.36 1.05
MI100 llama 8B Q4_0 7 pp128 326.70 331.05 1.01
MI100 llama 8B Q4_0 8 pp128 383.35 388.22 1.01
MI100 llama 8B Q4_K_M 1 pp128 93.21 103.09 1.11
MI100 llama 8B Q4_K_M 2 pp128 126.16 166.18 1.32
MI100 llama 8B Q4_K_M 4 pp128 216.07 231.69 1.07
MI100 llama 8B Q4_K_M 7 pp128 343.35 370.57 1.08
MI100 llama 8B Q4_K_M 8 pp128 403.07 430.50 1.07
MI100 llama 8B Q5_K_M 1 pp128 85.23 91.72 1.08
MI100 llama 8B Q5_K_M 2 pp128 116.22 154.87 1.33
MI100 llama 8B Q5_K_M 4 pp128 200.91 222.48 1.11
MI100 llama 8B Q5_K_M 7 pp128 316.71 355.13 1.12
MI100 llama 8B Q5_K_M 8 pp128 370.16 413.64 1.12
MI100 llama 8B Q6_K 1 pp128 73.68 77.33 1.05
MI100 llama 8B Q6_K 2 pp128 125.88 132.85 1.06
MI100 llama 8B Q6_K 4 pp128 181.16 190.83 1.05
MI100 llama 8B Q6_K 7 pp128 263.97 282.25 1.07
MI100 llama 8B Q6_K 8 pp128 306.62 326.95 1.07
MI100 llama 8B Q8_0 1 pp128 76.53 77.49 1.01
MI100 llama 8B Q8_0 2 pp128 135.33 137.65 1.02
MI100 llama 8B Q8_0 4 pp128 209.04 213.67 1.02
MI100 llama 8B Q8_0 7 pp128 292.00 306.70 1.05
MI100 llama 8B Q8_0 8 pp128 337.99 351.09 1.04
MI100 qwen35 27B Q5_K_M 1 pp128 22.79 23.78 1.04
MI100 qwen35 27B Q5_K_M 2 pp128 34.48 40.43 1.17
MI100 qwen35 27B Q5_K_M 4 pp128 58.98 59.79 1.01
MI100 qwen35 27B Q5_K_M 7 pp128 87.53 89.38 1.02
MI100 qwen35 27B Q5_K_M 8 pp128 102.10 103.07 1.01
GPU Model Microbatch size Test t/s master t/s pgonegandla/mmvq-q4k-q5k-branchless Speedup
RX 7900 XTX gemma4 26B.A4B Q6_K 1 pp128 99.31 99.86 1.01
RX 7900 XTX gemma4 26B.A4B Q6_K 2 pp128 194.06 195.59 1.01
RX 7900 XTX gemma4 26B.A4B Q6_K 4 pp128 310.55 311.32 1.00
RX 7900 XTX gemma4 26B.A4B Q6_K 7 pp128 401.88 402.90 1.00
RX 7900 XTX gemma4 26B.A4B Q6_K 8 pp128 443.91 447.52 1.01
RX 7900 XTX gpt-oss 20B MXFP4 MoE 1 pp128 191.31 192.17 1.00
RX 7900 XTX gpt-oss 20B MXFP4 MoE 2 pp128 301.22 300.27 1.00
RX 7900 XTX gpt-oss 20B MXFP4 MoE 4 pp128 471.01 473.06 1.00
RX 7900 XTX gpt-oss 20B MXFP4 MoE 7 pp128 596.76 601.40 1.01
RX 7900 XTX gpt-oss 20B MXFP4 MoE 8 pp128 641.92 643.05 1.00
RX 7900 XTX lfm2moe 8B.A1B F16 1 pp128 186.42 186.64 1.00
RX 7900 XTX lfm2moe 8B.A1B F16 2 pp128 246.87 248.05 1.00
RX 7900 XTX lfm2moe 8B.A1B F16 4 pp128 333.11 333.02 1.00
RX 7900 XTX lfm2moe 8B.A1B F16 7 pp128 387.94 388.37 1.00
RX 7900 XTX lfm2moe 8B.A1B F16 8 pp128 404.29 405.31 1.00
RX 7900 XTX lfm2moe 8B.A1B Q4_0 1 pp128 287.13 287.80 1.00
RX 7900 XTX lfm2moe 8B.A1B Q4_0 2 pp128 552.44 553.50 1.00
RX 7900 XTX lfm2moe 8B.A1B Q4_0 4 pp128 948.00 953.65 1.01
RX 7900 XTX lfm2moe 8B.A1B Q4_0 7 pp128 1272.61 1274.40 1.00
RX 7900 XTX lfm2moe 8B.A1B Q4_0 8 pp128 1412.44 1420.31 1.01
RX 7900 XTX lfm2moe 8B.A1B Q4_K_M 1 pp128 294.69 307.29 1.04
RX 7900 XTX lfm2moe 8B.A1B Q4_K_M 2 pp128 466.96 511.58 1.10
RX 7900 XTX lfm2moe 8B.A1B Q4_K_M 4 pp128 692.23 828.07 1.20
RX 7900 XTX lfm2moe 8B.A1B Q4_K_M 7 pp128 899.19 951.33 1.06
RX 7900 XTX lfm2moe 8B.A1B Q4_K_M 8 pp128 996.45 1061.90 1.07
RX 7900 XTX lfm2moe 8B.A1B Q5_K_M 1 pp128 283.68 291.73 1.03
RX 7900 XTX lfm2moe 8B.A1B Q5_K_M 2 pp128 449.50 482.36 1.07
RX 7900 XTX lfm2moe 8B.A1B Q5_K_M 4 pp128 659.81 764.74 1.16
RX 7900 XTX lfm2moe 8B.A1B Q5_K_M 7 pp128 882.80 938.30 1.06
RX 7900 XTX lfm2moe 8B.A1B Q5_K_M 8 pp128 979.20 1043.73 1.07
RX 7900 XTX lfm2moe 8B.A1B Q6_K 1 pp128 270.89 271.34 1.00
RX 7900 XTX lfm2moe 8B.A1B Q6_K 2 pp128 441.72 441.15 1.00
RX 7900 XTX lfm2moe 8B.A1B Q6_K 4 pp128 668.42 666.73 1.00
RX 7900 XTX lfm2moe 8B.A1B Q6_K 7 pp128 755.36 761.09 1.01
RX 7900 XTX lfm2moe 8B.A1B Q6_K 8 pp128 840.68 847.20 1.01
RX 7900 XTX lfm2moe 8B.A1B Q8_0 1 pp128 263.64 261.82 0.99
RX 7900 XTX lfm2moe 8B.A1B Q8_0 2 pp128 421.75 419.71 1.00
RX 7900 XTX lfm2moe 8B.A1B Q8_0 4 pp128 674.03 670.84 1.00
RX 7900 XTX lfm2moe 8B.A1B Q8_0 7 pp128 915.58 909.58 0.99
RX 7900 XTX lfm2moe 8B.A1B Q8_0 8 pp128 1012.45 1005.53 0.99
RX 7900 XTX llama 8B Q2_K_M 1 pp128 143.96 144.86 1.01
RX 7900 XTX llama 8B Q2_K_M 2 pp128 219.50 221.80 1.01
RX 7900 XTX llama 8B Q2_K_M 4 pp128 302.99 306.84 1.01
RX 7900 XTX llama 8B Q2_K_M 7 pp128 356.84 362.93 1.02
RX 7900 XTX llama 8B Q2_K_M 8 pp128 374.18 380.13 1.02
RX 7900 XTX llama 8B Q3_K_M 1 pp128 115.86 124.49 1.07
RX 7900 XTX llama 8B Q3_K_M 2 pp128 196.79 210.85 1.07
RX 7900 XTX llama 8B Q3_K_M 4 pp128 274.43 308.64 1.12
RX 7900 XTX llama 8B Q3_K_M 7 pp128 337.13 378.93 1.12
RX 7900 XTX llama 8B Q3_K_M 8 pp128 357.76 403.66 1.13
RX 7900 XTX llama 8B Q4_0 1 pp128 137.33 137.65 1.00
RX 7900 XTX llama 8B Q4_0 2 pp128 255.22 255.47 1.00
RX 7900 XTX llama 8B Q4_0 4 pp128 435.15 435.11 1.00
RX 7900 XTX llama 8B Q4_0 7 pp128 603.01 600.94 1.00
RX 7900 XTX llama 8B Q4_0 8 pp128 637.94 641.29 1.01
RX 7900 XTX llama 8B Q4_K_M 1 pp128 114.97 127.41 1.11
RX 7900 XTX llama 8B Q4_K_M 2 pp128 193.51 221.70 1.15
RX 7900 XTX llama 8B Q4_K_M 4 pp128 256.77 320.29 1.25
RX 7900 XTX llama 8B Q4_K_M 7 pp128 310.02 389.11 1.26
RX 7900 XTX llama 8B Q4_K_M 8 pp128 324.16 409.78 1.26
RX 7900 XTX llama 8B Q5_K_M 1 pp128 108.04 114.04 1.06
RX 7900 XTX llama 8B Q5_K_M 2 pp128 183.83 203.53 1.11
RX 7900 XTX llama 8B Q5_K_M 4 pp128 250.77 306.40 1.22
RX 7900 XTX llama 8B Q5_K_M 7 pp128 300.34 375.54 1.25
RX 7900 XTX llama 8B Q5_K_M 8 pp128 314.44 397.43 1.26
RX 7900 XTX llama 8B Q6_K 1 pp128 104.97 104.41 0.99
RX 7900 XTX llama 8B Q6_K 2 pp128 180.08 178.55 0.99
RX 7900 XTX llama 8B Q6_K 4 pp128 277.57 276.42 1.00
RX 7900 XTX llama 8B Q6_K 7 pp128 348.25 344.75 0.99
RX 7900 XTX llama 8B Q6_K 8 pp128 372.58 367.37 0.99
RX 7900 XTX llama 8B Q8_0 1 pp128 90.94 90.88 1.00
RX 7900 XTX llama 8B Q8_0 2 pp128 164.45 164.08 1.00
RX 7900 XTX llama 8B Q8_0 4 pp128 297.70 296.59 1.00
RX 7900 XTX llama 8B Q8_0 7 pp128 459.32 457.33 1.00
RX 7900 XTX llama 8B Q8_0 8 pp128 513.16 514.20 1.00
RX 7900 XTX qwen35 27B Q5_K_M 1 pp128 30.82 31.42 1.02
RX 7900 XTX qwen35 27B Q5_K_M 2 pp128 53.97 56.58 1.05
RX 7900 XTX qwen35 27B Q5_K_M 4 pp128 78.61 88.00 1.12
RX 7900 XTX qwen35 27B Q5_K_M 7 pp128 94.95 108.18 1.14
RX 7900 XTX qwen35 27B Q5_K_M 8 pp128 99.16 113.86 1.15
GPU Model Microbatch size Test t/s master t/s pgonegandla/mmvq-q4k-q5k-branchless Speedup
AI PRO R9700 gemma4 26B.A4B Q6_K 1 pp128 91.78 91.91 1.00
AI PRO R9700 gemma4 26B.A4B Q6_K 2 pp128 163.82 163.96 1.00
AI PRO R9700 gemma4 26B.A4B Q6_K 4 pp128 265.80 266.79 1.00
AI PRO R9700 gemma4 26B.A4B Q6_K 7 pp128 364.48 367.09 1.01
AI PRO R9700 gemma4 26B.A4B Q6_K 8 pp128 408.27 409.74 1.00
AI PRO R9700 gpt-oss 20B MXFP4 MoE 1 pp128 166.81 166.89 1.00
AI PRO R9700 gpt-oss 20B MXFP4 MoE 2 pp128 258.71 259.68 1.00
AI PRO R9700 gpt-oss 20B MXFP4 MoE 4 pp128 394.98 395.51 1.00
AI PRO R9700 gpt-oss 20B MXFP4 MoE 7 pp128 549.32 551.29 1.00
AI PRO R9700 gpt-oss 20B MXFP4 MoE 8 pp128 612.45 613.96 1.00
AI PRO R9700 lfm2moe 8B.A1B F16 1 pp128 150.58 150.61 1.00
AI PRO R9700 lfm2moe 8B.A1B F16 2 pp128 204.77 206.32 1.01
AI PRO R9700 lfm2moe 8B.A1B F16 4 pp128 258.46 261.33 1.01
AI PRO R9700 lfm2moe 8B.A1B F16 7 pp128 301.37 304.02 1.01
AI PRO R9700 lfm2moe 8B.A1B F16 8 pp128 313.00 315.74 1.01
AI PRO R9700 lfm2moe 8B.A1B Q4_0 1 pp128 298.63 299.93 1.00
AI PRO R9700 lfm2moe 8B.A1B Q4_0 2 pp128 450.43 452.52 1.00
AI PRO R9700 lfm2moe 8B.A1B Q4_0 4 pp128 748.50 754.18 1.01
AI PRO R9700 lfm2moe 8B.A1B Q4_0 7 pp128 1042.42 1051.39 1.01
AI PRO R9700 lfm2moe 8B.A1B Q4_0 8 pp128 1071.32 1080.89 1.01
AI PRO R9700 lfm2moe 8B.A1B Q4_K_M 1 pp128 244.17 284.84 1.17
AI PRO R9700 lfm2moe 8B.A1B Q4_K_M 2 pp128 446.35 444.79 1.00
AI PRO R9700 lfm2moe 8B.A1B Q4_K_M 4 pp128 678.75 723.50 1.07
AI PRO R9700 lfm2moe 8B.A1B Q4_K_M 7 pp128 859.71 902.73 1.05
AI PRO R9700 lfm2moe 8B.A1B Q4_K_M 8 pp128 943.38 1006.99 1.07
AI PRO R9700 lfm2moe 8B.A1B Q5_K_M 1 pp128 242.42 276.29 1.14
AI PRO R9700 lfm2moe 8B.A1B Q5_K_M 2 pp128 409.42 408.46 1.00
AI PRO R9700 lfm2moe 8B.A1B Q5_K_M 4 pp128 633.82 667.18 1.05
AI PRO R9700 lfm2moe 8B.A1B Q5_K_M 7 pp128 827.27 867.31 1.05
AI PRO R9700 lfm2moe 8B.A1B Q5_K_M 8 pp128 915.40 966.68 1.06
AI PRO R9700 lfm2moe 8B.A1B Q6_K 1 pp128 254.55 256.00 1.01
AI PRO R9700 lfm2moe 8B.A1B Q6_K 2 pp128 377.00 377.42 1.00
AI PRO R9700 lfm2moe 8B.A1B Q6_K 4 pp128 568.49 571.46 1.01
AI PRO R9700 lfm2moe 8B.A1B Q6_K 7 pp128 712.81 717.85 1.01
AI PRO R9700 lfm2moe 8B.A1B Q6_K 8 pp128 790.01 797.10 1.01
AI PRO R9700 lfm2moe 8B.A1B Q8_0 1 pp128 235.91 236.29 1.00
AI PRO R9700 lfm2moe 8B.A1B Q8_0 2 pp128 336.39 336.70 1.00
AI PRO R9700 lfm2moe 8B.A1B Q8_0 4 pp128 550.51 550.14 1.00
AI PRO R9700 lfm2moe 8B.A1B Q8_0 7 pp128 747.58 751.87 1.01
AI PRO R9700 lfm2moe 8B.A1B Q8_0 8 pp128 857.22 859.19 1.00
AI PRO R9700 llama 8B Q2_K_M 1 pp128 115.93 116.89 1.01
AI PRO R9700 llama 8B Q2_K_M 2 pp128 186.49 187.86 1.01
AI PRO R9700 llama 8B Q2_K_M 4 pp128 263.74 266.24 1.01
AI PRO R9700 llama 8B Q2_K_M 7 pp128 314.43 318.47 1.01
AI PRO R9700 llama 8B Q2_K_M 8 pp128 326.94 329.89 1.01
AI PRO R9700 llama 8B Q3_K_M 1 pp128 102.53 105.04 1.02
AI PRO R9700 llama 8B Q3_K_M 2 pp128 167.28 170.24 1.02
AI PRO R9700 llama 8B Q3_K_M 4 pp128 249.71 267.52 1.07
AI PRO R9700 llama 8B Q3_K_M 7 pp128 303.51 332.07 1.09
AI PRO R9700 llama 8B Q3_K_M 8 pp128 317.56 348.75 1.10
AI PRO R9700 llama 8B Q4_0 1 pp128 117.99 117.85 1.00
AI PRO R9700 llama 8B Q4_0 2 pp128 189.82 190.23 1.00
AI PRO R9700 llama 8B Q4_0 4 pp128 349.24 350.42 1.00
AI PRO R9700 llama 8B Q4_0 7 pp128 429.20 431.94 1.01
AI PRO R9700 llama 8B Q4_0 8 pp128 431.99 434.77 1.01
AI PRO R9700 llama 8B Q4_K_M 1 pp128 104.89 110.13 1.05
AI PRO R9700 llama 8B Q4_K_M 2 pp128 175.99 175.75 1.00
AI PRO R9700 llama 8B Q4_K_M 4 pp128 247.45 283.95 1.15
AI PRO R9700 llama 8B Q4_K_M 7 pp128 289.37 347.98 1.20
AI PRO R9700 llama 8B Q4_K_M 8 pp128 300.12 362.35 1.21
AI PRO R9700 llama 8B Q5_K_M 1 pp128 96.02 98.01 1.02
AI PRO R9700 llama 8B Q5_K_M 2 pp128 161.85 162.49 1.00
AI PRO R9700 llama 8B Q5_K_M 4 pp128 238.77 272.64 1.14
AI PRO R9700 llama 8B Q5_K_M 7 pp128 280.94 335.15 1.19
AI PRO R9700 llama 8B Q5_K_M 8 pp128 288.83 351.43 1.22
AI PRO R9700 llama 8B Q6_K 1 pp128 86.25 86.12 1.00
AI PRO R9700 llama 8B Q6_K 2 pp128 147.56 147.81 1.00
AI PRO R9700 llama 8B Q6_K 4 pp128 237.44 238.95 1.01
AI PRO R9700 llama 8B Q6_K 7 pp128 299.72 301.63 1.01
AI PRO R9700 llama 8B Q6_K 8 pp128 313.69 315.28 1.01
AI PRO R9700 llama 8B Q8_0 1 pp128 71.16 71.24 1.00
AI PRO R9700 llama 8B Q8_0 2 pp128 130.03 130.17 1.00
AI PRO R9700 llama 8B Q8_0 4 pp128 246.27 246.11 1.00
AI PRO R9700 llama 8B Q8_0 7 pp128 391.00 390.92 1.00
AI PRO R9700 llama 8B Q8_0 8 pp128 427.31 428.60 1.00
AI PRO R9700 qwen35 27B Q5_K_M 1 pp128 25.35 26.15 1.03
AI PRO R9700 qwen35 27B Q5_K_M 2 pp128 46.03 46.64 1.01
AI PRO R9700 qwen35 27B Q5_K_M 4 pp128 70.54 76.39 1.08
AI PRO R9700 qwen35 27B Q5_K_M 7 pp128 84.57 93.39 1.10
AI PRO R9700 qwen35 27B Q5_K_M 8 pp128 87.96 98.37 1.12

@gaugarg-nv

Copy link
Copy Markdown
Contributor

Its perf positve on HIP

Thanks @IMbackK

@IMbackK IMbackK removed their assignment Sep 4, 2026
@Pyrolistical

Pyrolistical commented Sep 7, 2026

Copy link
Copy Markdown

Should have looked here, but found this independently a few days ago. My version Pyrolistical@ecd06de

TG/s results over master on rocm r9700 running qwen3.8 27b q4_k_xl:

0 16 K 32 K 64 K 128 K
+3.01% +3.31% +3.44% +3.43% +2.93%

@gaugarg-nv

Copy link
Copy Markdown
Contributor

@ggml-org/ggml-cuda Could I please get another review?

Comment thread ggml/src/ggml-cuda/mmvq.cu Outdated
template <> struct mmvq_pf<GGML_TYPE_Q4_K> { static constexpr int bytes = sizeof(block_q4_K); };
template <> struct mmvq_pf<GGML_TYPE_Q5_K> { static constexpr int bytes = sizeof(block_q5_K); };
template <> struct mmvq_pf<GGML_TYPE_Q6_K> { static constexpr int bytes = sizeof(block_q6_K); };
template <> struct mmvq_pf<GGML_TYPE_IQ4_XS> { static constexpr int bytes = sizeof(block_iq4_xs); };

@am17an am17an Sep 7, 2026

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.

block_size should be added to ggml_cuda_type_traits, create a separate mmvq_should_prefetch function for excluding q2_k

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged. I will commit the necessary changes for review in a short bit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made the necessary changes in the latest commit. Please review.

Comment thread ggml/src/ggml-cuda/mmvq.cu Outdated
Comment on lines +20 to +24
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ == GGML_CUDA_CC_DGX_SPARK
static __device__ __forceinline__ void mmvq_prefetch_l2(const void * p) {
asm volatile("prefetch.global.L2 [%0];" :: "l"(p));
}
#endif

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.

leave a comment or link to PR discussion where DGX sparks numbers are displayed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a comment with link to the PR comment for DGX Spark results

@praneshgo

Copy link
Copy Markdown
Contributor Author

Pulling all the perf sweeps done of DGX Spark over multiple models, quants and HW in one place for reference.

DGX Spark Perf

DGX Spark GB10 - Llama-3.2-3B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 109.82 109.21 -0.56% 109.17 -0.59% 102.79
2 208.23 208.28 +0.03% 212.53 +2.07% 179.48
3 308.59 311.47 +0.93% 313.82 +1.70% 268.30
4 421.64 414.86 -1.61% 417.99 -0.87% 356.44
5 505.18 488.59 -3.28% 519.80 +2.89% 440.91
6 593.08 593.04 -0.01% 612.91 +3.34% 527.41
7 657.48 683.30 +3.93% 690.60 +5.04% 611.78
8 695.70 762.26 +9.57% 762.77 +9.64% 678.54
Q5_K 1 90.01 93.21 +3.56% 93.32 +3.68% 86.03
2 173.79 176.09 +1.32% 179.22 +3.12% 144.75
3 263.92 261.73 -0.83% 264.69 +0.29% 216.43
4 356.29 345.21 -3.11% 354.98 -0.37% 287.20
5 422.98 412.24 -2.54% 439.46 +3.90% 355.09
6 505.07 494.74 -2.04% 521.36 +3.23% 426.37
7 593.05 580.93 -2.04% 600.16 +1.20% 494.72
8 630.71 649.41 +2.97% 662.14 +4.98% 549.91
Q2_K 1 172.81 172.42 -0.23% 173.37 +0.32% 152.00
2 296.36 296.43 +0.02% 296.89 +0.18% 233.89
3 451.30 450.08 -0.27% 451.26 -0.01% 348.47
4 543.26 541.72 -0.28% 541.26 -0.37% 462.55
5 684.85 685.26 +0.06% 684.49 -0.05% 572.25
6 723.55 723.73 +0.02% 721.87 -0.23% 681.84
7 763.52 762.01 -0.20% 764.01 +0.06% 798.11
8 773.67 774.47 +0.10% 773.51 -0.02% 866.24
Q3_K 1 118.01 117.93 -0.06% 120.43 +2.05% 111.57
2 252.85 253.13 +0.11% 255.03 +0.86% 188.62
3 357.25 358.40 +0.32% 359.15 +0.53% 280.66
4 467.62 468.39 +0.17% 462.82 -1.03% 374.60
5 586.04 587.44 +0.24% 578.47 -1.29% 462.91
6 669.61 672.44 +0.42% 668.79 -0.12% 555.15
7 755.40 752.06 -0.44% 766.23 +1.43% 642.50
8 795.47 799.15 +0.46% 779.98 -1.95% 708.03
Q6_K 1 76.16 76.57 +0.55% 78.12 +2.58% 73.13
2 147.24 147.08 -0.11% 152.23 +3.39% 123.56
3 218.18 218.32 +0.06% 228.43 +4.70% 184.52
4 291.44 290.87 -0.20% 301.87 +3.58% 245.37
5 345.03 344.76 -0.08% 366.39 +6.19% 304.50
6 413.98 413.12 -0.21% 439.01 +6.05% 365.00
7 478.32 475.81 -0.53% 506.07 +5.80% 424.96
8 543.92 545.04 +0.21% 563.45 +3.59% 472.50
Q4_0 1 119.17 118.90 -0.22% 118.89 -0.23% 109.33
2 235.54 235.33 -0.09% 233.17 -1.01% 185.02
3 346.77 346.59 -0.05% 348.24 +0.43% 277.51
4 458.44 457.71 -0.16% 457.80 -0.14% 367.86
5 555.28 554.32 -0.17% 554.20 -0.19% 456.69
6 660.01 659.44 -0.09% 661.47 +0.22% 544.46
7 761.99 759.72 -0.30% 769.42 +0.98% 631.96
8 854.79 853.93 -0.10% 853.86 -0.11% 698.60
Q8_0 1 65.68 65.63 -0.08% 67.80 +3.22% 63.11
2 126.39 126.12 -0.22% 130.52 +3.26% 105.90
3 189.58 189.35 -0.12% 193.64 +2.14% 158.24
4 252.03 251.24 -0.31% 258.24 +2.46% 210.18
5 300.83 300.48 -0.11% 312.27 +3.80% 261.49
6 360.18 360.04 -0.04% 371.04 +3.02% 312.92
7 419.53 418.12 -0.34% 432.52 +3.10% 364.71
8 479.45 478.60 -0.18% 479.78 +0.07% 407.51
IQ4_XS 1 121.59 122.20 +0.50% 119.13 -2.03% 110.70
2 233.78 233.20 -0.25% 250.52 +7.16% 194.79
3 325.88 325.22 -0.20% 374.60 +14.95% 291.57
4 432.60 432.41 -0.04% 497.09 +14.91% 388.72
5 596.22 597.53 +0.22% 599.08 +0.48% 480.50
6 658.34 656.17 -0.33% 708.61 +7.64% 574.88
7 766.77 766.05 -0.09% 821.90 +7.19% 665.07
8 806.57 801.66 -0.61% 903.78 +12.05% 737.02

DGX Spark GB10 - Llama-3.1-8B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 50.05 49.75 -0.58% 50.29 +0.49% 48.20
2 94.80 93.44 -1.44% 96.63 +1.93% 81.33
3 139.25 139.64 +0.28% 144.67 +3.89% 121.39
4 191.83 186.19 -2.94% 192.15 +0.17% 161.40
5 230.69 219.86 -4.69% 245.71 +6.51% 200.12
6 273.41 266.37 -2.58% 292.10 +6.83% 239.80
7 307.47 308.72 +0.41% 337.71 +9.83% 278.05
8 327.37 346.87 +5.96% 374.09 +14.27% 313.11
Q5_K 1 40.12 41.62 +3.74% 42.06 +4.85% 40.07
2 76.45 76.79 +0.44% 79.63 +4.17% 66.21
3 118.73 116.05 -2.26% 119.06 +0.28% 98.83
4 159.60 154.21 -3.38% 161.73 +1.33% 131.69
5 189.39 182.29 -3.75% 202.92 +7.14% 163.58
6 227.44 220.82 -2.91% 241.38 +6.13% 195.84
7 267.53 259.52 -2.99% 281.17 +5.10% 227.74
8 287.37 289.53 +0.75% 314.94 +9.59% 256.30
Q2_K 1 82.08 82.13 +0.06% 82.44 +0.43% 75.41
2 138.14 138.45 +0.22% 138.57 +0.30% 113.82
3 233.72 233.51 -0.09% 233.77 +0.02% 170.11
4 276.09 276.31 +0.08% 276.64 +0.20% 226.17
5 322.40 322.27 -0.04% 322.55 +0.05% 280.61
6 338.85 339.06 +0.06% 338.96 +0.04% 334.28
7 357.17 357.14 -0.01% 356.83 -0.10% 388.24
8 358.59 357.61 -0.27% 357.55 -0.29% 434.08
Q3_K 1 54.64 54.62 -0.02% 57.02 +4.36% 54.40
2 121.08 120.83 -0.21% 119.38 -1.41% 86.13
3 165.17 165.30 +0.08% 173.70 +5.17% 128.80
4 229.19 229.40 +0.09% 225.50 -1.61% 171.05
5 271.17 270.49 -0.25% 289.21 +6.65% 212.24
6 312.04 312.63 +0.19% 331.88 +6.36% 254.33
7 349.79 349.62 -0.05% 365.73 +4.56% 295.18
8 371.18 370.27 -0.24% 375.14 +1.07% 331.02
Q6_K 1 34.38 34.48 +0.29% 34.97 +1.71% 33.26
2 64.53 64.61 +0.13% 68.27 +5.80% 54.52
3 95.94 95.95 +0.02% 102.72 +7.07% 81.50
4 128.01 128.02 +0.01% 136.18 +6.38% 108.17
5 150.95 151.29 +0.23% 161.51 +7.00% 134.69
6 181.88 181.80 -0.04% 198.17 +8.96% 161.01
7 208.95 209.59 +0.31% 228.42 +9.32% 187.40
8 241.11 241.76 +0.27% 256.65 +6.45% 211.44
Q4_0 1 54.42 54.47 +0.08% 54.93 +0.93% 51.80
2 105.67 106.09 +0.40% 106.18 +0.48% 85.13
3 157.64 157.54 -0.06% 158.84 +0.76% 127.14
4 210.27 209.80 -0.22% 211.61 +0.64% 169.25
5 252.13 252.17 +0.02% 257.80 +2.25% 210.39
6 302.11 301.51 -0.20% 308.66 +2.17% 250.84
7 349.49 349.81 +0.09% 360.49 +3.15% 292.33
8 395.81 397.37 +0.39% 403.77 +2.01% 327.29
Q8_0 1 29.32 29.28 -0.14% 29.99 +2.30% 28.53
2 55.24 55.26 +0.03% 58.40 +5.72% 47.05
3 82.99 83.07 +0.10% 86.96 +4.78% 70.34
4 110.09 110.15 +0.05% 115.70 +5.09% 93.53
5 133.20 133.28 +0.06% 139.75 +4.92% 116.38
6 158.88 158.95 +0.04% 166.48 +4.78% 139.32
7 183.82 184.10 +0.16% 194.57 +5.85% 162.16
8 213.53 213.45 -0.04% 219.12 +2.62% 183.12
IQ4_XS 1 56.45 56.33 -0.21% 56.80 +0.62% 53.37
2 106.98 106.97 -0.01% 116.19 +8.61% 88.84
3 147.12 147.16 +0.03% 174.70 +18.75% 132.83
4 197.26 197.51 +0.13% 231.38 +17.29% 176.53
5 279.73 279.16 -0.20% 281.34 +0.58% 219.44
6 305.37 305.79 +0.14% 333.24 +9.13% 262.28
7 355.16 353.54 -0.45% 387.48 +9.10% 304.21
8 368.71 369.05 +0.09% 433.07 +17.46% 341.05

DGX Spark GB10 - gemma-4-12B-it

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 31.48 31.12 -1.12% 31.71 +0.75% 27.85
2 59.94 57.88 -3.42% 59.83 -0.17% 50.57
3 86.25 86.44 +0.23% 89.85 +4.17% 75.59
4 117.95 115.13 -2.40% 118.19 +0.20% 98.71
5 141.95 136.67 -3.72% 149.58 +5.38% 124.04
6 166.91 165.27 -0.98% 177.02 +6.06% 148.23
7 184.22 191.05 +3.71% 202.40 +9.87% 172.34
8 195.90 216.05 +10.29% 225.51 +15.11% 196.88
Q5_K 1 25.24 26.13 +3.52% 26.50 +4.99% 22.87
2 48.35 47.69 -1.36% 49.58 +2.54% 41.23
3 73.39 72.00 -1.90% 74.24 +1.15% 61.56
4 97.85 94.53 -3.39% 99.35 +1.54% 80.87
5 116.94 112.56 -3.75% 124.01 +6.05% 101.53
6 138.05 134.91 -2.27% 146.54 +6.15% 121.23
7 161.58 159.27 -1.43% 169.22 +4.73% 141.09
8 175.09 178.60 +2.00% 190.07 +8.56% 160.69
Q2_K 1 50.52 50.52 +0.01% 50.49 -0.05% 41.09
2 86.05 86.25 +0.23% 85.93 -0.13% 71.27
3 141.85 142.05 +0.14% 141.93 +0.06% 106.58
4 165.77 165.98 +0.13% 165.65 -0.07% 138.51
5 193.41 193.54 +0.06% 193.73 +0.16% 174.18
6 203.10 202.96 -0.07% 203.33 +0.11% 208.15
7 213.44 213.31 -0.06% 213.82 +0.18% 242.16
8 216.05 216.10 +0.03% 216.02 -0.01% 275.57
Q3_K 1 33.79 33.77 -0.09% 35.53 +5.13% 30.00
2 74.05 74.24 +0.26% 74.38 +0.45% 53.96
3 102.65 102.53 -0.12% 106.71 +3.96% 80.58
4 138.12 137.86 -0.19% 137.32 -0.58% 105.33
5 165.64 165.61 -0.02% 174.45 +5.32% 132.25
6 188.31 188.33 +0.01% 198.42 +5.37% 158.39
7 210.19 210.58 +0.18% 218.31 +3.86% 184.00
8 223.99 224.44 +0.20% 226.04 +0.91% 209.62
Q6_K 1 21.55 21.62 +0.33% 21.76 +0.99% 18.81
2 40.36 40.37 +0.02% 42.63 +5.63% 33.73
3 60.06 60.08 +0.04% 64.05 +6.65% 50.30
4 79.69 79.66 -0.03% 84.34 +5.84% 66.32
5 94.06 94.06 -0.01% 100.70 +7.05% 83.01
6 113.26 113.37 +0.10% 122.82 +8.44% 99.55
7 130.40 130.48 +0.06% 141.57 +8.57% 115.52
8 150.11 150.10 -0.00% 159.58 +6.31% 131.89
Q4_0 1 33.60 33.68 +0.22% 33.97 +1.11% 29.34
2 65.20 65.31 +0.17% 65.61 +0.64% 52.88
3 97.25 97.29 +0.04% 97.92 +0.69% 79.01
4 127.84 128.22 +0.30% 129.10 +0.99% 103.17
5 154.53 154.77 +0.16% 158.57 +2.61% 129.83
6 185.16 185.07 -0.05% 189.51 +2.35% 155.25
7 213.39 213.68 +0.14% 220.93 +3.53% 180.68
8 244.07 244.46 +0.16% 249.56 +2.25% 205.46
Q8_0 1 18.40 18.45 +0.27% 18.59 +1.00% 16.27
2 34.48 34.51 +0.08% 36.50 +5.83% 29.38
3 51.84 51.86 +0.03% 54.24 +4.62% 43.89
4 68.48 68.54 +0.08% 71.92 +5.01% 57.86
5 82.74 82.69 -0.07% 86.80 +4.91% 72.52
6 98.65 98.51 -0.14% 103.44 +4.85% 86.61
7 113.59 113.64 +0.05% 120.88 +6.42% 100.74
8 133.12 133.20 +0.06% 136.35 +2.42% 115.01
IQ4_XS 1 34.23 34.29 +0.17% 33.94 -0.87% 29.21
2 66.05 65.91 -0.20% 71.50 +8.25% 54.52
3 91.16 91.19 +0.03% 107.64 +18.09% 81.43
4 121.38 121.16 -0.18% 141.91 +16.91% 106.26
5 171.14 171.06 -0.05% 171.46 +0.19% 133.54
6 187.27 187.21 -0.03% 203.29 +8.55% 159.92
7 218.44 217.66 -0.36% 236.93 +8.46% 185.31
8 229.79 229.86 +0.03% 267.99 +16.63% 211.00

DGX Spark GB10 - Qwen3.6-27B

type ne11 base t/s branchless t/s vs base branchless + prefetch t/s vs base MMQ t/s (forced at all ne11 - for comparison)
Q4_K 1 14.04 14.03 -0.05% 14.80 +5.47% 13.52
2 26.67 26.30 -1.39% 28.15 +5.57% 23.50
3 39.24 39.35 +0.28% 42.11 +7.32% 35.06
4 54.06 52.67 -2.58% 55.62 +2.88% 46.15
5 64.96 61.95 -4.63% 70.21 +8.08% 57.83
6 76.59 74.97 -2.12% 83.18 +8.60% 69.13
7 86.43 86.59 +0.18% 95.58 +10.59% 80.31
8 92.93 98.10 +5.56% 106.23 +14.31% 91.51
Q5_K 1 11.26 11.66 +3.58% 12.41 +10.22% 11.14
2 21.80 21.61 -0.88% 23.15 +6.21% 19.04
3 33.64 32.69 -2.83% 34.55 +2.71% 28.44
4 45.11 42.99 -4.69% 46.64 +3.40% 37.51
5 53.69 50.91 -5.18% 58.03 +8.08% 47.03
6 64.11 61.79 -3.62% 68.82 +7.35% 56.26
7 75.86 72.73 -4.13% 80.46 +6.05% 65.27
8 83.10 81.82 -1.53% 90.95 +9.45% 74.35
Q2_K 1 23.41 23.51 +0.44% 23.47 +0.26% 20.26
2 39.39 39.45 +0.15% 39.43 +0.10% 32.83
3 65.38 65.37 -0.01% 65.33 -0.08% 48.99
4 79.00 78.99 -0.01% 78.97 -0.03% 64.09
5 92.58 92.57 -0.01% 92.64 +0.06% 80.45
6 97.65 97.51 -0.13% 97.54 -0.11% 96.33
7 103.14 102.96 -0.18% 103.13 -0.01% 111.77
8 104.21 104.00 -0.20% 104.17 -0.03% 126.98
Q3_K 1 15.48 15.49 +0.05% 16.92 +9.24% 15.02
2 34.13 34.16 +0.10% 34.82 +2.01% 24.26
3 46.57 46.63 +0.13% 49.40 +6.07% 36.26
4 63.87 63.91 +0.06% 63.51 -0.56% 47.68
5 75.07 75.13 +0.09% 83.84 +11.69% 59.88
6 86.23 86.14 -0.10% 95.88 +11.19% 71.54
7 99.32 99.16 -0.16% 105.04 +5.75% 83.12
8 106.82 106.59 -0.21% 109.12 +2.16% 94.65
Q6_K 1 9.54 9.56 +0.17% 10.07 +5.60% 9.16
2 18.32 18.31 -0.04% 19.62 +7.10% 15.77
3 27.27 27.24 -0.08% 29.46 +8.05% 23.58
4 36.17 36.17 -0.01% 38.82 +7.31% 31.14
5 42.92 42.91 -0.02% 45.86 +6.85% 38.97
6 51.92 51.96 +0.08% 56.80 +9.40% 46.63
7 59.75 59.74 -0.01% 65.45 +9.55% 54.23
8 69.21 69.20 -0.01% 73.86 +6.72% 61.83
Q4_0 1 15.31 15.31 -0.03% 15.61 +1.93% 14.20
2 29.92 29.91 -0.03% 30.30 +1.28% 24.62
3 44.59 44.56 -0.08% 45.26 +1.50% 36.74
4 58.76 58.72 -0.06% 59.71 +1.61% 48.30
5 70.90 70.94 +0.05% 73.45 +3.59% 60.57
6 85.09 84.97 -0.14% 88.13 +3.57% 72.43
7 98.09 98.10 +0.01% 102.79 +4.79% 84.07
8 112.00 111.84 -0.15% 116.33 +3.86% 95.65
Q8_0 1 8.15 8.17 +0.34% 8.68 +6.51% 7.96
2 15.69 15.70 +0.05% 16.74 +6.67% 13.73
3 23.58 23.57 -0.04% 24.99 +5.98% 20.54
4 31.13 31.12 -0.05% 33.17 +6.54% 27.15
5 37.87 37.89 +0.05% 39.79 +5.07% 33.96
6 45.12 45.15 +0.07% 47.54 +5.35% 40.66
7 52.11 52.16 +0.10% 55.43 +6.36% 47.28
8 61.12 61.12 +0.01% 62.91 +2.93% 53.96
IQ4_XS 1 16.10 16.09 -0.06% 16.23 +0.79% 14.75
2 30.16 30.16 +0.00% 32.91 +9.10% 25.92
3 41.63 41.62 -0.01% 49.13 +18.02% 38.68
4 55.24 55.23 -0.01% 65.05 +17.76% 50.83
5 78.31 78.38 +0.09% 78.88 +0.73% 63.80
6 85.43 85.46 +0.03% 93.56 +9.52% 76.28
7 99.32 99.33 +0.01% 105.12 +5.84% 88.50
8 104.24 104.36 +0.12% 118.20 +13.39% 100.70

DGX Spark GB10 - few other models

ne11 Qwen3.5-9B (mtp) Qwen3.6-27B (mtp) Qwen3.8-27B(dflash2)
2 +1.34% +1.93% +2.43%
3 +1.74% +4.52% +4.34%
4 +2.91% +3.47% +3.75%
6 +4.83% +6.43% +6.17%
8 +3.46% +7.94% +7.61%

DGX Spark GB10 - more quants

This table measures the gain/loss when a quant type is allowed to use prefetch, with every other change in the PR added and kept as-is. This is used to determine which quants benefit from prefetch and which do not.

DGX Spark GB10 - Llama-3.2-3B

type ne11=1 ne11=2 ne11=3 ne11=4 ne11=5 ne11=6 ne11=7 ne11=8 median
Q4_K (unchanged: noise floor) -0.02% -0.11% -0.07% -0.06% -0.02% +0.02% +0.05% +0.02% -0.02%
Q6_K (unchanged: noise floor) -0.03% -0.01% -0.00% +0.07% -0.11% -0.11% -0.14% +0.03% -0.02%
Q5_0 (added) +0.00% +0.56% +0.60% +0.41% +0.95% +1.37% +1.02% -0.07% +0.58%
mxfp4 (added) +0.53% -0.56% +0.05% -0.37% +0.74% +2.05% +0.25% -0.04% +0.15%
IQ1_M (added) -1.87% +8.03% +11.30% +2.47% -3.42% +4.42% -2.27% -4.60% +0.30%
IQ4_NL (added) +0.01% +0.49% +0.79% +0.16% +0.05% +0.62% +1.74% +0.71% +0.56%
Q2_K -15.13% +7.34% -1.80% +3.94% -4.52% +0.01% +0.02% +0.07% +0.02%
Q4_1 -0.20% +0.30% -0.09% -0.08% -1.34% -1.81% -1.41% -0.70% -0.45%
Q5_1 +0.01% +0.09% +0.22% -0.11% -1.42% -1.06% -0.68% -1.28% -0.39%
Q1_0 -1.96% +1.24% +2.44% -0.51% +1.94% -0.87% -2.71% +3.33% +0.36%
Q2_0 -0.10% -0.91% -0.81% +0.55% +0.44% -1.00% -0.72% +1.69% -0.41%
IQ3_S -1.14% -11.28% +19.67% +0.49% +4.54% +2.89% +0.02% -0.52% +0.26%
IQ3_XXS +0.13% -0.29% +0.67% +0.08% +0.88% +2.75% -0.40% -3.06% +0.10%
IQ2_XXS +0.78% -0.52% -0.89% -0.42% -0.47% -1.38% -0.58% -1.71% -0.55%
IQ2_XS +3.57% -0.07% -0.13% +3.58% -1.38% -1.62% -1.30% +0.33% -0.10%
IQ2_S -4.81% -9.49% +2.86% +0.65% +1.89% +0.94% +0.42% -1.76% +0.54%
IQ1_S -0.79% -0.21% -0.81% +1.39% -0.22% -0.24% -1.35% -0.11% -0.23%
nvfp4 -0.26% -0.80% -0.09% -0.52% -0.30% -0.37% -0.33% -0.69% -0.35%

DGX Spark GB10 - Llama-3.1-8B

type ne11=1 ne11=2 ne11=3 ne11=4 ne11=5 ne11=6 ne11=7 ne11=8 median
Q4_K (unchanged: noise floor) +0.17% +0.25% +0.13% +0.20% +0.16% +0.20% +0.17% +0.20% +0.19%
Q6_K (unchanged: noise floor) +0.04% +0.08% +0.16% +0.09% +0.05% +0.01% +0.02% +0.17% +0.06%
Q5_0 (added) +0.33% +1.09% +1.03% +1.13% +2.55% +2.77% +2.71% +1.65% +1.39%
mxfp4 (added) +1.18% +1.17% +1.58% +0.44% +2.80% +3.70% +2.43% +2.35% +1.96%
IQ1_M (added) +2.68% +10.06% +9.40% +4.21% -2.54% +2.64% -0.91% -2.53% +2.66%
IQ4_NL (added) +1.70% +1.23% +1.08% +0.58% +1.98% +2.14% +3.13% +2.17% +1.84%
Q2_K -14.27% +11.12% -5.71% +2.22% -0.55% +0.03% -0.01% +0.01% +0.00%
Q4_1 +0.14% +0.21% +0.03% +0.07% -0.77% -1.44% -1.25% -0.05% -0.01%
Q5_1 +0.48% +0.07% +0.00% +0.07% -0.91% -0.85% -0.05% -0.90% -0.03%
Q1_0 +1.05% +0.63% +2.17% -0.22% +1.33% -0.06% -0.13% -0.72% +0.29%
Q2_0 -0.07% -0.19% +0.04% +0.23% +0.21% +0.97% -0.32% -0.05% -0.00%
IQ3_S -0.59% -4.63% +18.93% +1.86% +7.55% +4.15% +4.55% +4.87% +4.35%
IQ3_XXS +1.23% +0.79% +1.00% +1.60% +2.68% +1.19% +1.28% -0.89% +1.21%
IQ2_XXS -0.36% +0.84% +0.09% +0.91% +0.80% +0.05% -0.52% -1.23% +0.07%
IQ2_XS +0.78% +0.35% -0.37% +4.96% +0.05% -0.43% -0.64% +0.08% +0.06%
IQ2_S -3.38% -6.04% +4.30% +0.88% +5.71% +1.14% +1.41% -1.19% +1.01%
IQ1_S -0.61% +0.38% -0.62% +1.63% +1.54% +0.36% -1.82% -2.48% -0.12%
nvfp4 +0.29% -0.65% +0.25% -0.30% +0.20% +0.26% -0.38% +0.88% +0.22%

DGX Spark GB10 - gemma-4-12B-it

type ne11=1 ne11=2 ne11=3 ne11=4 ne11=5 ne11=6 ne11=7 ne11=8 median
Q4_K (unchanged: noise floor) +0.10% +0.10% +0.27% +0.13% +0.04% +0.03% -0.10% +0.10% +0.10%
Q6_K (unchanged: noise floor) +0.13% +0.05% -0.06% -0.00% +0.07% +0.07% -0.01% -0.02% +0.02%
Q5_0 (added) +0.65% +1.29% +1.23% +1.34% +3.80% +3.84% +3.63% +2.58% +1.96%
mxfp4 (added) +1.39% +0.84% +0.95% +0.58% +2.44% +3.54% +2.22% +2.37% +1.81%
IQ1_M (added) +2.67% +11.99% +11.02% +5.36% -0.05% +3.33% -0.24% -1.95% +3.00%
IQ4_NL (added) +0.94% +1.06% +1.12% +0.60% +3.02% +2.86% +3.32% +2.72% +1.92%
Q2_K -11.88% +10.81% -3.41% +2.46% +0.22% +0.19% -0.11% +0.05% +0.12%
Q4_1 +0.35% +0.27% +0.21% +0.20% +1.63% +1.29% +1.38% +2.16% +0.82%
Q5_1 +0.15% +0.14% +0.02% -0.01% -1.60% -1.49% -0.85% -1.57% -0.43%
Q1_0 -0.02% +0.99% +3.03% +0.21% +0.95% -0.93% -1.14% -2.34% +0.09%
Q2_0 +0.51% +0.09% -0.03% +0.11% +0.20% -0.06% +0.43% -0.93% +0.10%
IQ3_S +6.67% -5.98% +19.69% +2.03% +6.33% +4.65% +3.59% +3.03% +4.12%
IQ3_XXS +1.65% +0.99% +1.09% +1.42% +2.15% +1.71% +1.25% -0.77% +1.33%
IQ2_XXS +1.92% +0.30% -0.64% +0.51% +0.13% -0.99% -0.58% -1.26% -0.23%
IQ2_XS +5.66% +0.22% +0.12% +5.48% -0.39% -0.63% -0.42% -0.19% -0.03%
IQ2_S +4.74% -5.58% +4.10% +1.29% +4.47% +0.75% +1.44% -1.69% +1.37%
IQ1_S +0.86% -0.28% -0.86% +1.14% +0.75% +0.31% -2.28% -3.24% +0.01%
nvfp4 +0.18% -0.73% +0.13% -0.58% +0.18% +0.18% -0.59% +0.83% +0.15%

DGX Spark GB10 - Qwen3.6-27B

type ne11=1 ne11=2 ne11=3 ne11=4 ne11=5 ne11=6 ne11=7 ne11=8 median
Q4_K (unchanged: noise floor) +0.31% +0.29% +0.24% +0.32% +0.45% +0.36% +0.16% +0.11% +0.30%
Q6_K (unchanged: noise floor) +0.21% +0.29% +0.25% +0.21% +0.25% +0.12% +0.19% +0.11% +0.21%
Q5_0 (added) -0.46% +0.40% -0.21% -0.50% +1.85% +1.48% +1.94% +1.50% +0.94%
mxfp4 (added) +1.72% +1.52% +1.05% +0.52% +3.13% +3.71% +3.14% +3.66% +2.43%
IQ1_M (added) +1.61% +10.83% +8.22% +4.97% -0.56% +3.62% +0.84% -1.41% +2.61%
IQ4_NL (added) +1.17% +0.92% +0.59% -0.12% +1.81% +1.62% +2.70% +2.23% +1.40%
Q2_K -9.17% +13.06% -3.07% -3.45% +1.32% +0.11% +0.13% +0.25% +0.12%
Q4_1 -1.57% -1.06% -1.35% -1.66% -1.33% -0.95% -0.76% -1.06% -1.19%
Q5_1 -1.48% -1.56% -2.15% -2.41% -2.05% -2.31% -1.68% -1.92% -1.99%
Q1_0 +0.47% +2.51% +2.90% -0.00% +2.06% -0.47% -1.08% -2.24% +0.24%
Q2_0 +0.87% +0.35% +0.13% +1.15% +2.35% +2.07% +0.89% -0.74% +0.88%
IQ3_S +2.11% +0.27% +5.40% +1.52% +6.78% +3.54% +3.68% +3.13% +3.34%
IQ3_XXS +0.22% +1.99% +0.41% +0.39% +1.44% +0.44% -2.29% -2.37% +0.40%
IQ2_XXS -1.45% -0.26% +2.21% +0.63% +0.21% -0.68% -0.87% -1.07% -0.47%
IQ2_XS +0.01% +0.35% +0.23% +8.54% -1.22% -0.15% +0.38% -0.21% +0.12%
IQ2_S +0.90% -6.07% +3.10% +1.53% +5.72% +3.18% +3.09% +0.30% +2.31%
IQ1_S -0.53% -0.55% -0.05% +2.85% +0.32% -1.20% -3.04% -4.12% -0.54%
nvfp4 -0.51% -0.11% +0.14% +0.15% -1.80% -1.52% -2.00% -1.03% -0.77%

@praneshgo

Copy link
Copy Markdown
Contributor Author

@am17an
Addressed both the comments raised. Can you please review? Thanks.

Comment thread ggml/src/ggml-cuda/common.cuh Outdated
static constexpr int qk = QK_K;
static constexpr int qr = QR3_S;
static constexpr int qi = QI3_S;
static constexpr int block_size = sizeof(block_iq3_s);

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.

you can probably name this bs and keep the alignment the same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed block_size to bs for cleaner indentation in the latest commit.
@am17an can you please reapprove the PR? Thank you.

@am17an

am17an commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Also please re-name the PR before merging to something concise but informative.

@praneshgo praneshgo changed the title CUDA: Adding Spark to use prefetch and update Q4_K and Q5_K to use branchless computation, which stops the scale unpack being re-executed for every column in mmvq, improving perf at batch sizes > 1 CUDA: branchless Q4_K/Q5_K unpack to speed up mmvq, L2 prefetch on DGX Spark Sep 7, 2026
@praneshgo

Copy link
Copy Markdown
Contributor Author

Also please re-name the PR before merging to something concise but informative.

Updated the PR title to be concise and informative.

@am17an
am17an merged commit 73ab759 into ggml-org:master Sep 7, 2026
19 of 23 checks passed
t-jet pushed a commit to t-jet/llama.cpp-jet that referenced this pull request Sep 8, 2026
x1250 pushed a commit to x1250/llama.cpp that referenced this pull request Sep 9, 2026
…X Spark (ggml-org#26705)

* Update Q4_K and Q5_K to use branchless computation, which stops the scale unpack being re-executed for every column in mmvq, improving perf at batch sizes > 1

* Gating the change off from DGX Spark due to no gain

* Adding prefetch gated to Spark, making branchless change in Q4_K and Q5_K general and modifying switch points based on latest perf data

* Guard the mmvq L2 prefetch against MUSA as well as HIP

* Define the mmvq L2 prefetch only under the Spark guard

* Update switch point for Q4_K to accommodate more models

* Remove stale comments

* Add block_size to ggml_cuda_type_traits and create a separate mmvq_should_prefetch function

* Rename block_size to bs for cleaner indentation

* Fix build error on non-Spark CUDA arch with appropriate conditional around new function added

---------

Co-authored-by: praneshgo <227579474+praneshgo@users.noreply.github.com>
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
…X Spark (ggml-org#26705)

* Update Q4_K and Q5_K to use branchless computation, which stops the scale unpack being re-executed for every column in mmvq, improving perf at batch sizes > 1

* Gating the change off from DGX Spark due to no gain

* Adding prefetch gated to Spark, making branchless change in Q4_K and Q5_K general and modifying switch points based on latest perf data

* Guard the mmvq L2 prefetch against MUSA as well as HIP

* Define the mmvq L2 prefetch only under the Spark guard

* Update switch point for Q4_K to accommodate more models

* Remove stale comments

* Add block_size to ggml_cuda_type_traits and create a separate mmvq_should_prefetch function

* Rename block_size to bs for cleaner indentation

* Fix build error on non-Spark CUDA arch with appropriate conditional around new function added

---------

Co-authored-by: praneshgo <227579474+praneshgo@users.noreply.github.com>
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.

7 participants