Conversation
Assisted-by: Devin SWE-2 max and Codex
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
PQ2_0 still uses the generic float mat-vec shader. On an AMD BC-250 (gfx1013/RDNA1, RADV, no cooperative matrices or accelerated integer dot), this dominates decode time. This adds a dedicated PQ2_0 shader and tunes the BC-250 path. It complements the PTQ1_0 work in #252 and extends the BC-250 tuning discussed in #229.
The shader reads each 34-byte PQ2_0 block through aligned 16-bit words, decodes each row once before looping over columns, and computes
d * (sum(q*y) - sum(y)). This algebraic reassociation changes floating-point rounding relative to the generic shader; tolerance-based operator tests pass on BC-250. The shader arithmetic matches the earlier deployed implementation used in our reference-comparison tests.BC-250 uses a 32-thread workgroup/subgroup and eight rows per workgroup (16 for five columns). For PCI
1002:13FE/ RDNA1 / no coopmat only, PQ2_0, BF16 and Q8_0 can use mat-vec through 16 columns. BF16/Q8_0 cover the supporting MTP operations; their existing shaders are reused. Other devices keep the existing launch geometry and eight-column limit, but PQ2_0's float mat-vec shader itself changes on them too.The PR excludes our packed FP16 prefill path, GDN/state-copy fusion, runtime tuning knobs, and measurement scripts.
Additional information
Based on
prismatadfffbe41; patch commit031212ec9. Both were built directly on BC-250 with GCC 16 and Vulkan enabled, Release, identical flags.Model: Ternary-Bonsai-2-27B-PQ2_0-MTP-Q8_0; MTP is not used by this llama-bench run.
-ngl 99 -fa 1 -ctk q8_0 -ctv q4_1 -b 2048 -ub 512 -t 6 -p 512 -n 128 -r 3.test-backend-ops test -b Vulkan0 -o MUL_MAT,MUL_MAT_ID -p 'type_a=(pq2_0|bf16|q8_0)'passed on both builds. Upstream: 476/476 tests passed; this PR: 514/514 tests passed. The new coverage includes columns 9 through 16, row tails, batch shapes and the 17408x5120 model shape. These are targeted operator tests. Full CI and an independent model-quality evaluation were not run on this extracted PR.Only BC-250 hardware is available for testing. The new shader also serves PQ2_0 float mat-vec on other GPUs, including the generated MUL_MAT_ID variants, so independent testing is welcome. No claim of cross-device performance parity is made.
Our earlier deployment tests compared against the previous deployed build: Korean and English/code KL top-1 agreement was 100%, with small perplexity differences. This demonstrates agreement with that reference, not an independent assessment of model quality. English long-context quality and semantic correctness of the real-request sample were not evaluated.
Requirements