Skip to content

cuda : turn on the measured prefill and PQ2_0 decode defaults on A100, B200 and RTX PRO 6000 - #460

Merged
bri-prism merged 4 commits into
prismfrom
cuda/prefill-defaults-more-gpus
Nov 26, 2026
Merged

bri-prism merged 4 commits into
prismfrom
cuda/prefill-defaults-more-gpus

Conversation

@bri-prism

@bri-prism bri-prism commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

Turns on the measured CUDA defaults from #452 on more GPUs.

Now targets prism. #452 merged into prism before #457 merged into the #452 branch, so #457 (the opt-in Metal GGML_METAL_VERIFY_COLLAPSE switch, 2 Metal files) never reached prism. This branch sits on top of #457 and brings it in too.

  • GGML_CUDA_PREFILL_OPT is on by default for A100 (cc 800), B200 (cc 1000) and RTX PRO 6000 / RTX 50 (cc 1200-1299), not just Hopper.
  • The PQ2_0 multi-column mat-vec, including one-column decode, now also runs on A100 and B200.

Why

#452 turned these on only for Hopper because H200 was the only GPU measured. The other datacenter and workstation GPUs gain about as much.

How

One file, ggml/src/ggml-cuda/common.cuh: the architecture checks in ggml_cuda_prefill_opt, ggml_cuda_pq2_mc_min and ggml_cuda_pq2_multicol, plus a GGML_CUDA_CC_BLACKWELL_DC (1000) define. GGML_CUDA_PREFILL_OPT=0 and GGML_CUDA_PQ2_MC_MIN=3 restore the #452 behaviour.

Measurements

One pod per GPU on 2026-11-24, built from this branch's code. llama-bench -p 2048 -n 128 -r 5 -ngl 99 -fa 1, 2 order-swapped passes, tok/s, against GGML_CUDA_PREFILL_OPT=0 GGML_CUDA_PQ2_MC_MIN=3:

GPU PTQ1_0 prefill PQ2_0 prefill PTQ1_0 decode PQ2_0 decode
A100 80GB 1407 -> 1546 (+10%) 1391 -> 1515 (+9%) 108.5 -> 108.5 86.4 -> 106.3 (+23%)
B200 3240 -> 4433 (+37%) 3378 -> 3913 (+16%) 189.0 -> 189.7 147.6 -> 172.0 (+17%)
RTX PRO 6000 4268 -> 5401 (+27%) 4215 -> 4936 (+17%) 156.0 -> 156.1 135.8 -> 136.0

Correctness:

  • test-backend-ops -b CUDA0 for MUL_MAT, GATED_DELTA_NET, ROT_MATVEC and RMS_NORM passes on all three GPUs. One run on RTX PRO 6000 had 1 MUL_MAT failure out of 3091. Both settings passed 3091/3091 on the A100 rerun, and B200 passed in its job.
  • 128 greedy tokens are byte-identical between the two settings for PTQ1_0 on all three GPUs, and for PQ2_0 on A100 and RTX PRO 6000.
  • PQ2_0 on B200 is not byte-identical, because the multi-column kernel sums in a different order than the generic kernel. llama-perplexity --kl-divergence, 16 chunks of 512, both at -ub 1, gives mean KL 1.15e-4, max 7.4e-3 and same top token 99.56%. The generic kernel run twice gives 0. For scale, the generic kernel at -ub 1 against -ub 512 gives mean KL 1.2e-4. If B200 should stay bit-identical, ggml_cuda_pq2_mc_min can keep 3 there, which gives up the +17% decode.

Not measured:

  • Ada, which stays off.
  • The RTX 30 series (cc 86x), which this change does not include.
  • DGX Spark (cc 1210), which falls inside the cc 1200-1299 range that now turns GGML_CUDA_PREFILL_OPT on.

…n the collapse kernel, extc keeps 5-8 (opt-in)

The base-3 collapse multi-column kernel (GGML_METAL_PTQ1_MULTICOL=1, by @Karim-Mattar) computes the same
dot product as mul_mv_ext over the integers; only the float accumulation order differs. Until now the
extc path claimed 2-4 rows first whenever GGML_METAL_PTQ1_COEF was on, so the two could not be combined.
With GGML_METAL_VERIFY_COLLAPSE=1, 2-4 rows take the collapse kernel and 5-8 rows keep extc.

Measured on M5 Pro with a 4B ternary PTQ1_0 model, llama-bench -p N -n 0 -r 5, two passes, against the
GGML_METAL_VERIFY_OPT default: pp2 150.9 -> 189.6 (+26%), pp3 132.6 -> 180.8 (+36%), pp4 129.4 -> 222.5
(+72%), pp5 and pp8 unchanged. KL against the stock path at -ub 2 and -ub 4 (16 wikitext chunks) is at the
stock-vs-stock floor (mean 0, max 6.5e-5 and 6.1e-5). test-backend-ops -b MTL0 -o MUL_MAT -p type_a=ptq1_0: 255/255.
Opt-in because the logits are not bit-identical to mul_mv_ext.
metal : PTQ1_0 verify at 2-4 rows on the collapse kernel, extc keeps 5-8 (GGML_METAL_VERIFY_COLLAPSE, opt-in)
…00 class GPUs too

Measured 2026-11-24 with llama-bench pp2048, 5 reps x 2 order-swapped passes, against
GGML_CUDA_PREFILL_OPT=0: PTQ1_0 prefill +37% (B200), +10% (A100), +27% (RTX PRO 6000);
PQ2_0 +16% / +9% / +17%. 128 greedy tokens of PTQ1_0 are byte-identical on all three.
Ada stays off (unmeasured).
…umn decode

Measured 2026-11-24, llama-bench tg128, 5 reps x 2 order-swapped passes: +23% on A100
(86.4 -> 106.3) and +17% on B200 (147.6 -> 172.0). RTX PRO 6000 and RTX 4090 were neutral and
keep the generic kernel for one and two columns.

A100 greedy output is byte-identical. On B200 the float summation order differs from the
generic kernel: llama-perplexity --kl-divergence at -ub 1 (16 chunks of 512) against the
generic kernel at -ub 1 gives mean KL 1.15e-4, max 7.4e-3, same top token 99.56%. For scale,
the generic kernel at -ub 1 against itself at -ub 512 gives mean KL 1.2e-4.
@bri-prism
bri-prism changed the base branch from mtp/verify-prefill-kernels to prism November 25, 2026 17:34
@bri-prism
bri-prism merged commit f702476 into prism Nov 26, 2026
1 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant