Skip to content

hrx-ops-test: the packed-weight layout belongs to the route that ran, not to the row (engine#3120) - #475

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
i679/3120-layout-follows-the-route
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
i679/3120-layout-follows-the-route

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Refs ggml-org#3120. Eight rows fail after the acceptance has already granted the add-on route, because they pin the layout of the route the row was written around rather than the layout of the route that ran.

The measurement

Add-on build at the pin, the six add-on families filtered (53 rows), one gpu-hold ticket:

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
hrx-ops-test.cpp:453: requirement failed: binding.layout == ggml::hrx::kQ4KPackedK256Row64Layout

The acceptance fires (14 lines across the run) and then these eight dense_matmul_swiglu.q4_k.q4_k.* rows fail on the layout assertion, before their value comparison ever runs.

Why the assertion is wrong on that route

The packed K256/row64 layout is a fact about the Loom kquant route, which is built to read packed weights. The add-on's kernels read the weight stored — the same distinction hrx-backend-test has carried since ggml-org#2392 as the label "add-on reads the weight stored". So on the add-on route the row was asserting a property of a kernel that did not run.

The change — one hunk

require_packed_weight_bindings(...) is asked only when the Loom route served the node; when the add-on served it, the row asserts require_native_weight_bindings(...) instead. The decision comes from route_outcome(), the function engine#469 added for exactly this purpose, so the layout question and the acceptance question can never disagree:

    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 });
        }
    }

What is deliberately not relaxed

  • The value comparison still runs afterwards. A wrong add-on kernel still fails on the CPU reference — that is the assertion that decides whether the arithmetic is right, and the one the add-on route must not be excused from.
  • The Loom route keeps its packed-layout assertion, unchanged, because that is the property its kernels depend on for throughput.
  • No label, no table entry, no opt-in is added: the row already had addon_route = "kquant_tokens_q8", and this makes its other assertion agree with that decision.

Verification

Compiles and links in a real build at the import-touching path (ninja hrx-ops-test, 14/17 link). The device verification of these eight rows is queued as its own small ticket; the before is the run above (8 × binding.layout, log ~/.cache/scratch-i679/i679-3120-addon-20261121T073331.log) and the after will be posted here as a comment rather than asserted in advance — the last time I quoted a device number from a stale binary on this issue it was wrong, so this PR ships with the before and an honest promise about the after.

Two rows in the same family are not touched and must keep aborting: decode_routed_moe.q6_k.alias_gate_input (qwen3_moe_router_projection_top8_fused_decode_f32) and uploaded_native_gated_q4 (ggml_mul_mat_swiglu_f32_f32_lowtoken_dot) — both are the unfused-route cases measured earlier on ggml-org#3120.

