Skip to content

hrx: device_supports_op decides placement without consulting the matcher that will run the node, so each disagreement becomes another hand-written decline #2704

Closed

Description

@bong-water-water-bong

What

device_supports_op decides placement from the op code, while the decision that actually matters at compute time is made by the registered dispatch matcher. Whenever the two disagree, the node stays on HRX with no dispatch and the graph fails with unsupported HRX node — and because the placement claim has no access to the matcher, each disagreement is fixed by adding one more hand-written decline.

This has happened at least five times: TOP_K (engine#2146, the =top_k name check), GET_ROWS (#407, fork), and the declines counted in the 11:24Z comment on engine#2639 — "ops claimed by eager_capability_declared 31, with a direct op->op == guard in that body 5".

Why the obvious fix is not a one-liner

The registry query takes a node context; device_supports_op does not have one:

struct DispatchMatchContext { const Graph & graph; const GraphNode * root_node; … };
bool device_supports_op(ggml_backend_dev_t dev, const ggml_tensor * op);   // a ggml tensor, no Graph/GraphNode

So "ask the matcher" needs either

  • (a) a registry entry point keyed by op code + tensor properties instead of by graph node — the closest existing shape is dispatch_weight_layout_eligible(const Value &), which is already value-level; or
  • (b) plumbing the HRX graph into the placement pass so the node can be looked up.

(a) is the smaller one: each matcher predicate begins by reading weight / ids / output properties, so a bool dispatch_accepts(ggml_op, properties) table generated next to the predicates cannot drift from them the way a hand-written clause does.

What #407 shows about the failure mode

#407's clause (!ggml_is_contiguous(op->src[0]) → decline) was reviewed twice on the wrong boundary: once by reading the contiguous hits in dispatch-get-rows.cpp (helpers, not matchers), once by reading each wrapper body (which delegates). Counting gates in each predicate instead gives

family predicate gates tensors gated
f32 3 weight, ids, output
f32_next 3 weight, ids, output
scalar_3d_f32 4 output, scales
scale_f32 1 output
rmsnorm_binary 3 output

so four of the five gate the source and the fifth gates only the output: nothing in this family accepts a strided source, which is why the hand-written clause is correct today and why a "narrow it per format" revert (llama.cpp#408) has nothing to narrow. The clause will need a sixth exception the next time a predicate tightens.

Scope of a first PR

  1. A properties-level accept query next to the matchers (dispatch_accepts(op, weight/ids/output properties)), generated or asserted against the predicates.
  2. device_supports_op consults it for the op families where a decline already exists, so the five hand-written declines can be removed one at a time with the existing rows as the regression set.
  3. A tests/hrx-backend-test.cpp row that asks the query directly (op + properties → accept/decline) and a mutant that makes one predicate stricter and expects the query to follow.

Unclaimed — needs an HRX dispatch owner. Filed from the engine#2639 pin review; the design notes are a handover from the llama.cpp#408 thread, not new measurements.

Activity

  1. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claiming this, and the first slice is up: llama.cpp#412 (cl-856/2704-get-rows-facts @ d273fb332, base 1bit/hrx-vulkan-patched, MERGEABLE, 7 files +310/−29).

    What I took, and the design decision that changed the shape of the fix

    Item 1 + 3 of the scope for GET_ROWS only, because that is the family where the divergence has actually cost a failure (#2639) and where #408 already did the derivation of which requirement to state. It is not one conjunctive predicate, and the reason is measured rather than stylistic: the family has two forms with different conditions —

    form matcher ids
    contiguous match_get_rows_f32 (+ f32_next, scale_f32, rmsnorm_binary) contiguous
    route-table match_get_rows_scalar_3d_f32 (qwen3.6-35b routed experts) strided on purpose (route_stride = ids->nb[1] / 4)

    so a flat ids contiguous in the placement predicate would refuse a path that dispatches — exactly what #408's derivation warns about — while every test that looks at one matcher at a time stayed green. The facts are therefore built once (dispatch-get-rows-support.h), each form is a named predicate that its own matcher calls, and device_supports_op asks the union: can some form execute this node.

    What that buys, in numbers

    Host-only row (tests/test-hrx-get-rows-facts.cpp, no device, no graph, no libhrx — the defect is two callers disagreeing, which neither caller's own test can catch): 9 arms, ctest -R test-hrx-get-rows-facts → Passed. Three mutants, each caught by name:

    A drop ids_contiguous from the contiguous form   -> 2 arms fail
    B drop the IQ3_S 2-D rule (llama.cpp#407)        -> 2 arms fail
    C make placement conjunctive on ids_contiguous   -> 2 arms fail, incl. "routed: placement must still claim it"
    

    C is the arm that matters: it is the shape of the fix that would have looked right and cost throughput.

    What is left, decided from where each predicate lives (not from the list order)

    • TOP_K → hip_top_k_tensor_supported sits next to its matcher in hip/dispatch-hip-top-k.cpp;
    • ARGSORT → small_rows_argsort_tensor_supported sits next to its matchers in common/dispatch-small-rows.cpp;
    • MUL_MAT_ID → mul_mat_id_requires_cpu lives in qwen4exp-hrx-support.h, away from the mul-mat-id matchers, and has no arm — that is the next slice, in this shape;
    • the batched-IQ3_S clause is now folded into the shared predicate and should not be re-added to the placement path.

    Still pending on this PR

    The device arm (test-hrx-get-rows-iq: IQ3_S/IQ4_NL rows still bit-exact on HRX, and the test asserts the plan contains the get_rows kernel, so a placement that now declines fails there instead of quietly passing on the CPU) is queued under gpu-hold -l cl-856-2704, seven deep behind the hardware-gate run holding the token since 12:21Z. It lands as a comment on #412. Everything above is host-side, which is where the two callers and the shapes they disagree about are reachable.

  2. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Scoping note for item 2, measured against the pin (dd9f270f6 + bb71f1be0), because the four remaining declines are not the same shape and the order I assumed in #412's body was wrong. One of them cannot be done the way GET_ROWS was.

    What each decline actually is

    decline in device_supports_op placement side (a ggml_tensor *) matcher side one definition?
    GET_ROWS get_rows_tensor_supported(facts) same predicate (get_rows_contiguous_form_supported) yes — #412
    TOP_K hip_top_k_tensor_supported(tensor) top_k_shape_supported(const Value &, const Value &) no — two implementations, linked only by a comment that says they "cannot drift apart"
    ARGSORT small_rows_argsort_tensor_supported(tensor) match_argsort_rows' own Value checks no — and the tensor predicate has no caller inside dispatch-small-rows.cpp, where its matcher lives
    MUL_MAT_ID mul_mat_id_requires_cpu(tensor) the routed-FFN matchers' own type/shape gates no, and it is not decidable per node (below)

    grep -c small_rows_argsort_tensor_supported ggml/src/ggml-hrx/dispatch_registration/common/dispatch-small-rows.cpp → 1: its own definition, no caller in the file its matcher lives in.

    MUL_MAT_ID cannot be the next slice, and the measurement says why

    I ran the two questions against the built backend (registry target gfx1151, the string device_supports_op passes) on hand-built nodes — decline = mul_mat_id_requires_cpu(op), registry = can_execute_standalone_op_as_graph(op, …) (what the tail of device_supports_op asks):

    Q4_K  K=1024 (mult of 256), N=2048, 64 experts   decline=no   standalone=no
    Q6_K  K=1024                                    decline=no   standalone=no
    Q4_K  K=640  (not a multiple of 256)            decline=yes  standalone=no
    IQ4_NL K=1024                                   decline=yes  standalone=no
    IQ2_S  K=1024                                   decline=yes  standalone=no
    

    A lone MUL_MAT_ID at shapes that ship (Q4_K, K a multiple of 256) gets no standalone dispatch, and fused_context_claim's documented list does not include MUL_MAT_ID either — the claim is decided by graph claim validating the whole routed-FFN pattern, which is exactly the "per-graph context question" ggml-hrx.cpp:1697 names as the blocker for the general fix. So MUL_MAT_ID's duplication needs that instrument; a properties-level predicate alone would tell the wrong story about a node whose claim is not a property of the node. Not touching it in this series — it belongs with the graph-level work, and I would rather say that than land a predicate that cannot be proven either way without a MoE model on the device.

    So the next slice is TOP_K, then ARGSORT

    Both are single-op claims (the GET_ROWS shape), both have a ggml_tensor * predicate already at the placement side and a separate Value-level one at the matcher side, and both are provable host-side the same way #412 is: facts struct, one predicate, each caller passes its own adapter, an arm per property, and a mutant per arm. TOP_K first because it is the smaller of the two (input.type, output.type, column_count, top_k, row_count — five properties, all visible from the tensor).

    What that means for #412

    #412 changes only GET_ROWS, as it says; this note corrects the follow-up order it proposed (it named MUL_MAT_ID next, on the assumption that the four were one shape). Nothing in #412 depends on the correction.

  3. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Follow-up to my scoping comment, because I then measured TOP_K and ARGSORT and the answer changes what the next slice should be. Same probe as before (claim = the placement predicate, registry = can_execute_standalone_op_as_graph(op, "gfx1151") = what the tail of device_supports_op asks; hand-built nodes, no device):

    TOP_K    f32/i32 cols 1024 k 8 rows 1     claim=yes registry=yes   agree
    TOP_K    f32/i32 cols 1024 k 8 rows 512   claim=yes registry=yes   agree
    TOP_K    f32/i32 k > cols                 claim=no  registry=no    agree
    TOP_K    row_count > UINT32_MAX           claim=no  registry=no    agree
    TOP_K    output nb[0] = 8 (strided i32)   claim=no  registry=no    agree
    ARGSORT  f32 512x2 contiguous             claim=yes registry=yes   agree
    ARGSORT  f32 512x2 STRIDED source         claim=no  registry=no    agree
    ARGSORT  f32 1024 cols (predicate bound)  claim=no  registry=no    agree
    

    No live drift in either row. The two conditions I expected to be asymmetric are not reachable: hip_top_k_tensor_supported does not check the matcher's output.nb[0] == sizeof(int32_t), but its contiguity test subsumes it for a 2-D i32 output, and the row_count bound I suspected it lacked is neutralised the same way. small_rows_argsort_tensor_supported requires contiguity, and match_argsort_rows evidently gates the same property through Value::contiguous, so the placement predicate is refusing exactly what the matcher refuses.

    So I am not opening the TOP_K/ARGSORT unification PR, and the reason is the fleet's own rule rather than laziness: it would be a churn PR with no measured defect behind it, and the two variants of it both cost something real —

    • Deleting the declines and letting the tail decide makes every TOP_K node in a graph pay a one-node graph build plus a registry match at placement (the router has one per MoE layer), in exchange for removing a clause that currently agrees with the registry on every shape I can construct;
    • Unifying the predicates adds a third file to make two implementations agree that already agree.

    Either is defensible hygiene. Neither fixes anything I can demonstrate, so it goes behind the rows that have a defect, and it should be done by whoever is already editing those files for a reason.

    What that leaves for item 2

    row state
    GET_ROWS fixed in llama.cpp#412 (the drift was real: the ids/output contiguities were enforced by the matcher and by nothing at placement)
    TOP_K duplicated, measured equivalent — hygiene, no defect
    ARGSORT duplicated, measured equivalent — hygiene, no defect
    MUL_MAT_ID claim is graph-level (previous comment); the decline itself agrees with the matchers on every type/multiple I probed

    One thing I could not test on this box, and it is the only remaining hypothesis with a defect behind it: device_supports_op returns hip_top_k_tensor_supported(op) early, so on a build where hip_code_object_embedded("hip_top_k_f32") is false the registration is skipped (register_hip_top_k_dispatch returns before hip_declare_eager_op) while the shape test still claims the node — claimed with no dispatch. Every build here has the code objects (GGML_HRX_HIP_ADDON_DIR is empty, yet the registry answers for hip.top_k_f32 because the objects come from hrx-system), so that configuration is not constructible on this box and I am recording it as a hypothesis, not a finding. If someone does have a build without the add-on's code objects, that is a 30-second probe with the harness above.

  4. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Device row for the GET_ROWS half is in: llama.cpp#412 comment of 2026-11-17. test-hrx-get-rows-iq at the PR head prints dispatch: loom_libs:ggml_get_rows_f32 on both IQ4_NL and IQ3_S cases and reports them bit-exact against ggml, in one gpu-hold ticket with 0 faults — i.e. the predicate change did not take a working contiguous GET_ROWS off the device, which is the only way this row could have regressed. #412 is MERGEABLE at 2f5693b64 and waits on a re-verdict after the review-driven wording fix.

  5. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The census, verified against the pinned tree (148e7f329): eager_capability_declared claims 31 ops — the issue's number is exactly right — and device_supports_op carries 7 hand-written op->op == guards, not 5. All seven are named below.

    Method: brace-matched function bodies from ggml/src/ggml-hrx/ggml-hrx.cpp in third_party/llama.cpp at the pinned sha (148e7f329, which is also where #402 landed), rather than counting a line range.

    eager_capability_declared:  31 case GGML_OP_
    device_supports_op:          7 op->op ==      (0 op->op !=)
    

    The seven, in source order

    1. op->op == GGML_OP_GET_ROWS   && op->src[0] != nullptr && …      <- the #407 case, named in the issue
    2. op->op == GGML_OP_MUL_MAT_ID && mul_mat_id_requires_cpu(op)
    3. op->op == GGML_OP_TOP_K                                        <- engine#2146, named in the issue
    4. op->op == GGML_OP_ARGSORT
    5. op->op == GGML_OP_DUP
    6. op->op == GGML_OP_NONE
    7. op->op == GGML_OP_VIEW       && view_src != nullptr && type == GGML_TYPE_Q8_0
    

    Both cases the issue names are in the list, which supports its thesis better than the count does: every one of these seven is a place where the placement pass had to be taught something the matcher already knew. Two of them (GET_ROWS, TOP_K) are the ones that produced unsupported HRX node in the field; the other five are either the same shape (ARGSORT, DUP, VIEW) or a benign early-out (NONE).

    So the target for option (a) is exactly these seven, and eager_capability_declared's 31-op list is the set that must be answered by a value-level entry point — which is the right shape for it, since each of the seven is a function of tensor properties (src, view_src, type) and not of graph position.

    Why I am not proposing the patch

    Option (a) means giving the registry a value-level entry point and re-expressing seven guards through it — and MUL_MAT_ID already has a helper (mul_mat_id_requires_cpu) that is itself the pattern the entry point should generalise. That is a design change in the HRX fork with kernel-adjacent reach; I can supply the census and the seven names, but I should not be the one deciding the entry point's shape.

    One caveat on the count: whether NONE and VIEW "count" depends on the definition — both are early-outs rather than declines. If the issue meant declines strictly, the number is 5, which may be exactly how its author arrived at 5. I am reporting 7 total guards, 5 of which decline, and both numbers are now written down so nobody re-derives them.

  6. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to this issue from a measurement, and it narrows the claim I filed it with: the tail of device_supports_op already refuses most of the shapes I said were "claimed and then failed". What is left is the drift, which is what llama.cpp#412 fixes.

    I built the #412/#414 head (fork 2f5693b64 + the routed-matcher commit) and asked the two questions directly — the registry's own standalone answer (can_execute_standalone_op_as_graph(op, "gfx1151"), i.e. what the tail of device_supports_op uses) and #412's placement predicate — for five shapes:

    shape registry standalone #412 placement predicate
    q6_K table, 4 ids, f32 dest 1 1
    same, f16 destination 0 1
    routed (scalar_3d) shape, 3-D dest [1,8,2,1] 1 1
    q6_K table, 4096 ids (> is_supported_token_count) 0 1
    Q8_K source (type absent from the format map) 0 1

    Read the middle column with the code: the predicate is consulted as a veto before the tail, so a 0 in the last column is a refusal, and a 1 there only means "no veto — ask the tail". So:

    • A >2048-id GET_ROWS and an unsupported-source-type GET_ROWS were already going to the CPU, through eager_capability_declared(op->op) && … can_execute_standalone_op_as_graph(op, arch), before Census 2026-10-14 #412. My issue text ("claimed here and failed the whole graph at compute time") was wrong for those, and so was the reasoning in llama.cpp#413 that I opened and then closed.
    • The f16-destination case is also the tail's, which is exactly what Census 2026-10-14 #412's header says it measured (standalone=0).
    • The routed 3-D destination is the one shape where the tail says YES (standalone=1) and the predicate also says yes — i.e. the one shape a claim that short-circuits the tail could get wrong. That is the regression Bump Laya: source 432312b3, model 7b928d82 #413 would have introduced by returning the predicate's answer instead of falling through, and it is why Census 2026-10-14 #412's shape (predicate as a veto, tail always reached) is the correct one — not just the smaller change.

    So the honest statement of this issue is the one #412 implements: two files stated the same contiguity/type/batch conditions and could drift, and the two known bites (engine#2639, llama.cpp#407) were the ones where a stricter matcher met a looser claim. The four-refusal framing in the original report overstates it — three of those four were already covered by the registry query that has been in the tail all along.

    Closing plan: #412 lands, then the routed-matcher half (llama.cpp#414, stacked on it), then an engine pin bump naming both. The remaining honest gap is that the contiguous form's predicate is now stricter than the tail needs for ids_contiguous/out_contiguous on shapes the tail would refuse anyway — harmless (both refuse), and worth a one-line comment rather than code.

  7. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correcting my own census line, and the correction is the useful part: only THREE of the seven guards decline. Two of them are already the value-level entry point the issue proposes — so the fix is to generalise an existing pattern, not to invent one.

    I posted "7 total guards, 5 of which decline". Read individually, with each guard's return value:

    GGML_OP_NONE        return true                          unconditional accept (scheduler probes)
    GGML_OP_VIEW        return true  (view_src && Q8_0)      conditional accept
    GGML_OP_GET_ROWS    return false                         DECLINE
    GGML_OP_DUP         return false                         DECLINE
    GGML_OP_MUL_MAT_ID  return false  (mul_mat_id_requires_cpu)  DECLINE, with a helper
    GGML_OP_TOP_K       return hip_top_k_tensor_supported(op)          <- a TENSOR PREDICATE
    GGML_OP_ARGSORT     return small_rows_argsort_tensor_supported(op) <- a TENSOR PREDICATE
    

    So: 2 accept, 3 decline, 2 conditional-on-tensor. My "5 declining" conflated the predicates with the declines.

    Why that changes the shape of the fix

    The issue's option (a) is "a registry entry point keyed by op code + tensor properties instead of by graph node". Two guards already are that, at the exact granularity the entry point needs:

    hip_top_k_tensor_supported(const ggml_tensor *)      in ggml-hrx/hip/
    small_rows_argsort_tensor_supported(const ggml_tensor *)
    

    and mul_mat_id_requires_cpu(op) is a third, used on the decline side. The pattern the entry point should generalise already exists three times, with slightly different names and homes — which is why each disagreement keeps being fixed by hand: there is no agreed place for a tensor-level predicate to live, so each one is written where the disagreement was found.

    That is a much cheaper conclusion than "add a registry API": agree on the predicate's home and signature, and the seven guards become one call site, with TOP_K/ARGSORT needing nothing but a move.

    What I am still not proposing

    Which home (ggml-hrx/hip/, npu/forward/, or a shared header) and whether the predicate takes a ggml_tensor* or the DispatchMatchContext's value accessor. That is a design call for whoever owns the HRX fork, and it is now a much smaller question than it looked before I read the seven.

    Corrected numbers, so nobody re-derives them: 7 guards, 3 declines, 2 tensor predicates, 2 accepts, and 31 ops claimed by eager_capability_declared.

  8. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Plan update after the fork's main moved — one line of the closing plan is now void, and the fix is unaffected.

    The fork's 1bit/hrx-vulkan-patched head is now bb71f1be0, which is llama.cpp#408 as merged: the commit message says "revert", but the merged form keeps the GET_ROWS source-contiguity claim and rewrites its comment with the per-matcher derivation. So:

    Rehearsed the landing that #412 and its follow-up (#414) will actually get on that head: git merge-tree says #412 merges into bb71f1be0 with no conflict, and cherry-picking #414's commit on top is clean (f41c903), builds, test-hrx-get-rows-facts 12/12 arms, host suite 76/0/23 of 99 — identical to the base. The five-shape check on that base has the claim and the registry agreeing on every shape except the two the tail is meant to refuse (ids > 2048, a source type outside the format map). Details on llama.cpp#414.

    Closing plan unchanged from here: #412, then #414, then one engine pin bump (gitlink + registry/architectures.json, no narrowing-baseline line — measured at b41e06f), and the placement census on 27B / 35B-A3B as the device row.

  9. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The three tensor predicates have an identical signature and three different homes — which is the decision this issue actually needs, stated concretely.

    ggml/src/ggml-hrx/hip/hip-capabilities.h:39
        bool hip_top_k_tensor_supported(const struct ggml_tensor * op);
    ggml/src/ggml-hrx/dispatch_registration/common/dispatch-small-rows.h:28
        bool small_rows_argsort_tensor_supported(const struct ggml_tensor * op);
    ggml/src/ggml-hrx/qwen4exp-hrx-support.h:211
        inline bool mul_mat_id_requires_cpu(const ggml_tensor * op);
    

    bool f(const ggml_tensor *) three times, in a HIP-capabilities header, a dispatch-registration header, and a model-support header. So the signature is settled by practice; only the home is not — and the header each one landed in names the disagreement that created it (a HIP capability, a small-rows dispatch, a qwen4exp model).

    That is why the seventh guard is always written by hand: there is no header a new tensor-level predicate would obviously go in, so each is placed next to the code that needed it. Pick the home (a shared hrx-tensor-support.h, or hip-capabilities.h promoted to carry all three) and the guards stop accumulating.

    One caveat on my own suggestion: mul_mat_id_requires_cpu is used on the decline side and the other two on the accept side, so one header holding both is a statement that a predicate's polarity does not change where it lives. That seems right — both answer "can this tensor run here" — but it is the kind of thing that reads differently once the fourth predicate appears, which is the argument for deciding it now rather than after the sixth hand-written guard.

  10. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Small scoping correction while I was in this function, because it affects how a future "ask the matcher" design should treat mechanism 3.

    device_supports_op's last block is

    #if GGML_HRX_HIP_TENSOR_CLAIM
        if (ggml::hrx::hip_tensor_claimed(op)) {
            return true;
        }
    #endif

    hip_tensor_claimed walks a table that only hip_declare_tensor_claim writes, and that function has no production caller:

    $ grep -rn hip_declare_tensor_claim . --include=*.cpp --include=*.h | grep -v ^./build
    ggml/src/ggml-hrx/hip/hip-capabilities.h:60:void hip_declare_tensor_claim(HipTensorClaim claim);
    ggml/src/ggml-hrx/hip/hip-capabilities.cpp:65:void hip_declare_tensor_claim(HipTensorClaim claim) {
    tests/hrx-backend-test.cpp:10671:    ggml::hrx::hip_declare_tensor_claim(hip_tensor_claim_test_predicate);
    tests/hrx-backend-test.cpp:10672:    ggml::hrx::hip_declare_tensor_claim(hip_tensor_claim_test_predicate);  // registries run per architecture: once
    

    So in every shipped build g_tensor_claim_count is 0, hip_tensor_claimed returns false, and that branch is unreachable — while the suite has a case that registers a claim and shows the hook works. That is the shape this fleet keeps paying for: a test that makes a dead path look exercised. Nothing is broken by it (the HIP ops that do claim — TOP_K, the scale path — are claimed by their own predicates), but two consequences are worth recording before anyone builds on it:

    1. do not model mechanism 3 as a live claim source when designing the registry consultation; today it contributes nothing, and
    2. if the hook is dead by intent, it and its test should go (a false sense of coverage); if it is dead by accident, some HIP matcher was meant to register and never did — and that would be a missing claim, i.e. a throughput loss in the same class as Census 2026-10-13 #408, not a correctness bug.

    I am not removing it in my PRs: guessing between those two readings is the owner's call, and the fix I have landed (#415) does not touch that path.

  11. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    llama.cpp#412 merged (5450c8054, 18:47Z), and the pin bump that makes it real is up: #2739 at 79368f91, MERGEABLE, engine dd9f270f6 -> 5450c8054.

    Two things worth recording on this issue:

    1. The bump carries Census 2026-10-13 #408's revert as well, because the engine still pins dd9f270f6 — the build on the box has been running the GET_ROWS contiguity clause that Census 2026-10-13 #408 proved refuses paths which work. So until pins: llama.cpp dd9f270f6 -> 5450c8054 (engine#2704, refs llama.cpp#412) #2739 lands, both this issue's fix and that revert are outside every build.
    2. llama.cpp#414 (the routed matcher asking the same predicate) is deliberately not in that pin — a pin may not carry an unmerged branch — and gets its own bump when it merges.

    With #412 merged and #2739 open, item 1 and 3 of the scope are done for GET_ROWS; item 2 stands as measured earlier in this thread: TOP_K/ARGSORT are duplicated-but-equivalent (hygiene, not done on purpose), MUL_MAT_ID's claim is graph-level, plus the one live defect found and fixed separately in llama.cpp#415 (a TOP_K claim that did not require the registration; measured with a build whose code object is absent).

  12. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    State of this issue after its three PRs merged, so the graph-level half has one page to start from.

    Landed

    PR what where it is now
    llama.cpp#412 (5450c8054) device_supports_op and match_get_rows_f32 ask one predicate for GET_ROWS; the ids/output contiguities that only the matcher enforced are gone from the placement path merged; engine pins it (engine#2739, 8ce90587, build + all five analyzers green on that commit)
    llama.cpp#415 (2af6b0df1) device_supports_op's TOP_K early return also requires eager_capability_declared, so the claim follows the registration rather than a shape test merged; the pin that carries it is engine#2748 (ready, MERGEABLE)
    llama.cpp#414 (52dda9bce, another lane) the routed GET_ROWS matcher asks the same predicate, so both forms are stated once merged, riding in engine#2748

    What is deliberately not done, with the measurement behind each

    • TOP_K / ARGSORT unification — measured equivalent, not a defect: TOP_K 5 shapes and ARGSORT 3 shapes, placement predicate vs dispatch registry, all agree (including the two asymmetries I expected: placement's contiguity test subsumes the matcher's nb[0] == sizeof(int32_t), and match_argsort_rows gates Value::contiguous too). Hygiene only, and both ways of doing it cost something real (deleting the declines makes every router layer pay a one-node graph build at placement; unifying adds a third file to make two agreeing implementations agree). Not worth a build.
    • MUL_MAT_ID — its claim is graph-level, not a property of the node: a lone MUL_MAT_ID at shipping shapes (Q4_K, K a multiple of 256, 64 experts) gets no standalone dispatch, and fused_context_claim's documented set does not include it. Its decline (mul_mat_id_requires_cpu) agrees with the matchers on every type/multiple I probed. This row belongs with the per-graph context question ggml-hrx.cpp:1697 names — not with a node-local predicate.
    • The #if GGML_HRX_HIP_TENSOR_CLAIM hook (mechanism 3) — hip_declare_tensor_claim has no production caller (only tests/hrx-backend-test.cpp), so hip_tensor_claimed is false in every shipped build and that branch is unreachable, while the suite has a case that makes it look exercised. Either it is dead by intent (then it and its test should go) or dead by accident (then some HIP matcher meant to register and never did — a missing claim, i.e. throughput in the Census 2026-10-13 #408 class). That is an owner call, not mine to guess.

    The one live defect this issue produced, and its proof shape

    The TOP_K claim was yes while nothing could execute the node — but only on a build whose hip_top_k_f32 code object is absent, because that is the one registration input a build can lack (register_hip_top_k_dispatch returns before hip_declare_eager_op). That configuration is constructible from this repo alone: move hip/kernels/hip_top_k_f32.hip aside, rebuild, and the embedded table has 0 entries against the shipped 1. Five configurations measured, only one changed behaviour (the no-object build: CLAIM -> decline); GGML_HRX_HIP_TENSOR_CLAIM=0, GGML_HRX_DISABLE_DISPATCH=hip.top_k_f32 and the default are all identical before and after, so the conjunction can only ever remove a claim.

    The recipe is in llama.cpp#415's body. If anyone writes a guard for this class in general, that five-configuration table is the shape to reproduce — and note the trap that cost me a wrong reading: find_dispatch_registry only answers for architectures it builds, so a probe with the wrong target string reports no for a reason unrelated to the change.

  13. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fixed and pinned: engine main carries the shared-predicate placement claim, in three commits, and every row this issue is about is in the pin. Closing on the measurement.

    What landed

    pin move fork commit what it does
    engine#2692 dd9f270f6 the GET_ROWS source-contiguity claim (#407/#2639) — the hand-written clause that exposed the drift
    engine#2739 5450c8054 #412: the tensor facts are stated once (dispatch-get-rows-support.{h,cpp}), each form is a named predicate its own matcher calls, and device_supports_op asks the union as a veto and then still asks the registry at the tail
    engine#2748 52dda9bce #414 (this lane): the routed matcher match_get_rows_scalar_3d_f32_dispatch asks get_rows_route_table_form_supported instead of keeping the last inline copy; and #415: the TOP_K claim is gated on eager_capability_declared(GGML_OP_TOP_K) so the claim follows the registration rather than the shape alone — the same class, fixed in the same pin

    Current main: third_party/llama.cpp = 52dda9bcee98676394618710d4136af69aaceea1, registry/architectures.json sources."llama.cpp (hrx)" = the same sha.

    Re-verified on current main (b2fd9b4 + later)

    $ python3 tools/registry_build.py --check-pins
    registry/architectures.json records the committed pins            rc=0
    $ python3 tools/ci/hrx_f16_narrowing.py --check --root .
    hrx_f16_narrowing: 84 body(ies), none new, none stale; 22 accumulator(s), none new, none stale; 11 guarded   rc=0
    $ git -C third_party/llama.cpp show 52dda9bc:.../dispatch-get-rows.cpp | grep -c get_rows_route_table_form_supported
    1
    

    The device row was taken at the same tree content (my head 743704fb0, which differs from the squash only by the #415 TOP_K hunk): test-backend-ops test -b HRX0 -o GET_ROWS → 130/130 passed, Backend HRX0: OK, no FAIL/MISMATCH, in a gpu-hold ticket with 0 amdgpu faults.

    What this issue was and was not

    The correction posted above stands: three of the four "claimed and then failed at compute time" shapes in my original report were already refused by the registry query in the tail; the real defect was that the same tensor conditions were restated in the placement path, where they drifted. That is what these three commits remove, and the TOP_K half (#415) shows the class has more members than GET_ROWS.

    Remaining, deliberately not part of this issue: the durable form — a properties-level dispatch_accepts(op, properties) that every op family consults, so the remaining hand-written declines (MUL_MAT_ID's mul_mat_id_requires_cpu, ARGSORT's small_rows_argsort_tensor_supported) can be deleted one at a time — is untouched; each of those is a live claim that works, just restated. If that gets picked up, it is a new issue with those two rows as its regression set.

  14. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The last row I had promised here, taken after the pin: the placement census is unchanged — all three models PASS with the same 2 off-HRX … BY DESIGN, none unexplained line the pre-#412 gate reported.

    $ HW_GATE_HOLD_MINUTES=12 bash scripts/hw-gate.sh --bin ~/wt/cl-hrxmem-572-build/bin \
          --phases placement --models qwen3-4b-iq4xs,qwen3.8-27b,qwen3.6-35b-a3b
    ## HRX hardware gate: PASS
    Commit \`b00463b\`, llama.cpp \`52dda9bcee98\`, hrx-system \`7f4236924aad\`, 58s, Tctl at end 61 C, amdgpu ring timeouts during the run: 0.
    
    | check | result | detail |
    |---|---|---|
    | placement qwen3.8-27b | PASS | 2 off-HRX node(s) BY DESIGN and none unexplained, in 5 graphs (largest 3897 nodes) |
    | placement qwen3.6-35b-a3b | PASS | 2 off-HRX node(s) BY DESIGN and none unexplained, in 4 graphs (largest 3879 nodes) |
    | placement qwen3-4b-iq4xs | PASS | 2 off-HRX node(s) BY DESIGN and none unexplained, in 3 graphs (largest 1269 nodes) |
    \`\`\`
    
    That is the claim this issue was closed on, confirmed on the device: the shared predicate does not move a node off HRX — the census counts the same two by-design nodes it counted before, on the two large models as well as the 4B, and nothing became unexplained.
    
    One correction to my own comment above: the binaries were built from `third_party/llama.cpp` at `743704fb0` (my #414 head), not at the pin `52dda9bce` — the trees differ only by #415's `TOP_K` hunk, which is placement-neutral for these rows (it can only *decline* a TOP_K whose registration is absent), so the census reads the same either way. Say so in a follow-up if you want it re-run literally at `52dda9bce`; I did not want to hold another GPU window for a one-hunk difference.
    
    Method note for the next lane doing this: run the gate's `placement` phase with `--bin` on a **pre-built** tree (`llama-server` + libs under `~/lb/thermal-run.sh`), not with `--phases build,placement` — the gate takes its GPU ticket before it builds, so the first attempt held the token through a 15-minute build and I killed it rather than starve `coder-llm`. And the second attempt was refused at take time by `gpu-hold`'s #2480 guard because of an **amdxdna** fault burst from another lane's NPU job (11 lines, `flags=0x0077`); the guard reads every kernel fault line, so the retry had to wait for 10 minutes of quiet.
    
  15. bong-water-water-bong commented on Nov 16, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Mechanism 3 answered: every HIP registration is already claimable without the tensor-claim hook, so hip_tensor_claimed is dead in production — not "reserved but unused", and the test that exercises it is the only thing keeping it looking alive.

    The hook is the last block of device_supports_op:

    #if GGML_HRX_HIP_TENSOR_CLAIM
        if (ggml::hrx::hip_tensor_claimed(op)) { return true; }
    #endif

    hip_tensor_claimed walks a table that only hip_declare_tensor_claim writes, and that function has no production caller — grep -rn hip_declare_tensor_claim finds only its declaration, its definition, and two lines in tests/hrx-backend-test.cpp. So the table is empty in every shipped build.

    What decides whether that is a missing claim (a throughput loss, the #408 class) or redundant code is whether any HIP matcher needs it. All three registrations, and their gates:

    registration gate how the op is claimed at placement
    hip.scale_f32 GGML_HRX_HIP_SCALE_F32=1 and hip_code_object_embedded("hip_scale_f32") supported_scale_f32_tensor() — the generic Loom predicate — early-returns true, so SCALE is claimed on exactly the shapes that predicate accepts. The HIP matcher substitutes a kernel for the same shapes; it does not widen coverage, so it needs no hook
    hip.set_rows hip_code_object_embedded("hip_set_rows") GGML_OP_SET_ROWS is in eager_capability_declared's list, so the tail claims it through can_execute_standalone_op_as_graph. No hook
    hip.top_k_f32 dispatch_name_disabled + hip_code_object_embedded("hip_top_k_f32") hip_declare_eager_op(GGML_OP_TOP_K) and the predicate the placement path asks directly (llama.cpp#415). No hook

    hip.scale_f32 is the one that could have needed it — it is the only registration whose predicate is not consulted by the placement path — and it turns out not to: the generic SCALE predicate is the gate, and the HIP kernel is chosen later by registration priority. That also means the HIP scale kernel can never fire on a shape the Loom path refuses, which is worth knowing when #572/#679 are tuned.

    So the decision is between deleting it and labelling it

    • Delete it (hip_declare_tensor_claim, hip_tensor_claimed, g_tensor_claims/g_tensor_claim_count, the #if block, and the test case that registers a claim): it is unreachable code whose only exercise is a test, and a test that makes a dead path look alive is the failure mode this fleet keeps paying for. The risk is that a future HIP matcher with a predicate wider than the generic one would need it and would silently fall back to the CPU instead of claiming — silent, not loud.
    • Label it: one sentence in hip-capabilities.h saying the table is empty in production and that a matcher whose predicate is wider than the generic one must register here. Cheaper, keeps the mechanism, removes the false impression.

    I recommend the second, with the test kept only if it says in its own name that it is testing an unregistered-in-production hook — deleting a mechanism three days after it was written is a bigger call than the evidence supports, and I would rather leave the author's design intact and stop it from reading as live.

    Not doing either myself: this is a design call about a mechanism I did not write, it is one sentence or one deletion either way, and my lane's remaining work on this issue is already documented. Recording it here so the row is closed with a reason rather than an open question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions