Repository navigation
cuda: PQ2_0 multi-column mat-vec for 1-2 columns on Hopper, with bias and gate+GLU fusion: +4.1% decode, +1.4-3.1% MTP3 on H200 - #397
Merged
Conversation
… bias and gate+GLU fusion The 3-8 column PQ2_0 kernel (#381) needs no per-weight decode: the activation layout is permuted so the raw 2-bit codes pair with it. On H200 it is also the faster 1-column kernel for the larger projections (2.3-2.9 TB/s against 1.7-2.2 for the generic tall-row path). Plain decode calls the 1-column mat-vec with fused bias (residual) and fused gate+up+GLU, so the kernel gets the same epilogue as mul_mat_vec_q: x_bias added to the result, and with a gate a second weight matrix dotted against the same activations, gate_bias added, then the GLU op. Hopper takes 1-8 columns; elsewhere it stays at 3-8. GGML_CUDA_PQ2_MC_MIN overrides the lower bound.
bri-prism
force-pushed
the
cuda/pq2-mc-1col
branch
from
October 25, 2026 14:08
8f9e493 to
35f1816
Compare
This was referenced Oct 25, 2026
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.
What
The PQ2_0 multi-column mat-vec from #381 needs no per-weight decode: the activation layout is permuted so the raw 2-bit codes pair with the activation bytes.
On H200 it is also the faster 1-column kernel for the larger projections. Kernel times, including the activation quantize:
Plain decode calls the 1-column mat-vec with fused bias (the residual) and fused gate+up+GLU. The kernel therefore gets the same epilogue as
mul_mat_vec_q:x_biasis added to the result;gate_biasis added and the GLU op is applied.Fusion is a template parameter. The unfused instantiation, used by every 3–8 column verify call, compiles to the same code as before. An earlier runtime bias check cost
mc<8>12–14% (27.2 → 31.0 µs) and DFlash7 −5%.Scope:
GGML_CUDA_PQ2_MC_MINsets the lower bound;3gives the old behaviour.Results on prism bf8c069 (H200, 9B PQ2_0, job 31830)
27B unaffected (−0.1 to +0.3%). 2B PQ2_0 with #395: +7.5 to +7.8%. Tests: MUL_MAT_VEC_FUSION 538/538, MUL_MAT 1669/1669, Hadamard fusion suites pass.
Earlier results (H200, 9B PQ2_0, prism 97ea5ae, job 31406)
GGML_CUDA_PQ2_MC_MIN=3Exactness: not bit-identical to the generic 1-column kernel. The integer dot products are exact, but the float accumulation order differs. Greedy tokens are identical on 3 of 4 prompts; one near-tie flips (gen-lru, no spec). This is the same class as #381.
Stacked: on #395 + #396 with
GGML_CUDA_GDN_FUSION=1, no-spec decode is +5.3 to +5.8% (370 → 390 tok/s, job 31362).27B (PTQ1_0): not affected, since it uses a different weight type. No spec −0.1 to 0%, MTP2 −0.5 to +0.2%, tokens identical.
Tests
MUL_MAT_VEC_FUSION525/525, including new PQ2_0 gate / bias / gate+bias cases at 1, 2, 4 and 8 tokens, K=4096.MUL_MAT1666/1666.