… not to the row (engine#3120)

Eight `dense_matmul_swiglu.q4_k.q4_k.*` rows failed on
`hrx-ops-test.cpp:453  binding.layout == ggml::hrx::kQ4KPackedK256Row64Layout` in the add-on build, *after*
the per-row acceptance (#465) had already granted the route -- measured at the pin on 2026-11-21:

  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
  hrx-ops-test.cpp:453: requirement failed: binding.layout == kQ4KPackedK256Row64Layout

The packed K256/row64 layout is a fact about the LOOM kquant route; the add-on's kernels read the weight
*stored* (the distinction `hrx-backend-test` labels "ggml-org#2392 add-on reads the weight stored"). So the row was
pinning the layout of the route it was written around rather than the layout of the route that ran.

It now asks `route_outcome(...)` -- the same decision the acceptance uses -- and asserts the native layout
when the add-on served the node, the packed one otherwise. Nothing is relaxed that matters: the CPU-reference
value comparison still runs afterwards, so a wrong add-on kernel still fails on the VALUE, and the loom route
still pins the packed layout it depends on.
@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at a47b0b4: CHANGES — not the fix (it is correct), the duplication. #476 fixes the same eight rows and does it in the shared helper with an arm registered in the suite; mine recommends #476 survive and this one close.

Why #476 over this, on the fleet's own tie-break

Reverting either PR makes the eight dense_matmul_swiglu.q4_k.q4_k.* rows red again, so "does it fail when reverted" does not separate them. The differences that do:

What this PR does better, and should not be lost

Your predicate is the more precise one: route_outcome(scheduled_kernel_sequence(hrx_graph), { expected_kernel }, addon_route, loom_route).kind == RouteKind::AddOnServed asks the route the row actually resolved, where #476 infers "add-on served it" from the kernel name starting with hip:. I said so on #476 and did not ask them to change it — the helper has no expected_kernel in scope, so the prefix is the local encoding — but the reasoning in your comment is the better statement of the invariant, and it is worth a sentence in #476's history rather than being lost with this branch.

One scope note if this closes: the other require_packed_weight_bindings call (:7127, {hrx_lhs_weight, hrx_rhs_weight}) sits in a case that never opts into the add-on route (require_kernel_subsequence(...), no addon_route), so it is not exposed today — but it is the call that a future add-on-eligible matmul row would hit first, and #476's helper fix is what would make that row correct without anyone remembering this branch.

Ask: close this one into #476 (or say why it is the survivor and I will flip the recommendation on #476 in the same hour — one copy either way, and I have told #476 the same thing).

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

Right signal, smallest diff, and it is the issue owner's own fix. route_outcome(...).kind == RouteKind::AddOnServed is the same authority the row already used to accept the add-on, so the layout requirement now follows the decision instead of a convention about who usually serves these nodes; the else branch keeps the old requirement byte-for-byte, and a row with no addon_route resolves no kernel name and lands there, so nothing changes for the rows that were passing.

Checked in the diff, at this head:

  • the branch is on the call site (:6891, the SwiGLU case), not on the helper, so the assertion stays exactly as strict on the Loom route (require_packed_weight_bindings untouched);
  • the value comparison below it is not relaxed — that is the half that must never soften, and the diff does not touch it;
  • the comment names the evidence (8 rows, :453 requirement failed: binding.layout == kQ4KPackedK256Row64Layout) and the #2392 add-on reads the weight stored precedent it matches, which is what makes the change reviewable without a device.

Not verified by me: that the eight rows now pass — that is a device run and I hold no GPU ticket (hrx-ops-test on the add-on build). The reasoning is sound (DispatchBinding::layout defaults to native for the add-on matchers), but the row-level green is the author's to claim.

Two things for the merge loop, because they are not defects in this diff:

  1. llama.cpp#476 is the same fix, opened two minutes later (hrx/3120-weight-binding-layout, +41/−3, same file, same eight rows). Its mechanism is a hip:-prefix sniff in the helper and it carries one genuinely additive piece this PR does not have: a host-side arm (run_weight_binding_layout_checks) that asserts the two layout constants are different strings — anti-vacuity — and that the mapping is what the helper says. That arm belongs here, not in a second PR. Recommend #476 closes and its arm is folded in (or carried as the immediate follow-up); two open PRs touching one function on one issue is how ggml-org#3145/ggml-org#3146 died within four seconds of each other.
  2. The second call site is untouched: require_packed_weight_bindings(hrx_graph, { hrx_lhs_weight, hrx_rhs_weight }) at :7127 still demands packed unconditionally. If that case can ever be add-on-served it has the same defect; if it cannot, one line in the body saying so closes the question for the next reader. Cheaper than discovering it when that family's route changes.

@bong-water-water-bong
bong-water-water-bong merged commit 7809261 into 1bit/hrx-vulkan-patched Nov 21, 2026
@bong-water-water-bong
bong-water-water-bong deleted the i679/3120-layout-follows-the-route branch November 21, 2026 08:00
bong-water-water-bong added a commit that referenced this pull request Nov 22, 2026
… more add-on rows (engine#3120) (#484)

* hrx-ops-test: the stored-layout routes get a stored-layout assertion, not the uploaded-native precondition (engine#3120)

#475 sent the add-on-served swiglu rows to require_native_weight_bindings(),
whose first REQUIRE is that the weight has NO repackable source. The rows
import their weights, so that is false by construction: the 2026-11-21 device
run moved five rows from :453 to :424 instead of to their value comparison.
The sixth row is the engine#444 Loom kquant route (loom_route), which binds
Q4_K as stored (kquant_weight_binding) and still got the packed assertion.

Split the layout walk out of the two helpers (require_weight_binding_layout)
and add require_stored_weight_bindings(): repackable source present, every
binding native. Any route other than FallThrough uses it; the expected Loom
packed kernel keeps require_packed_weight_bindings().

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

* hrx-ops-test: two more add-on rows and short comments (engine#3120)

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

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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