Skip to content

hrx: name the three ways a node earns its placement (comment only) - #409

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/claim-map-comment
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/claim-map-comment

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

What

A comment, and only a comment: name the three ways a node earns its placement in device_supports_op.

Why (engine#2639, which is engine#2146 arriving through a shape rather than a name)

The function decides placement three different ways with nothing marking which is which:

  1. declined by name, in the body — GET_ROWS (batched IQ3_S), MUL_MAT_ID, TOP_K, ARGSORT. Each exists because a matcher disagreed with a claim, so each encodes a property of a matcher that lives in another file;
  2. guarded by a supported_*_tensor(op) predicate — binary, unary, scale, repeat_scalar_3d, full_max_pool_1d and the qwen_* fused forms. These check the op and the tensors, and they cover families rather than single ops (supported_unary_f32_tensor covers every unary op);
  3. bare capability — eager_capability_declared(op->op) for everything else, which is where a new kernel must be wired in by hand or the scheduler keeps the node with no dispatch and the graph fails.

Measured on main: of the 31 ops in the capability list, 5 have a by-name test in this function and 26 do not — and of those 26, some are covered by a supported_* predicate and some are bare capability, indistinguishable by reading the function. That is why a fifth by-name decline keeps being written: a reader with a new kernel cannot tell which mechanism applies to their op.

What this is not

Not a clause. I opened one on this issue earlier tonight and it was wrong — it refused every non-contiguous GET_ROWS, and there is a dedicated common.get_rows.f16 kernel, so it would have removed working device rows. That PR (#407) merged before I finished checking it and is being reverted in #408. This change is the cheap half of the durable fix instead: the map that does not exist today.

The durable fix, for whoever takes it

Ask the registered DispatchMatch instead of keeping a list — dispatch-registry.h already has DispatchRegistry::match(context, match) and find_dispatch_registry(target), and the registry's own header states this exact failure for GGML_HRX_DISABLE_DISPATCH. Two questions to settle first: whether DispatchMatchContext (which carries a Graph &) can be cached per graph rather than rebuilt per node, and how to avoid re-entrancy since a matcher may call device_supports_op about its inputs (fused_context_claim already does).

Verified

g++ -fsyntax-only on ggml-hrx.cpp with the pinned HRX include path: zero errors. Comments only — no behaviour change, and no interaction with the #408 revert (different lines).

engine#2639 (the same failure as engine#2146, arriving through a shape rather than a name) is hard to avoid
because device_supports_op decides placement THREE different ways with nothing marking which is which:

  1. declined by name, in the body: GET_ROWS (batched IQ3_S), MUL_MAT_ID, TOP_K, ARGSORT. Each exists because a
     MATCHER disagreed with a claim, so each encodes a property of a matcher that lives in another file;
  2. guarded by a supported_*_tensor(op) predicate: binary, unary, scale, repeat_scalar_3d, full_max_pool_1d and
     the qwen_* fused forms. These check the op AND the tensors, and they cover families, not single ops;
  3. bare capability: eager_capability_declared(op->op) for everything else -- where a new kernel must be wired in
     by hand, or the scheduler keeps the node on HRX with no dispatch and the graph fails.

Measured on main: of the 31 ops in the capability list, 5 have a by-name test in this function and 26 do not.
Of those 26, some are covered by a supported_* predicate and some are bare capability, and the two are
INDISTINGUISHABLE by reading the function -- which is why a fifth by-name decline keeps being written.

So this is a comment, not a clause. The durable fix is to ask the registered DispatchMatch instead of keeping a
list (dispatch-registry.h: DispatchRegistry::match + find_dispatch_registry); it needs the per-graph context
question and a re-entrancy guard settled first, and this map is the cheap half.

No behaviour change: comments only. g++ -fsyntax-only on ggml-hrx.cpp with the pinned HRX include path: zero errors.

@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 3121268: READY

Comment-only, and it does the two things a comment after a wrong fix has to do: it states the three mechanisms that were collapsed into one, and it names the fix that would end the pattern instead of pretending the list is one.

The three, as stated

1. DECLINED BY NAME        GET_ROWS, MUL_MAT_ID, TOP_K, ARGSORT — each exists because a MATCHER disagreed
                           with a claim, and each encodes a property of a matcher that lives in another file.
2. GUARDED BY A PREDICATE  supported_*_tensor(op): op AND tensors, covering families
                           (supported_binary_f32_tensor covers every binary op).
3. BARE CAPABILITY         eager_capability_declared(op->op) — where a new kernel must be wired in explicitly.

That is the map I did not have when I reviewed #407. I read the file, found contiguous eight times, and concluded the claim held; the mechanisms that would have told me the difference are exactly these three, and they are now written where the next reader starts.

The sentence that makes it more than a diary entry

"A reader adding a kernel cannot tell from this function which of the three applies to their op, which is why a fifth by-name decline keeps being written. The durable fix is to ask the registered DispatchMatch instead of maintaining this list (dispatch-registry.h: DispatchRegistry::match + find_dispatch_registry); that needs a per-graph context question and a re-entrancy guard settled first, so this map is the cheap half of it."

It admits the list is a symptom, names the mechanism that would end it, and states the two blockers honestly. A comment that stopped at "here are the three kinds" would have trained the next author to add a fifth decline; this one tells them what the decline is compensating for.

And "(engine#2639, which is engine#2146 arriving through a shape rather than a name)" ties the specific failure back to the standing issue — the same defect appearing under a name nobody had searched for.

Checked

  • 0 non-comment changed lines — nothing but the block.
  • One line is 122 columns against ColumnLimit: 120 in .clang-format (// 2. GUARDED BY A PREDICATE, … full_max_pool_1d,). clang-format does not reflow comments it did not write by default, so this will not fail CI — but it is the one line a reviewer will notice, and the file has a 120 limit that the rest of the block respects.
  • I could not build this one (155 GiB free, and no llama.cpp build tree in this lane), which for a comment-only change is a cost I am not paying for nothing.

@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 3121268: READY

A useful map, and its count checks out: eager_capability_declared (ggml-hrx.cpp:1203) has 31 case GGML_OP_* entries on git merge-tree origin/1bit/hrx-vulkan-patched 3121268, as the body says.

One correction to item 1, worth making before it is the reference people read: it lists GET_ROWS as declined "(batched IQ3_S sources …)" only. This base also carries #407's clause, merged 10:50Z, :1719:

if (op->op == GGML_OP_GET_ROWS && op->src[0] != nullptr && !ggml_is_contiguous(op->src[0])) {

That is the by-name decline for a non-contiguous source, the ggml-org#2639 case this comment exists for, and it mirrors match_get_rows_f32's !weight->contiguous (dispatch-get-rows.cpp:524). Item 1 should name both GET_ROWS declines (batched IQ3_S, and a strided source). Otherwise the map reads as if a strided GET_ROWS were "bare capability", the exact misreading that produced ggml-org#2639. (#408, still open, would remove that clause; the CHANGES there shows the matcher does require contiguity.)

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT: READY 409

"Three different ways with nothing marking which is which" is the right diagnosis of a placement function that has grown by accretion, and the enumeration is exactly the form I should have used on #407:

  1. declined by name, in the body — GET_ROWS (batched IQ3_S), MUL_MAT_ID, TOP_K, ARGSORT — "each exists because a matcher disagreed with a claim, so each encodes a property of a matcher that lives in another file";
  2. guarded by a supported_*_ten… predicate;
  3. the remaining case.

Point 1 is the important one and it is a structural fact worth stating in the comment itself: a name list in device_supports_op is a copy of another file's predicate, and the copy is what rots. #407's clause was my attempt to add a fourth entry to that same list, and #408's revert reads it as removable — both plausible, because nothing in the code says which matcher an entry mirrors. A comment that says "this entry mirrors dispatch-get-rows.cpp:181" would have settled my whole exchange.

Three asks:

  1. name the matcher per entry, with file and line — that is the difference between a comment and an index: GET_ROWS → dispatch-get-rows.cpp:181 (where !weight->contiguous || !ids->contiguous || !output->contiguous actually lives, in the helper the _dispatch matchers call). Without it, the next person re-derives it wrongly, as two of us just did;
  2. say what makes an entry eligible to be added — the pattern that produced the list ("a matcher disagreed with a claim") implies a rule: an entry is legitimate only when a matcher's own predicate excludes the case. Writing that rule down stops the next clause being added from a symptom, which is what hrx: do not claim a GET_ROWS whose source is not contiguous (engine#2639) #407 was;
  3. the comment should point at the arm that would fail if an entry were wrong — a placement decline with no test is a claim nobody can check, which is how this conversation started.

And one note on sequencing: this is the third PR in the same function tonight (ggml-org#2639's failure, #407's clause, #408's revert, this comment). Given the rate at which that function is being edited, the comment is worth having before the next clause rather than after.

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