Repository navigation
hrx: K-quant decode kernels for 2-8 tokens (MTP / speculative verify) - #46
Merged
bong-water-water-bong merged 1 commit intoSep 30, 2026
Merged
Conversation
Speculative decoding verifies 2-4 tokens per step; those batches fell off the one-token K-quant kernels onto AMD's low-token and prefill WMMA kernels. - ops/kquant_decode_f32.loom: ggml_kquant_swiglu_decode_tokens_f32 and ggml_kquant_mul_mat_decode_tokens_f32 (token count 2..8, compile-time). Each lane dequantizes its 16 weights once per block (per-format "lane weights" functions derived from the one-token ones: the weights and the positions of their runs) and applies them to every token; x loads are 16/8/4 wide by format. Reference kernels loop over tokens; five 3-token check.cases (all formats covered), all twelve cases pass with the access sanitizer. - dispatch-kquant-decode.cpp: matches 1..8-token MUL_MATs (the common matcher's decode form only admits one token); projection + residual ADD also registered at 185, above common.mul_mat_postops.f32_f32_wmma (180), which took the multi-token projections through the prefill WMMA kernel. Qwen3.8-27B UD-Q4_K_XL + MTP head (n3, p-min 0.75), HRX0, llama-server: 20.1/16.4/17.6 -> 22.5/17.7/19.0 tok/s (code/prose/translate prompts; draft acceptance unchanged 97-98/88/79%); GPU busy for the same request 9134 -> 8123 ms. Plain decode 11.9/12.0/12.5 -> 12.1/12.2/12.7. test-backend-ops -o MUL_MAT -b HRX0 passes (n = 1..6 cases for all these types). Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
merged commit Sep 30, 2026
dad19ad
into
1bit/hrx-vulkan-patched
10 of 24 checks passed
This was referenced Sep 30, 2026
Pin llama.cpp dad19ad: lossless SwiGLU everywhere, MTP verify kernels on HRX
1bit-MONSTER/engine#239
Merged
bong-water-water-bong
added a commit
that referenced
this pull request
Nov 1, 2026
… (silent stale grid) (#168) The recipe said "list the parameters that change the grid" without saying what a miss costs, and a miss is not an error: launch_fn runs once per executable cache entry, the key holds only the workload parameters, so an unlisted parameter read by the launch function freezes the first case's grid for every later case and the kernel quietly covers less than it was asked to. Written from the V4.1 indexer gate (gpu-kernels #46), where n_stream was left out: test-backend-ops -o LIGHTNING_INDEXER -b HRX0 gave 4/12 - all ns=1 cases green, all ns=4 cases wrong by one stream plane (inf mismatch: HRX0=0.943650 CPU=-inf; ERR = 2.909230024) - while the same kernel driven straight through hipModuleLaunchKernel is correct at 4 streams to 3.9e-03. That is why the standalone harness missed it and the suite did not.
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.
Adds K-quant decode kernels for batches of 2–8 tokens, the size of MTP and speculative verify steps. Before this, those steps fell off the one-token K-quant kernels onto AMD's low-token and prefill WMMA kernels.
Changes
ops/kquant_decode_f32.loom:ggml_kquant_swiglu_decode_tokens_f32andggml_kquant_mul_mat_decode_tokens_f32. The token count (2–8) is fixed at compile time.dispatch-kquant-decode.cpp:common.mul_mat_postops.f32_f32_wmma(180), which was taking multi-token projections through the prefill WMMA kernel.Results
Qwen3.8-27B UD-Q4_K_XL + MTP head (n3, p-min 0.75), HRX0, llama-server:
Vulkan with MTP does 34.6 / 24.3 / 24.5 on the same prompts, so HRX is at 65–78%. A 4-token verify step still costs about 1.7× a 1-token step, because the f32 multiply-adds on every token dominate. The next step is int8 activations, the way Vulkan's matrix-vector path does it.
Other models (llama-bench tg128 with the new projection+add matcher on vs off, idle GPU): Qwen3-0.6B 327.6 vs 325.9, Qwen3-Coder-30B-A3B 89.4–90.4 vs 90.3, ZAYA1-8B 94.3.
test-backend-ops -o MUL_MAT -b HRX0passes, including the n = 1–6 cases for all these weight types.🤖 Generated with Claude Code