Repository navigation
hrx: K-quant / IQ4 / Q8_0 decode projections in GGUF block layout - #42
Merged
bong-water-water-bong merged 1 commit intoSep 29, 2026
Merged
Conversation
One-token (decode) projections on Q4_K, Q5_K, Q6_K, IQ4_NL, IQ4_XS and Q8_0 weights, read straight from their GGUF blocks with f32 activations (no repack, no activation quantization), in our own files: - ops/kquant_decode_f32.loom: ggml_kquant_swiglu_decode_f32 (FFN gate/up pair fused with SwiGLU) and ggml_kquant_mul_mat_decode_f32 (projection with an optional residual ADD). One wave64 per row, 16 lanes per 256-value block, 8-byte weight loads. IQ4 table values are read across lanes (lane c of each 16-lane group holds kvalues_iq4nl[c]): a 16-entry vector.table.lookup lowers to 15 v_cndmask per byte on gfx11 and made IQ4_XS compute-bound (108 GB/s). Scalar reference kernel and six check.cases (every format, both kernels, a half-full last workgroup). - dispatch-kquant-decode.cpp: matchers at token count 1. SwiGLU pairs at priority 305 (below the int4 lowrow path); projections at 85, above only the generic common.mul_mat f32 matchers. Mixed-quant models (Unsloth UD-Q4_K_XL) pair these types freely per layer and previously took the generic dequantize-4-values dot kernels. Qwen3.8-27B UD-Q4_K_XL, HRX0 (gfx1151), decode token 104.7 -> 89.4 ms busy; FFN gate/up pairs 105-176 -> 197-222 GB/s, projections ~210-224 GB/s. Results in the PR description. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
merged commit Sep 29, 2026
ade79d4
into
1bit/hrx-vulkan-patched
10 of 24 checks passed
This was referenced Sep 29, 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.
Decode (token count 1) projections for Q4_K, Q5_K, Q6_K, IQ4_NL, IQ4_XS and Q8_0 weights, read straight from their GGUF blocks with f32 activations. There is no repack and no activation quantization. All code is in our own files; the hookups are one include and one call in
dispatch-common.cpp, plus CMake and manifest entries.ops/kquant_decode_f32.loomhas two kernels:ggml_kquant_swiglu_decode_f32: the FFN gate/up pair fused with SwiGLU.ggml_kquant_mul_mat_decode_f32: a projection with an optional following residual ADD.vector.table.lookuplowers to 15v_cndmaskper byte on gfx11, which made IQ4_XS compute-bound: 1492 instructions per step, down to 584 with no selects; IQ4_XS pairs went from 108 to 206 GB/s.check.cases covering every format, both kernels and a half-full last workgroup. All pass under--sanitizer=accesson gfx1151.dispatch-kquant-decode.cppholds the matchers:common.mul_matf32 matchers (80/70/60).Mixed-quant GGUFs (Unsloth UD-Q4_K_XL) pair these types freely per layer. Before this change they took the generic kernels, which dequantize 4 values at a time.
Results (gfx1151)
Decode, tg128, interleaved with Vulkan (weekly build), thermal guard on:
27B decode token (profiled): 104.7 ms busy before, 89.4 ms after.
ffn_down(2.8 ms), three Q3_K FFN pairs, and the smallssm_alpha/ssm_betaprojections, which are latency-bound at about 16 µs each.Accuracy, wikitext
-c 128 --chunks 4with-ub 1(every token decode-shaped):The ZAYA figures are all within ±9.1. The before path used q8 activations for Q4_K; this one keeps f32.
test-backend-ops -o MUL_MAT -b HRX0: all cases pass (2/2 backends).Thermals: the 27B HRX run peaks at 90–93 °C on this box (Vulkan: 67 °C); one of the two HRX rounds was stopped by the 93 °C guard.
🤖 Generated with Claude Code