Repository navigation
Pascal (sm_61) PQ2_0 mat-vec for 1-4 columns: +17% on Ternary-Bonsai-2-9B with MTP, bit-identical output - #368
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ArtyomITA
force-pushed
the
pascal-pq2_0-matvec
branch
from
October 17, 2026 18:05
533257f to
e687f81
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This adds a PQ2_0 mat-vec for 1-4 columns on Pascal (sm_61) in
ggml/src/ggml-cuda/ggml-cuda.cu(+112 lines), used by single-token decode and by the MTP verify step. On sm_61 these went to the generic vec_dot, since the multi-column PQ2_0 kernel is only enabled on Ada. It keeps the exact summation order of the generic mmvq (warp per 4 rows, no shared memory or barriers, activations read in the PQ2 layout without per-weight decode), so the output is bit-identical.GTX 1080, driver 581.57, CUDA 12.4, MSVC 14.38, Windows, PrismML fork commit 0082ac2 (branch prism)
Ternary-Bonsai-2-9B PQ2_0 + MTP Q8_0, llama-server, draft-mtp n-max 2, 1 slot, fa on, ~5k token context then 3 greedy answers of 384 tokens:
from 55.7 to 65.3 tok/s (+17.3%), all 5 pairs faster (+13.6% to +19.5%)
prefill 518 to 512 tok/s (-1.2%, noise)
With llama-bench (PQ2_0, no MTP, -r 3, average of 2 runs per build A-B-B-A):
tg128 +8.1%, pp512 +1% (noise). Without MTP every step is 1 column, with MTP the verify step runs 3 columns and that is where the generic path was slowest.
How i measured: median of 5 runs per build, alternating A-B-A-B for thermal drift, first run with the GPU at 55 C. Anything under 3% i call it noise.
Correctness. Against logits saved from the stock build (llama-perplexity --kl-divergence):
The 99.902% at ubatch 1 is not from the patch: the stock build against its own saved logits gives the same 99.902%. A different summation order (correct on paper) moved the KL divergence to 7e-4, that's why the kernel copies the generic order.
test-backend-opson the patched build: 15873/15873 tests passed.Additional information
This is the safest piece of a larger set of changes for the same model and card, tested together in one build: +51% in total (55.9 to 84.4 tok/s), same KLD floor, greedy text on 11k tokens identical, same texts as the stock build with --parallel 4. The other pieces are not part of this PR; this is what each one is worth in the full build (full build vs full build without that piece):
If there is interest i can open them as separate PRs.
Requirements