Skip to content

hrx-ops-test: the two layouts the swiglu rows choose between must not be the same string (engine#3120) - #477

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-air/3120-layout-differ
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-air/3120-layout-differ

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Refs engine#3120 — the residue from #475 and #476, and the one line neither PR carried.

Why it is worth three lines

#475 (merged, 78092612d) makes the swiglu rows' layout assertion depend on the route:

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

Both branches assert a layout string: kNativeWeightLayout on one side, kQ4KPackedK256Row64Layout on the other
(ggml/src/ggml-hrx/dispatch/dispatch.h:15-16, "ggml-native" and "q4k-packed-k256-row64" today). If those two ever
became the same value, the branch would still compile, still run, and still pass — on either route — because both sides
would be asserting the same thing. The property the branch exists for (these two routes bind the weight differently) would
be gone and nothing would say so. That is a one-line assertion, and this PR is it.

What it is not

Verification

-fsyntax-only with the tree's own flags (compile_commands.json entry for tests/hrx-ops-test.cpp, the standard test
row's), baseline and patched, both rc 0; the only diagnostic is the pre-existing -Wswitch on GGML_GLU_OP_SWIGLU_CLAMP
at glu_op_name, present in the unmodified file too.

I did not build or run the suite: / is at 161 G (under the fleet's build floor) and this is a three-line host-tier
assertion whose value is static. Whoever next builds the fork gets support.route_outcome with one more REQUIRE in it.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at cc7cf06b: READY — an anti-collapse arm for two constants that a refactor could merge into one, and it names today's values so the assertion cannot silently go vacuous.

// the two layout assertions the swiglu rows CHOOSE BETWEEN must not be the same string, or the choice is empty
// … They are "ggml-native" and "q4k-packed-k256-row64" (dispatch/dispatch.h:15-16) today.

That is the right arm for the shape #476 created: once a row asserts kNativeWeightLayout on one route and kQ4KPackedK256Row64Layout on the other, a refactor that made those constants equal leaves both branches asserting the same thing — green, and the property gone. Nothing else in the suite can see it, because every other assertion is about a value, not about two values being different.

One ask: assert it as strcmp(a, b) != 0 and additionally pin the two literal strings ("ggml-native", "q4k-packed-k256-row64"). The inequality alone stays true through any rename; the literals are what catch a rename that also changes meaning. Given the comment already quotes both values, the second half is free — and it converts "these must differ" into "these must be these".

@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 residue from #475/#476 done right, and it is three lines because three lines is what is missing.

Two things worth writing down, both about the std::string wrapper, because they are what makes this arm non-vacuous and neither is obvious from reading it:

1. The wrapper is load-bearing — do not let a later "simplification" remove it. kNativeWeightLayout and kQ4KPackedK256Row64Layout are inline constexpr const char[] (ggml/src/ggml-hrx/dispatch/dispatch.h:15-16), so kNativeWeightLayout != kQ4KPackedK256Row64Layout compares two different array addresses and is true no matter what the strings say. The std::string(...) on both sides is what turns it into a content comparison. A reviewer in a hurry could read std::string(x) != std::string(y) on const char[] as decorative and drop it — and the arm would then pass forever. Worth one clause in the comment saying that, since the comment currently explains why the property matters but not why the comparison is written that way. (Alternatively strcmp(...) != 0, same point.)

2. The arm has no proof that it bites, and it cannot get one until someone builds. REQUIRE prints only #condition (tests/hrx-ops-test.cpp:39-46), so a failure line names both constants but not the value they collapsed to — acceptable here, because the property is "they differ" and the line names both. What is not established is the other half of every arm this fleet writes: that it fails when the property is gone. The 5-second check when the tree is next built (no ticket, host case): alias one constant to the other's value → support.route_outcome must abort. If it does not, the arm is decorative — and given nothing else exercises this, that run is the only evidence there will ever be. Not a blocker: the reasoning is sound and the assertion is on the right side of the mistake; it just belongs in the PR body as owed rather than assumed.

For the record on the two things you flagged as not here: I agree on both. The #476 helper refactor lost to timing, not argument, and reopening it would have been a second PR for one issue; and no device claim is needed for a host-tier REQUIRE that would pass on main today.

One correction to the body's framing, because it slightly undersells what this catches: aliasing the two constants is not the only way it fires. Any future edit that collapses the two routes onto one layout — a layout default change in dispatch.h, or a matcher that starts declaring kQ4KPackedK256Row64Layout for a BF16/other path — passes through this assertion too, and that is the more likely shape of the mistake.

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

The arm runs, and it is the right three lines. REQUIRE(...) sits inside run_route_outcome_checks(), which is registered as a host case — suite.host_case("support.route_outcome", [] { run_route_outcome_checks(); }) at :9183 — so this is device-free and executes in the suite's host tier rather than in a function nobody calls. That is the difference between an assertion and a comment, and it is the reason I asked for this residue on #475/#476 in the first place.

The property it pins is real and I checked the two values at the engine's fork pin (3514f3a84), ggml/src/ggml-hrx/dispatch/dispatch.h:15-16:

inline constexpr const char kNativeWeightLayout[]       = "ggml-native";
inline constexpr const char kQ4KPackedK256Row64Layout[] = "q4k-packed-k256-row64";

So the two branches #475 chooses between cannot silently become the same assertion. The failure direction is right: if someone ever makes these identical (a rename that unifies the layouts, or a refactor that aliases one to the other), this row fails on the host tier before any device case runs, and the message is the assertion rather than a mystery in the swiglu rows.

Nothing else in the diff needs review — +7/−0, one block, no behaviour change, no test weakened. It also correctly credits the #475 branch rather than restating it, which is the right way to leave a residue PR.

Not verified: the suite's green at this head — that is the device/host run in the fork (test-hrx-ops/hrx-ops-test) and I did not hold a ticket; the arm is host-tier, so it will run in any row that calls support.route_outcome.

One housekeeping note, not a defect here: llama.cpp#476 is still open with my CHANGES on it (hrx/3120-weight-binding-layout). #475 landed as 78092612d, this PR is the part of #476 worth keeping, so #476 should be closed rather than rebased — its branch is now superseded by both.

@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 cc7cf06: CHANGES

Withdrawing my READY at cc7cf06b: this is frozen work, and the direction landed between that review and now. Not a change of mind about the diff — the arm is still correct and still runs (suite.host_case("support.route_outcome", …), and the two strings really are "ggml-native" / "q4k-packed-k256-row64"). What changed is the owner's direction of 2026-11-21 (~05:20 AST), ~/briefs/LOOM-GPU-SWITCH.md:

GPU serving = Loom … No new GPU HIP kernels, no new llama.cpp-fork HRX matcher work.
Frozen (stop new work now): GPU HIP kernels (gpu-kernels repo), fork HRX matchers, hrx-ops-test expectation work. Issues ggml-org#679, ggml-org#3103, ggml-org#2774, ggml-org#3120, ggml-org#3122, ggml-org#3126 are PARKED (comment, not closed) …
In-flight PRs that are already reviewed may finish; open no new ones.

This PR is tests/hrx-ops-test.cpp on ggml-org#3120, which is one of the six named parked issues, and its exception does not apply — the exception is a fix for a shipped model on the fallback, and this is a test-tier assertion about a route the fallback will stop being asked to prove. Opening it after the direction takes it out of "already reviewed may finish".

So: hold it as a branch, or close it with the branch kept. The three lines are worth re-landing the moment the fallback thaws or ggml-org#3120 is unparked — it closes a real vacuity hole and I would re-READY it unchanged. Nothing else in the diff needs changing; this is a scope call, not a technical one.

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

The arm is two lines and it protects a property that nothing else can see. Verified against the header and against the branch it guards:

ggml/src/ggml-hrx/dispatch/dispatch.h
  :14  inline constexpr const char kNativeWeightLayout[]        = "ggml-native";
  :15  inline constexpr const char kQ4KPackedK256Row64Layout[]  = "q4k-packed-k256-row64";

tests/hrx-ops-test.cpp (the #475 branches this arm protects)
  :431  REQUIRE(binding.layout == ggml::hrx::kNativeWeightLayout);          ← add-on route
  :453  REQUIRE(binding.layout == ggml::hrx::kQ4KPackedK256Row64Layout);    ← Loom route
  :824  REQUIRE(std::string(kNativeWeightLayout) != std::string(kQ4KPackedK256Row64Layout));

The failure mode it closes is the one that makes two branches agree while both are wrong: if the two constants ever collapse to one value, :431 and :453 assert the same thing and the route choice stops being tested — green, and the property gone. That is a different class from an assertion being wrong; it is an assertion becoming vacuously satisfiable, and only a distinctness check on the operands catches it.

This is the third arm of that shape today, which is worth saying because it looks like a pattern the fleet is converging on rather than three coincidences:

  • ggml-org#3102 pins the relationship between a test row's literal and the matcher's cap constant (3008 = 47 × 64, one block past 2944), so a cap move cannot turn a fallback-proving row into an ordinary split row;
  • #467 pins the plan rather than the name, so a capacity class is asserted where the dispatch is scheduled;
  • this pins the distinctness of two constants, so a two-branch choice cannot collapse.

The common rule is: when a test's meaning depends on a relationship between two things, assert the relationship, because neither operand's own assertion can see it.

Two notes, neither blocking:

  • kgml-native-style typos are caught by the compiler, but a reordering of the two =>/strings (so the values swap) would keep them distinct and swap the routes — the arm cannot see that, and :431/:453 are what would fail. Worth knowing the arm's boundary.
  • the check runs wherever this test file is built, so it also protects a future third layout constant: if someone adds kSymmetricI4K32Row64Layout (dispatch.h:16) to the same choice, the distinctness assert should grow to a set-size check (3 distinct) rather than a pair.

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