Repository navigation
hip : use native PQ2_0 unpacking in MMQ tile loader - #200
Conversation
Assisted-by: SWE-2 Max (Devin) Assisted-by: OpenAI Codex (Astra)
bri-prism
left a comment
There was a problem hiding this comment.
Agent review: posted by the maintainer's coding agent at their request.
No findings in this source pass. The HIP device-only substitution preserves the two four-symbol groups produced by the original byte-permute sequence, while leaving the other compilation paths unchanged.
HIP compilation and MMQ numerical tests were not executed here; those remain the platform gate for this narrow change.
Reviewed commit: 5476d46e95b5fb978f8f28f000298ac12cfe7403.
|
Agent benchmark follow-up, posted at the maintainer's request. Tested this head (
Important limitation: the allocated GPU had an unrelated host process holding substantial VRAM. It was idle at inspection, but exclusive access was not established, so these are exploratory measurements, not clean performance validation. We also used the newer public model generation in PQ2 format, rather than the model used in the original report. No end-to-end logit-parity claim is made. The results support the prefill-only direction of the change; decode's paired 95% interval was −4.28% to +2.78%. Bench settings: full GPU offload, flash attention enabled, f16 K/V, 8 CPU threads, batch and microbatch 512, one repetition per invocation. |
|
From my side, gfx1201 (2× AMD Radeon AI PRO R9700, ROCm, R9700 = gfx1201) data points, since those devices were compile-checked but not runtime-tested here.
I think prefill gain is consistent across all 5 rounds but much smaller on gfx1201 than the gfx1100 numbers (+20% vs ~2x) - decode unchanged as predicted. Note: these runs shared the GPU with a live 4-slot llama-server, so treat as relative A/B only. |
Overview
Use the existing
q2_0_symbols4_hiphelper in the PQ2_0 MMQ tile loader. On RX 7900 GRE, the isolated change improves Bonsai 27B prompt processing by about 2x at 512 and 2048 tokens, and 3.09x at 32 tokens.The loader currently unpacks each int16 with four
__byte_permcalls. HIP implements these through a software path. Two calls to the existing native AMD helper produce the same low/high groups of four signed-byte symbols. This follows the existing PQ2_0 vec-dot path; tile layout, scales, and accumulation are unchanged. CUDA/MUSA and HIP host compilation keep the original branch.Additional information
Tested on AMD Radeon RX 7900 GRE (gfx1100), Linux, AMD clang 22.0.0git. Control and candidate were built from
01041db99dae68529db58c6fc692a9ca623b30a2; the candidate adds only the five-line change in this diff. No decode tuning or activation-reuse patches are included. The branch is rebased onto9a9394a; the intervening upstream commit changes release configuration and DSPARK option-storage portability, not these kernels. Measurements below remain from01041db.Model:
Ternary-Bonsai-27B-PQ2_0.gguf(SHA-256e4781999f1997ef97ce0c58d05750835acc999d18d83ee6489ba7ac7b14cb5f6).Five paired
llama-benchinvocations per workload, alternating control/candidate order, with exclusive GPU access. Throughput is mean +/- sample SD in tokens/s; gain is the mean paired ratio.The tg128 confidence interval includes zero: this is a prefill improvement, not a demonstrated decode gain. The paired 95% lower confidence bounds for pp32/pp512/pp2048 are +207.05%, +100.58%, +95.01%, respectively.
Validation:
test-backend-ops test -o MUL_MAT -p 'type_a=pq2_0': 45 supported cases pass against the CPU reference on both builds; 33 unsupported cases are skipped on both.10.1473 +/- 0.94883on both builds. This is a limited sample, not a full-corpus evaluation.Reproduce each build:
For the benchmark table, repeat the bench command as five alternating control/candidate pairs for
(p,n) = (32,0), (512,0), (2048,0), (0,128).Related: #125 (existing native HIP unpack helpers), #116 (separate broader HIP optimizations).
Requirements