Repository navigation
hrx: a q4_0 KV cache's SET_ROWS goes to the add-on hook too (engine #679) - #335
Conversation
…gml-org#679) match_set_rows_addon offered only a q8_0 cache to the HIP add-on, so -ctv q4_0 left the KV write claimed with no dispatch (unsupported HRX node: SET_ROWS output=q4_0). The hook still decides per format whether it has a kernel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- the gate names both types and nothing more, which is what keeps the two halves in step
The condition is the design: (output->type != GGML_TYPE_Q8_0 && output->type != GGML_TYPE_Q4_0) || rows->type != GGML_TYPE_F32 || ... sends a cache format to the add-on hook only when it is one of the two the hook can write. A "any quantised type" test would have routed q5_0 and q4_1 at a hook that has no kernel for them, and the failure would have looked like a missing kernel rather than a wrong gate.
And the pair is safe even if it drifts, which is worth writing down because it is the reason duplicating the list in two repos is acceptable: set_rows_format() in the addon returns nullptr for anything that is not Q8_0/Q4_0, and the matcher refuses on nullptr. So if one repo gains q5_0 and the other does not, the node is not claimed and falls to the existing path -- no wrong stride, no silent corruption, just a slower but correct route. That is the property that makes this two-repo handshake reviewable at all; one sentence next to the condition would spare the next reader working it out.
Nothing else: 2 lines, and they name the same two formats the kernels implement (set_rows_q8, set_rows_q4_0), so the comment and the condition cannot disagree about what the hook covers.
|
VERDICT: READY at The defect, in the error message
That last clause is the design that makes four lines correct: the hook offers, the add-on decides, so adding a format to the offer list cannot silently route something to a kernel that does not exist. The alternative (the hook claiming and dispatching) is how #331/#338-style mismatches happen. And the error message itself is the good kind — it names the node and the format, which is why this was a four-line fix rather than an afternoon. Two asks
Why four lines deserve a verdictBecause the split is the interesting part: claim-time vs run-time. A missing dispatch that surfaces as |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 0c48ebb: READY
I checked the fallback contract at both ends before believing the widening is safe, because widening a matcher is how a q4_0 cache ends up in a kernel that writes q8_0 layout. It is safe:
// match_set_rows_addon, dispatch-rope-set-rows.cpp
if (!hip_set_rows_dispatch(args, dispatch_match)) {
return false; // the add-on declined → generic matcher runs
}and in the add-on as it is pinned today, before gpu-kernels#75:
a.rows->type != GGML_TYPE_F32 || a.output->type != GGML_TYPE_Q8_0 || // ← q4_0 is refused hereSo with the pinned add-on, offering a q4_0 cache gets declined, the generic matcher logs "input or output format is unsupported" and does not match, and the graph falls back to the ordinary path. Merged alone this PR is inert and correct; the win arrives when the add-on can accept it. That is the right way round for a dispatch change and it means no coordinated pin bump is required to be safe — only to be fast.
The measurement is the kind I can act on: one gpu-hold ticket, gfx1151, test-backend-ops -o SET_ROWS -b HRX0, one binary per arm, 73/73 → 75/75, with the two newly-supported shapes named (f32 → q4_0, i64, ne=[256,5,1,3] and ne=[256,5,7,3]). Before/after on the same box with the CPU as the oracle is the only form of this claim that means anything.
And the scope note is honest in the way that matters: "Not in this PR: reading a q4_0 V in flash attention", with the reason (the HRX FA matchers take f16 K/V). A partial enablement that says which half is missing is worth more than one that quietly implies the feature is complete.
Pairing note for the merge queue, not a condition: this PR readies the offer. gpu-kernels#75 is the accept, and I have put a CHANGES on it for a kernel-log-name collision (set_rows_q4_0 is registered with the log name set_rows_q8, so every q4_0 SET_ROWS would be attributed to the q8 kernel in rocprofv3). Merging #335 before #75 is harmless — it is the inert-and-correct side of the pair.
Refs engine#679 (item 3a, the write half).
match_set_rows_addonoffered only a q8_0 cache to the HIP add-on's SET_ROWS hook. A q4_0 V cache (-ctv q4_0) therefore left the KV write claimed, sincesupports_optakes SET_ROWS of any type, with no dispatch:unsupported HRX node: SET_ROWS output=q4_0[…]. The match now offers q4_0 as well. The hook still decides per format whether it has a kernel, so on a build whose add-on has no q4_0 write, nothing changes. One file, 2 lines.Measured (gfx1151, one gpu-hold ticket)
test-backend-ops -o SET_ROWS -b HRX0, one binary per arm. Both libraries are built with the add-on.29616ef+ add-on main.f32 → q4_0, i64, ne=[256,5,1,3]andne=[256,5,7,3]Not in this PR: reading a q4_0 V in flash attention. The HRX FA matchers take f16 K/V and the add-on's take f16 or q8_0, so
-ctv q4_0end to end fails one node later until that half lands.🤖 Generated with Claude Code