Skip to content

hrx: Q3_K and IQ3_S in the K-quant decode kernels - #43

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-kquant-q3k
Sep 29, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-kquant-q3k

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Follow-up to #42. Adds Q3_K and IQ3_S to both K-quant decode kernels: the fused SwiGLU gate/up kernel and the projection kernel. These were the last two types in Unsloth's UD-Q4_K_XL that still went through the generic decode kernels.

  • Q3_K: each lane (n, j, h) owns one 16-value run that has a single 6-bit scale. The blocks are only 2-byte aligned, so the 2-bit codes and the hmask bit are read with 16-bit loads.
  • IQ3_S: the kernel needs the 512-entry iq3s_grid from ggml-common.h (MIT).
    • Loom rodata can't be read from amdgpu kernels: global.load has no target-low contract.
    • Looking entries up in a constant vector would compile to chains of selects.
    • So when a weight is IQ3_S, each workgroup writes the grid into 2 KiB of workgroup memory: each wave writes one 128-entry chunk, then a workgroup barrier.
    • Other formats compile to the same instruction counts as before, checked by disassembly.
  • Tests: reference paths and check.cases for both formats. All seven cases pass under the access sanitizer.

Results

Qwen3.8-27B UD-Q4_K_XL on HRX0 (gfx1151):

  • Q3_K SwiGLU pairs: 102–111 GB/s before, 189–190 GB/s now.
  • The IQ3_S ffn_down: previously 2.83 ms per token on AMD's generic kernel; now handled by the projection kernel.
  • Token busy time: 89.4 ms before, 85.4 ms now.
  • Decode, tg128: 12.15 tok/s (was 11.60), against 12.48 on Vulkan: 97.3%.
  • Decode-shaped wikitext PPL (-ub 1): 7.1595; CPU 7.1475.
  • test-backend-ops -o MUL_MAT -b HRX0 passes, including the IQ3_S and Q3_K n=1 cases.

ZAYA1-8B decodes at 94.0 tok/s.

The 27B on HRX still runs hot: it peaks at 91–93 °C and draws about 130 W, against 99 W on Vulkan. One gate-bench round was stopped by the 93 °C guard.

🤖 Generated with Claude Code

Extends ops/kquant_decode_f32.loom (both kernels) and its matchers to Q3_K
and IQ3_S, the last two types of Unsloth's UD-Q4_K_XL still on the generic
decode kernels.

- Q3_K: lane (n, j, h) owns one 16-value run with a single 6-bit scale; 2-bit
  codes and the hmask bit via 16-bit loads (blocks are 2-byte aligned).
- IQ3_S: the 512-entry iq3s_grid (ggml-common.h, MIT) cannot live in Loom
  rodata for amdgpu kernels (no global.load lowering), and a constant-vector
  lookup would be select chains; each workgroup writes it to 2 KiB of
  workgroup memory (one 128-entry chunk per wave, then a barrier) only when a
  weight is IQ3_S. Other formats compile to the same code as before.
- Reference paths and check.cases for both (seven cases, access sanitizer).

Qwen3.8-27B UD-Q4_K_XL, HRX0 (gfx1151): Q3_K SwiGLU pairs 102-111 -> 189-190
GB/s; the IQ3_S ffn_down 2.83 ms -> in the projection kernel; token busy
89.4 -> 85.4 ms; decode 11.60 -> 12.15 tok/s (Vulkan 12.48); ub1 wikitext PPL
7.1595 (CPU 7.1475). test-backend-ops -o MUL_MAT -b HRX0 passes. ZAYA1-8B
decode 94.0 tok/s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the ggml label Sep 29, 2026
@bong-water-water-bong

Copy link
Copy Markdown
Author

The three windows matrix jobs shown as failing were cancelled by the runner (job conclusion cancelled, no failed step); they passed on #42 and HRX is not built on Windows. ubuntu and windows pass. Merging.

@bong-water-water-bong
bong-water-water-bong merged commit f81814a into 1bit/hrx-vulkan-patched Sep 29, 2026
7 of 24 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hrx-kquant-q3k branch November 12, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant