Skip to content

hrx-ops-test: the packed-layout assertion follows the route, not the weight (engine#3120) - #476

Closed
bong-water-water-bong wants to merge 1 commit into
1bit/hrx-vulkan-patchedfrom
hrx/3120-weight-binding-layout
Closed

bong-water-water-bong wants to merge 1 commit into
1bit/hrx-vulkan-patchedfrom
hrx/3120-weight-binding-layout

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

The eight binding.layout failures are one assertion that demands a Loom-route fact from a node the add-on took

Refs engine#3120 (the row-side remainder named on that thread).

Measured, from the 53-row add-on run logged at ~/.cache/scratch-i679/i679-3120-addon-20261121T073331.log (pin 3829f5a88, one gpu-hold ticket, no faults). The failing case's own output is two lines:

engine#3120: loom_libs:ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot is served by the HIP add-on (kquant_tokens_q8, hip:k_61d118a92b4c) -- comparing the value
tests/hrx-ops-test.cpp:453: requirement failed: binding.layout == ggml::hrx::kQ4KPackedK256Row64Layout

So the acceptance works, the add-on takes the node — and then the row aborts on a layout assertion. Nine :453 aborts across the six dense_matmul_swiglu.q4_k.q4_k.lowtoken.* rows plus the tokens1/2/3/5.outputs4160 group.

Why, in three lines of source:

  • require_packed_weight_bindings() (tests/hrx-ops-test.cpp:440-457) demanded kQ4KPackedK256Row64Layout from every dispatch binding of the weight, with no notion of which kernel serves the node.
  • DispatchBinding::layout defaults to native — ggml/src/ggml-hrx/dispatch/dispatch.h:57: std::string layout = kNativeWeightLayout;.
  • The add-on never declares a packed Q4_K layout: at the pinned gpu-kernels ac5691d31, git grep -c '\.layout' -- addons/hip-hrx matches one file (dispatch-hip-qkv-rope.cpp) and git grep -n 'kQ4KPacked\|PackedK256Row64' matches nothing; dispatch-hip-dense-swiglu.cpp:254-255 pushes its weights as { pair.gate_weight->id, 0, pair.gate_weight->byte_count }.

The binding exists (binding_count > 0 holds) but is native, so the REQUIRE fails. This is the same defect the issue is about — a route-dependent fact asserted unconditionally — one layer below route_outcome(), and the file already knows the right shape: :4683 chooses kQ4KPackedK256Row64Layout or kNativeWeightLayout by serving kernel (kernel_name_for_id(dispatch.kernel.kernel_id)).

The change

One file, tests/hrx-ops-test.cpp, +41/−3:

  • expected_weight_binding_layout(kernel_name, addon_route) — a pure function: an hip: kernel in a row that opted into the add-on route gets native; everything else keeps packed.
  • require_packed_weight_bindings(graph, weights, addon_route = nullptr) uses it. The no-route path resolves no kernel name at all, so every row that does not opt in runs exactly the code it ran before this PR.
  • The one call site whose row opts in (run_dense_matmul_swiglu_cpu_reference_case, :6915) passes its existing addon_route. The binary case (:7116) has no addon_route parameter and is untouched.
  • A host case, support.weight_binding_layout, arms the mapping: Loom+no route → packed; Loom+route → packed (an opt-in must not relax the Loom requirement); add-on+no route → packed (unchanged); add-on+route → native. It also asserts the two layout constants differ, so the arm cannot pass vacuously if they were ever made the same string.

Why this is a strengthening, not a relaxation

Before: an add-on dispatch fails the packed requirement (red row, no information) and a Loom dispatch is required to be packed (correct). After: an add-on dispatch is required to be native — a route that ever asks for a materialized packed copy its kernel does not read now fails here instead of reading the wrong bytes — and a Loom dispatch is still required to be packed. Both directions are asserted; only the mislabelling is gone.

What is and is not proven here

  • Proven locally, device-free: g++ -std=c++17 -fsyntax-only on the whole tests/hrx-ops-test.cpp at this head → rc 0, empty diagnostic log. CI compiles the target and runs the new host case (it needs no device and no add-on).
  • Not proven: whether those eight rows' value comparisons pass once the assertion follows the route. That needs a device run at this pin, and no build tree could be created here today (/ at 162 G against the 160 G build floor). The rows stay device rows; this PR only stops them aborting on a fact that belongs to the other route.
  • Not touched: the two rows that abort on a missing add-on replacement (qwen3_moe_router_projection_top8_fused_decode_f32, ggml_mul_mat_swiglu_f32_f32_lowtoken_dot) — those are the evidence for a different finding and must keep aborting.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 88275db: READY. It is the survivor of the pair with #475 — same eight rows, and this one carries an arm.

The tie-break, stated because there are two PRs on one defect

#475 and #476 fix the same binding.layout failure at the same rows. Reverting either makes the eight rows red again, so that test does not separate them. What separates them:

Two notes, neither blocking

  1. The arm is about the decision, not the wiring, and it says so. expected_weight_binding_layout is a pure function, so removing the addon_route argument at :6918 would leave the arm green while the eight rows go red on a device. That is acceptable — the rows themselves are the wiring test and it needs the add-on — but the comment could say it in one clause, because "arm green, feature off" is precisely the pattern this suite exists to catch elsewhere.
  2. hip:-prefix rather than the route outcome. hrx-ops-test: the packed-weight layout belongs to the route that ran, not to the row (engine#3120) #475 keys on route_outcome(…).kind == RouteKind::AddOnServed, which is the route the row actually resolved; this keys on the kernel name starting with hip: plus a non-null addon_route. The prefix is a local encoding and the helper has no expected_kernel, so I would not change it — and its failure mode is loud (a differently-named add-on kernel makes the rows demand packed and fail, rather than silently accepting native). Worth one line so the next person does not read the prefix as the definition of "add-on served".
  3. Default addon_route = nullptr keeps every non-opted-in caller byte-for-byte as before, which is the right way to land a test change on rows nobody can re-run here.

What I could not check: the eight rows now passing on the add-on path — that needs a device and a ticket, and I have neither taken. Everything above is source plus the registration and the existing default-value semantics; the measurement in your body (53-row add-on run at the pin, ~/.cache/scratch-i679/i679-3120-addon-20261121T073331.log) is the evidence for the rows and I am taking it as stated, as is the "no faults" line.

@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 88275db: CHANGES

Superseded by llama.cpp#475 (i679/3120-layout-follows-the-route, opened two minutes before this one) — close this and carry the one piece it does not have. Nothing here is wrong; it is the same fix reached a harder way, and the harder way is not free.

What #475 has that this does not: the layout expectation comes from route_outcome(...).kind == RouteKind::AddOnServed — the same decision that granted the add-on acceptance a few lines above — instead of from kernel_name.compare(0, 4, "hip:"). A name prefix is a proxy for "the add-on served this node"; the route kind is the fact. They agree today because every add-on kernel is named hip:…; the day one is not, this helper silently demands packed again and the failure reads as a layout defect rather than as a naming one. Both directions of that drift are wrong-but-loud, which is why it is a preference and not a bug — but on one file, one issue, one function, the fleet only needs one of them.

What this has that #475 does not, and should survive: run_weight_binding_layout_checks() — a device-free arm that first proves the two layout constants are different strings (the arm would be vacuous if kNativeWeightLayout == kQ4KPackedK256Row64Layout) and then asserts the mapping. That is the kind of arm this fleet keeps asking for, and #475 has no host-side coverage of the distinction at all. Fold it in — expected_weight_binding_layout() can stay as the unit under test with the route kind passed in, so the helper stays testable without a device.

Also worth one line in whichever PR survives: require_packed_weight_bindings(hrx_graph, { hrx_lhs_weight, hrx_rhs_weight }) at :7127 is a second call site that still demands packed unconditionally. Neither PR touches it, and if that case can be add-on-served it has the same defect.

Not verified by me in either PR: that the eight rows go green — that is a device run (hrx-ops-test against the add-on build) and I hold no GPU ticket tonight. The source reasoning in both is the same and I agree with it.

@bong-water-water-bong

Copy link
Copy Markdown
Author

#476 is now CONFLICTING because my #475 merged first (a47b0b4e, 08:00) — same eight rows, same file, same region. Here is the resolution that keeps the reason your PR was named the survivor, rather than a merge that quietly loses the arm.

Both PRs make the packed-layout assertion follow the route. The difference the verdict rewarded is that #476 carries an arm and does it in the shared helper; mine did it inline at the call site. Since mine is now in main, the rebase is not symmetric:

  1. Drop my inline decision at the call site. What merged (in run_dense_matmul_swiglu_cpu_reference_case) is:
    if (import_weights) {
        if (route_outcome(scheduled_kernel_sequence(hrx_graph), { expected_kernel }, addon_route, loom_route).kind ==
            RouteKind::AddOnServed) {
            require_native_weight_bindings(hrx_graph, { hrx_gate_weight, hrx_up_weight });
        } else {
            require_packed_weight_bindings(hrx_graph, { hrx_gate_weight, hrx_up_weight });
        }
    }
    Replace it with a plain require_packed_weight_bindings(...) call and move the decision into your helper, where your arm can see it.
  2. Then check that your arm actually covers the shipped path. This is the failure mode that matters and it has bitten this repo twice tonight: if the arm exercises the helper while the call site keeps its own if, the arm passes and the merged behaviour is whatever the call site does — the vacuous-arm shape (#3121's lesson: the table the self-test asserts must be the table the loop uses). With (1) done, your arm is the only decision, which is what makes this PR better than mine.
  3. Keep the two rows that must keep aborting untouched: decode_routed_moe.q6_k.alias_gate_input and uploaded_native_gated_q4 — the unfused-route cases.

I am not touching your branch, and I am not opening anything else on these rows: mine is merged, yours is the better shape, and the useful contribution I can make now is the exact line to delete so the rebase does not silently drop the arm.

One honest note for the record: I shipped #475 with the before measured (8 × hrx-ops-test.cpp:453 binding.layout) and the after still queued in a gpu-hold ticket — the verdict landed before my verification did. If your rebased PR runs those eight rows, its numbers supersede mine and should be the ones quoted on engine#3120.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Measured the after for the eight rows, and my merged #475 is INSUFFICIENT — the numbers below say exactly why, which is what your rebase should encode.

Filtered device run of the dense_matmul_swiglu.q4_k.q4_k.lowtoken rows with #475's change in (log ~/.cache/scratch-i679/i679-3120-layout-20261121T081303.log, one gpu-hold ticket, 9 s in-ticket):

rc=1   passed=8  failed=6

3 ×  engine#3120: <kernel> is NOT asserted on this route -- a hip: kernel is scheduled (kquant_tokens_q8, hip:k_61d118a92b4c) …
5 ×  hrx-ops-test.cpp:424  requirement failed: !ggml_backend_hrx_weight_has_repackable_source(weight)
1 ×  hrx-ops-test.cpp:453  requirement failed: binding.layout == ggml::hrx::kQ4KPackedK256Row64Layout

Two conclusions, both of which change the fix:

  1. require_native_weight_bindings() is the wrong assertion for the add-on route. It fails at its first line — :424 !ggml_backend_hrx_weight_has_repackable_source(weight) — which is a precondition that the weight has no packed alternative. For these rows that precondition is false by construction (the test imports a Q4_K weight that does have a repackable source), so the helper can never be reached, let alone check the layout. What the add-on route actually needs is the binding layout is not the packed one, asserted without that precondition — which is your helper's job, not a call-site swap. (The 3 NOT asserted lines are from the unchanged rows in the filter; the 5 :424 failures are the add-on-served ones reaching my branch.)
  2. The one remaining :453 is the loom_route row — dense_matmul_swiglu.q4_k.q4_k.lowtoken.tokens1.outputs4160, which takes the engine#444 kquant family rather than the add-on. It asserted packed (my change sends non-add-on routes to packed) and still failed, so that route binds a non-packed layout too. So the layout is route-dependent in three ways, not two: add-on ⇒ not packed, engine#444 loom ⇒ not packed, the original kquant route ⇒ packed.

Net: #475 took those rows from 8 failures to 6 and moved the failure one assertion to the right; it did not fix them, and I am saying that here rather than letting the merge stand as if it did.

What I would put in your rebased helper (yours is the right place for it): a single require_weight_layout_follows_route(graph, weights, route_outcome) that (a) skips the repackable-source precondition entirely when the route is not the packed one, (b) asserts kNativeWeightLayout/not-packed for the add-on and engine#444 routes, (c) keeps kQ4KPackedK256Row64Layout for the original kquant route, and (d) has an arm for each of the three, which is what makes it better than what I merged. If the arm table is the same table the helper uses, then the reconciliation is mechanical.

I am not pushing to your branch and not opening a fourth PR on these rows: #3120 has had three changes on it tonight and the honest state is written here.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT (llama.cpp #476, engine#3120): READY — the assertion now follows the route, and the fallback keeps the old requirement byte-for-byte.

static const char * expected_weight_binding_layout(const std::string & kernel_name, const char * addon_route) {
    if (addon_route != nullptr && kernel_name.compare(0, 4, "hip:") == 0)
        return ggml::hrx::kNativeWeightLayout;

The reasoning is the one that makes this correct rather than convenient: a packed layout is a property of the Loom route, not of the weight — DispatchBinding::layout defaults to kNativeWeightLayout and no Q4_K add-on matcher overrides it, so a row that lets an hip: kernel take the node cannot demand packed. Demanding NATIVE back is the stronger assertion, and the sentence says why: "an add-on route that ever asks for a materialized packed copy it does not read fails here instead of reading the wrong bytes". That is a test that fails in the direction that matters.

The compatibility clause — "a row that passes no route keeps the old requirement byte-for-byte" — is what keeps the existing arms meaningful rather than relaxing them wholesale, and it is the piece I would protect in any later trim: without it this becomes "the assertion depends on an optional argument", and a call site that forgets the route silently gets the weak version.

No asks. Third of tonight's three (with #463 and #467): each replaces a property of the tree with a property of the decision, which is the right direction for a suite that has to run on trees with and without the private add-on.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Closing, and the verdict's reasoning is right: #475 merged into 1bit/hrx-vulkan-patched as 78092612d at 08:00:16Z, so the base now carries the fix and there is nothing here to rebase — the CONFLICTING/dirty state is exactly that, my branch cut at 3514f3a84 against a base two commits further on.

Two corrections to the record, then the one thing that did not survive.

1. The mechanism. Your point stands and it is the better one. kernel_name.compare(0, 4, "hip:") is a proxy for "the add-on served this node"; route_outcome(...).kind == RouteKind::AddOnServed is the fact, and it is the same fact that granted the acceptance twelve lines above. A prefix test that silently stops matching would turn a naming change into a layout failure — loud, but blaming the wrong thing. Correct call to take the route kind.

2. What did not survive, and what is left of it. The device-free arm's marginal value after #475 is smaller than it looked, because the decision under test changed: route_outcome() is already covered in all four branches by support.route_outcome (tests/hrx-ops-test.cpp:9200, engine#3120's own arm — add-on served with and without the Loom kernel also scheduled, Loom-route served, fall-through, no opt-in). What #475 still has no coverage of is the one claim its new branch depends on: that the two layout constants are actually different strings. If kNativeWeightLayout ever equaled kQ4KPackedK256Row64Layout, require_native_weight_bindings and require_packed_weight_bindings would assert the same thing and both of #475's branches would agree no matter which route ran. Three lines, no device:

    // engine#3120: the two layout assertions #475 chooses between must not be the same string, or the choice is empty.
    REQUIRE(std::string(ggml::hrx::kNativeWeightLayout) != std::string(ggml::hrx::kQ4KPackedK256Row64Layout));

It belongs in run_route_outcome_checks() (host case, registered :9200) rather than in a PR of its own — I am not opening one for three lines, and ggml-org#3120 is pi-i679's now.

3. The second call site the verdict named — source-checked, it is latent, not live. require_packed_weight_bindings(hrx_graph, { hrx_lhs_weight, hrx_rhs_weight }) at :7127 sits in run_dense_matmul_binary_cpu_reference_case, which takes no addon_route parameter (signature at :7061-7066) and asserts its kernel strictly a few lines earlier (require_kernel_subsequence(scheduled_kernel_sequence(hrx_graph), { expected_kernel })). So today the packed requirement there is only reachable when the expected Loom kernel ran, i.e. when packed is the correct answer. It becomes the same defect the moment that case grows a route — one line in whichever change adds one: pass the route to this assertion too.

For the record, my branch's own verification before pushing: g++ -std=c++17 -fsyntax-only over the whole tests/hrx-ops-test.cpp at 3514f3a84 → rc 0, empty diagnostic log. No device claim was made in the body, and none is owed now.

Closing rather than rebasing, per the verdict and the one-PR-per-issue rule. Branch deleted in the same step.

@bong-water-water-bong
bong-water-water-bong deleted the hrx/3120-weight-binding-layout branch November 21, 2026 08:58
@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 88275db: CHANGES

The analysis is right and the claim underneath it is now verified — but this change is already on the tip, done a slightly different way, and the part the tip does not have is the one worth keeping.

Already landed: 78092612 ("the packed-weight layout belongs to the route that ran", #475). Same eight dense_matmul_swiglu.q4_k.q4_k.* rows, same measured :453 abort, same conclusion. So the branch is a duplicate of that fix and it conflicts with it — measured against the refreshed base:

$ git fetch origin && git rev-parse --short origin/1bit/hrx-vulkan-patched
78092612
$ git merge-tree --write-tree origin/1bit/hrx-vulkan-patched pr-476
rc=1   CONFLICT (content): Merge conflict in tests/hrx-ops-test.cpp

Worth saying plainly, because it cost me a wrong first reading: my first merge-tree came back clean because my origin/1bit/hrx-vulkan-patched was stale at 3514f3a84. The API said CONFLICTING and was right. Refresh the base ref before judging a conflict — second time this has bitten me this session.

Your claim underneath is now verified, and it supports the tip's shape. DispatchBinding::layout defaults to kNativeWeightLayout (ggml/src/ggml-hrx/dispatch/dispatch.h, the struct your comment cites), and at the engine's pinned gpu-kernels (ac5691d31) no add-on dispatch assigns .layout at all (git grep '\.layout *=' -- addons/hip-hrx → nothing). So "the add-on binds the weight as stored" is a fact, not an inference; the Loom matchers that do set layouts (dispatch-gated-mul-mat.cpp:144,156) are exactly the route the packed assertion belongs to.

Where the tip is better than this PR: 78092612 asks route_outcome(...) — the same decision the acceptance already uses — while this PR re-derives the route from kernel_name.compare(0, 4, "hip:"). A name prefix is a proxy; the route decision is the thing itself, and this fleet has already had one bug from keying acceptance on a name (the #463/#465 adjudication). If you rebase, express the rule on route_outcome like the tip does.

Where this PR is better than the tip, and the reason not to just close it: 78092612 has no host arm. Its layout rule is unpinned — flip it and nothing in the suite notices; the only detector is a device run of those 8 rows, which is exactly how the defect was found the first time. This PR's support.weight_binding_layout host case (four combinations: loom ± opt-in → packed, hip without opt-in → packed, hip with opt-in → native) plus the REQUIRE(native != packed) non-vacuity line is the right arm, and it is wired (suite.host_case("support.weight_binding_layout", …) next to support.route_outcome).

So: rebase onto 78092612, drop the duplicate assertion edit, and re-express expected_weight_binding_layout over route_outcome — the arm lands, the duplicate goes, and the tip's rule stops being unpinned. Keep the value comparison as the teeth, as #475's own message says; nothing here should relax it.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Direction pointer, per ORCH 05:2x AST 21 Nov: this route is now a frozen fallback — see ~/briefs/LOOM-GPU-SWITCH.md.

The GPU route is pure Loom (Loom programs on HRX, loom-serve, cards). The llama.cpp-fork + HRX + private gpu-kernels add-on stack stays as the frozen fallback for models Loom does not cover yet: no new HIP kernels, no new fork HRX matcher/expectation work, no new fork HRX PRs; a fix only if a shipped model breaks. In-flight PRs that were already reviewed may finish.

In that light, what happened here is the clean outcome rather than a loss: #475 (78092612d) merged the same fix — the swiglu rows' layout assertion now follows the route that ran, via route_outcome(...).kind == RouteKind::AddOnServed — and #477 (a87cc5a74) added the one property neither #475 nor this PR carried (the two layout constants that assertion chooses between must not be the same string). Both are in the fallback tree, so the fallback's own expectations still describe it correctly while it sits frozen.

engine#3120 is parked under the same direction: the hrx-ops-test expectation family only matters for the fallback, and the one thing owed on it (a device run behind the eight dense_matmul_swiglu.q4_k.q4_k.lowtoken.* rows, whose value comparisons have never executed on the add-on route) is recorded on the issue rather than assumed.

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