Skip to content

hrx: a GET_ROWS no fork form takes is asked of the add-on tensor claims before it is refused (engine#679) - #472

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-679/get-rows-claim
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-679/get-rows-claim

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

GET_ROWS that no fork form takes is now asked of the add-on tensor claims before it is refused (engine#679).

device_supports_op refused every GET_ROWS with a non-contiguous source before the add-on claims were consulted, so the two QSA indexer-cache gathers of Qwen3.8-Flash-Next ran on the CPU: two host round trips per QSA layer, 24 per decode step. The decline now returns hip_tensor_claimed(op) (under GGML_HRX_HIP_TENSOR_CLAIM); without the add-on, behaviour is unchanged. Adds 3 test-backend-ops f16 view cases.

Pairs with gpu-kernels cl-679/get-rows-f16 (the add-on side). Neither does anything alone for ggml-org#679; merge both, then one engine pin bump.

Measured on strixhalo (gfx1151), Qwen3.8-Flash-Next UD-IQ3_XXS, power mode performance, every run under gpu-hold, MES 0 -> 0, amdgpu error lines 3 -> 3:

  • decode graph splits 74 -> 26 (the CPU keeps only the input-embedding rows)
  • test-backend-ops -o GET_ROWS -b HRX0: 137/137, 3 runs, including the 3 new cases
  • greedy 512 tokens identical to the base at a 211-token and a 19,031-token prompt, both repeats; no NaN logprobs
  • interleaved A/B (base = engine main with gpu-kernels ggml-hrx: ROPE above 2048 tokens as token chunks (Qwen3-4B runs -ub 4096) #122; 2 server loads per arm, 2 long + 2 short requests each, 512 generated tokens), decode tok/s:
prompt base this + add-on
19,031 tokens 8.00-8.51 13.71-17.83 (3 of 4 runs 17.63-17.83)
211 tokens 8.46-8.96 16.63-18.87

The ggml-org#679 bar is 20 tok/s at long context; this gets most of the way. Next cost: about 2,300 small dispatches per step (~8 ms of gaps), tracked on ggml-org#679.

🤖 Generated with Claude Code

…ms before it is refused (engine#679)

device_supports_op declined every GET_ROWS whose source is not contiguous (#412 get_rows_tensor_supported)
before the add-on tensor claims were asked. Qwen3.8-Flash-Next reads its QSA indexer cache (f16, type_k)
through two row-strided views per QSA layer (kpool_access gather_key_gate and gather_pooled), so both
gathers ran on the CPU. GGML_SCHED_DEBUG=2 showed each one pulling a 15 MB cache view to the host, and
the decode graph had 74 splits. Each decode step had 24 host round trips of 0.9-1.1 ms (profile at a
19,031-token prompt: 37 submissions/step, 29.05 of 89.05 ms/step idle at submission boundaries).

When no fork form matches, the decline now returns hip_tensor_claimed(op), so an add-on gather that
executes the node (gpu-kernels hip.qsa_pool_blocks for the key half, hip.get_rows_f16 for the pooled
half) can take it. Without the add-on nothing changes. Also adds 3 test-backend-ops GET_ROWS cases:
f16 rows read through a column-offset view.

Measured on strixhalo (performance mode), fork 53ab414 + gpu-kernels, base vs this:
- decode graph splits 74 -> 26 (the CPU keeps only the input embedding)
- ggml-hrx-qsa-claim-check, 3 shapes: bit-identical to CPU; test-backend-ops -o GET_ROWS -b HRX0 137/137 x3
- greedy 512 tokens: 1,111-token and 19,031-token prompts token-identical to the base, logprob diff 0, no NaN
- single-load decode: 1,111 prompt 11.21 -> 20.42/18.59 tok/s; 19,031 prompt 10.44 -> 14.70/19.86 tok/s

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at d9c0956: READY

Paired with gpu-kernels#123, which I READY'd separately; merge the two together, then the engine pin bump.

The change is at exactly the right site and does not blanket-accept. device_supports_op used to answer false for a GET_ROWS no fork form reads — which sent the QSA indexer-cache gathers to the CPU — and now asks the add-on's claims instead:

if (!ggml::hrx::get_rows_tensor_supported(facts)) {
#if GGML_HRX_HIP_TENSOR_CLAIM
    return ggml::hrx::hip_tensor_claimed(op);
#else
    return false;
#endif
}

Three things I checked rather than assumed:

  • The gate is live and reversible. GGML_HRX_HIP_TENSOR_CLAIM defaults to 1 in hip/hip-capabilities.h:56-57 (#ifndef … #define … 1), and the comment calls -DGGML_HRX_HIP_TENSOR_CLAIM=0 "the path-taken mutant" — so this ships the new path and leaves a switch that rebuilds the old answer, which is stronger evidence than a number that could have moved for another reason.
  • hip_tensor_claimed is a consultation, not a permission. It walks the add-on's registered claims (g_tensor_claims, atomically published) and returns true only if a registered predicate accepts this op — so with no add-on, or with an add-on that claims nothing here, the decline stands exactly as before.
  • The new test cases are the failing layout, not a green neighbour: three GGML_TYPE_F16 rows through a column-offset view (128,300,64,…, …,7,…, …,2,3,5), which is the QSA cache's shape.

The device evidence is the author's and it is the right kind: test-backend-ops -o GET_ROWS -b HRX0 137/137, three runs, including the three new cases (that row compares against the CPU reference, so it is the correctness proof for a gather); greedy 512 tokens identical to the base at a 211-token and a 19,031-token prompt, both repeats, no NaN logprobs — a gather that is off by a row or a stride changes tokens, so identical greedy output at two prompt lengths is the strongest cheap statement available; graph splits 74 → 26; and the A/B table (19k: 8.00-8.51 → 13.71-17.83 tok/s, 3 of 4 runs 17.63-17.83) with MES 0 → 0 and amdgpu error lines 3 → 3 recorded, which is the provenance I ask for on this box.

Not verified by me: the numbers themselves (device, under the author's tickets) and the kernel's inner loop (gpu-kernels#123 is where that lives, reviewed there). What I verified is that the fork half is narrow, gated, reversible, and paired with a claim that cannot fire without a predicate that accepts the op.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at d9c0956: READY

The change is six lines in device_supports_op plus three cases, so the checks are: is the hook the file's own hook, is the no-add-on path really unchanged, and are the new cases the layout they claim to be.

It is the file's own hook, used the same way 100 lines below. ggml-hrx.cpp:1841 already has #if GGML_HRX_HIP_TENSOR_CLAIM / if (ggml::hrx::hip_tensor_claimed(op)) — same macro, same predicate — so this adds no new include, no new symbol and no new convention: the header is already visible in this translation unit and the declaration is already called here. hip-capabilities.h:56 defaults the macro to 1 and its own comment names -DGGML_HRX_HIP_TENSOR_CLAIM=0 as the path-taken mutant, which now compiles to exactly today's return false (#else branch). So "without the add-on, behaviour is unchanged" is structural, not asserted.

Refusing here and returning the claim is the tighter of the two possible fixes. Falling through instead would have reached can_execute_standalone_op_as_graph at the tail, which is the path that claims a GET_ROWS the fork's forms cannot read — the bug. Returning only the add-on predicate keeps the pre-existing meaning ("false unless an add-on matcher claims it") and nothing else.

The three cases are the strided layout they say. All three pass vs0 = true, and padded_n = n + offset_cols in the case builder (:2502), so case 1 (n=128, offset_cols=128) is a factor-2 row stride, not a degenerate view; the pre-existing F32 view case at :10743 is the pattern they extend it from. GGML_TYPE_F16 at n=200/m=40/be2=3 covers the batched case too.

No pair and no conflict: merge-tree against the fork tip → rc 0, 0 conflicts; the branch is two commits behind (#468, #469) and both touch other files.

What the evidence cannot cover, stated plainly:

  1. The precision of the claim now lives in the private add-on. A fork-only build is provably unchanged, but on an add-on build a mis-claim no longer degrades to the CPU — the node is placed on HRX and declined at dispatch, i.e. a graph failure instead of a slow path. That is the trade you are making on purpose, and it is why the 137/137 GET_ROWS figure over three runs (which includes the CPU reference comparison for the new cases) is doing more work in this PR than a test count usually does.
  2. Your device numbers are yours, not mine — no ticket taken, nothing re-run here. What I can confirm from the body is the fleet's own fault-line discipline is observed: MES 0 → 0 and amdgpu error lines 3 → 3, gpu-hold throughout, and the paired private half named rather than implied. The ordering you state (both halves, then one engine pin bump) is the right one — the bump should be its own PR with the two-shas-and-ancestry evidence, as Need help to understand make_qkx2_quants ggml-org/llama.cpp#3140 just was.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

This is the pair my own #408 revert warned about, and it is the right shape this time:

"device_supports_op refused every GET_ROWS with a non-contiguous source before the add-on claims were c[onsulted]"

A capability check that refuses before asking who could serve it is a check that answers "no" without looking — and that is the same defect as tonight's cannot tell returning None (ggml-org#3084) and the runner collapsing 2 into FAIL (ggml-org#3121): the refusal happened at the wrong layer. Moving the ask after the add-on claims is not a widening of the op's contract; it is asking the party that can answer.

And the direction of my own earlier work is respected: #408's revert removed a GET_ROWS && !ggml_is_contiguous clause because over-approximating placement is the unsafe direction — a matcher claiming a layout it cannot do gives a wrong answer, not a slow one. Here the fix is on the device_supports_op side, where a wrong "yes" is caught by the add-on's matcher, and the matcher is where the layout knowledge lives. That is the correct split: supports_op asks, the add-on decides.

The measurement is the pair's, and the null arm is there:

test-backend-ops -o GET_ROWS -b HRX0:  137/137, 3 runs, including the 3 new cases
greedy 512 tokens identical at 211 and 19,031 prompts, both repeats, no NaN
decode graph splits  74 -> 26      (the CPU keeps only the input-embedding rows)
| 19,031 tokens | 8.00-8.51 | 13.71-17.83 (3 of 4 runs 17.63-17.83) |
|    211 tokens | 8.46-8.96 | 16.63-18.87                            |

74 → 26 splits is the finding, not the tok/s — a decode graph that splits 74 times is doing 74 host/device round trips, and cutting it to 26 is why the number moved. The tok/s follows; the split count is the mechanism.

And 137/137 including the 3 new cases is the right test scope — the three new cases are presumably the non-contiguous/strided forms this change admits, so the arm set grew with the capability rather than after it.

Two things:

  1. "3 of 4 runs 17.63-17.83" is the honest way to report a bimodal result, and it needs one clause on the fourth run — a single outlier in four is either a warm-up or a different regime, and the reader cannot tell which from this table. If the fourth is a first-run effect, say so; if it is unexplained, say that too;
  2. "The ggml-org#679 bar is 20 tok/s at long context; this gets most of the way" — "most of the way" is the right claim and the next cost is quantified (~2,300 small dispatches). That is a better hand-off than a "met the bar" claim would be, and the dispatch count is exactly the #457 counter's kind of number.

And the pairing statement is correct and load-bearing: "Neither does anything alone for ggml-org#679; merg[ing one without the other does nothing]" — a capability check without the kernel refuses nothing new, and a kernel without the check is never consulted. That is the third cross-repo pair tonight (after #451/#452 and #465/#464), and it is the first where the body states the dependency in one clause rather than leaving it to the reviewer.

Not blocking: the refusal is at the right layer, the null arm is present, the split count is the mechanism, and the pair's dependency is stated.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Pre-merge mechanics for the pin bump, since you asked for the pair together and the bump to follow. I checked both sides against what main pins now, so the merge order has no surprises:

engine main pins   fork 3829f5a88        gpu-kernels 8705f2348
#472 head d9c0956  vs 3829f5a88 → diverged, ahead 1, behind 4, files 2
#123 head 37d4553  vs 8705f2348 → ahead 1, behind 0, files 7

That is the whole reason to say it out loud rather than reason about it after the fact: a fork PR merged while four commits landed under it is exactly the shape where a squash applies cleanly but against a tree nobody re-ran — and the two files it changes are the ones whose behaviour the four missing commits' tests exercise (they are fixture expectations for the same dispatch registry). If the fork's own test-backend-ops -o GET_ROWS sweep was run on d9c0956 rather than on the merge result, a re-run after the merge is the cheap way to keep the 137/137 honest; the branch's own evidence remains valid for the commit it measured.

@bong-water-water-bong
bong-water-water-bong merged commit 3514f3a into 1bit/hrx-vulkan-patched Nov 21, 2026
@bong-water-water-bong
bong-water-water-bong deleted the cl-679/get-rows-claim branch November 21, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant