Skip to content

test-hrx-backend: pass the consumer to moe_router_descriptor_layout (engine#3129) - #468

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
os3/3129-backend-test-consumer
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
os3/3129-backend-test-consumer

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 21, 2026 •

Copy link
Copy Markdown

Refs engine#3129. tests/hrx-backend-test.cpp has not compiled since fork a7fd21ac9 (#438, engine#2861): the two-argument moe_router_descriptor_layout(int64_t, bool) arrived and this one call site kept the one-argument form. One line, and the reason it is worth its own PR rather than a rider on #467 is that the claim is different and separable: #467 is about the get_rows capacity class, this is a compile break, and a compile break should not live or die with another PR's fate.

The break, at exactly the sha this branch is cut from (9ad200545)

$ /usr/bin/c++ -fsyntax-only -std=gnu++26 -DGGML_USE_HRX -DGGML_USE_CPU … tests/hrx-backend-test.cpp
tests/hrx-backend-test.cpp:368:105: error: too few arguments to function
    'ggml::hrx::MoeRoutingDescriptorLayout ggml::hrx::moe_router_descriptor_layout(int64_t, bool)'

and after this commit, same command, same tree:

$ … ; echo rc=$?
rc=0

-fsyntax-only is the honest unit for this: no device, no link, no ggml objects — it fails on the arity and nothing else, in about a second.

Why false is the right consumer, read from the reference's own subject

The header (pinned sha) states the rule the parameter exists for:

// The layout has to be the one the CONSUMER decodes, not the one that follows from the expert count. The qwen fused
// routed kernels decode the Qwen layout and only run at 128 experts; the common mul_mat_id decodes the common layout
// and runs for 1..512 experts. … (engine#2861)
inline MoeRoutingDescriptorLayout moe_router_descriptor_layout(int64_t expert_count, bool consumer_reads_common_layout)

And the equivalence is total, which is what closes the only semantic risk a one-line fix like this carries: the parent of a7fd21ac9 (the last tree where this compiled) had

inline MoeRoutingDescriptorLayout moe_router_descriptor_layout(int64_t expert_count) {
    if (expert_count <= kMoeRoutingQwenLayoutMaxExpertCount) return { "127", "7", "13", "128", 127, 7, 13 };
    return { "511", "9", "15", "512", 511, 9, 15 };
}

so with false the two-argument function is the same function for every expert_count — not merely for the fixture sizes the suite uses. git show --stat a7fd21ac9 also shows how the call site was missed rather than changed: the header, the router and tests/test-hrx-moe-routing-layout.cpp were updated, tests/hrx-backend-test.cpp was not touched at all.

This call site builds make_qwen_partition_table_reference — the table a qwen routed kernel decodes — so the consumer does not read the common layout, and the function returns 127/7/13 at ≤ 128 experts and the common layout above that whatever is passed. The case's own expectation, written out on purpose rather than read from this function (:8574, "so a wrong layout cannot pass by agreeing with itself"), says exactly compact = expected_expert_count <= 128 → 127/7/13/128, else 511/9/15/512. So the fix does not move the expectation; it makes the reference agree with it again.

Swept for the same class: this is the only stale call site

$ grep -rn 'moe_router_descriptor_layout' --include='*.cpp' --include='*.h' .
ggml/src/.../qwen/dispatch-moe-router.cpp:397   moe_router_descriptor_layout(router_match.expert_count, consumer_reads_common_layout);
ggml/src/.../qwen/dispatch-moe-router.cpp:630   moe_router_descriptor_layout(router_match.expert_count, consumer_reads_common);
tests/test-hrx-moe-routing-layout.cpp:49-57     (128, false) (129, false) (experts, true)
tests/hrx-backend-test.cpp:368                  ← the one-argument call, fixed here

Both production call sites pass the flag, and the layout self-test exercises both values, so the two-argument form is in use and this was the single straggler.

Not claimed

  • That the rows now pass. No value can have moved (the equivalence above), but "it runs and reports" is a build-tree result, not a syntax one. The host tier needs the built target; that run is not in this PR (no build tree on this box tonight). The lane that found this ran it on a branch carrying this same hunk and reports host: 1 passed, 0 failed with the device half skipping — that is their measurement, not mine, and I am crediting it rather than restating it as verified here.
  • The engine side. Nothing reaches an engine build until a pin bump; engine#3129 stays open for that and for the reason the break was invisible (a gate does attempt this build — hrx-build.yml's blanket cmake --build "$fork" with -k 0, whose rc is swallowed — and the fork_ctest_known_fail baseline carries hrx-backend-test # Failed, which absorbs the new Not Run because ctest_known_fail.py keys the baseline by name and never compares the recorded reason).

One line plus a four-line comment, no other file touched.

…engine#3129)

The two-argument form arrived with a7fd21a (fork #438, engine#2861) and this
call site kept the one-argument one, so tests/hrx-backend-test.cpp has not
compiled since. The target is registered but built only inside a job that
swallows the build's rc, so both of its ctest rows and all of its cases have
been dead without anything reporting it (engine#3129).

`false` is the consumer for this table by the reference's own subject: it
builds the partition table a qwen routed kernel decodes, and above 128 experts
the function returns the common layout whatever is passed, which is what the
case's independent expectation (127/7/13 at <= 128 experts) already states.

Verified with -fsyntax-only at this sha: rc 1, "too few arguments to function
... moe_router_descriptor_layout(int64_t, bool)" before; rc 0 after. Not
claimed: that the rows pass -- that needs the built target (engine#3129).

@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 64cd4cc: READY

A one-argument test fix, and the argument is the interesting part:

// the second argument is WHO READS the table, and this reference is the table the qwen routed kernels decode, so
// it is not the common layout: Qwen 127/7/13 at <= 128 experts, the common layout above that
const Mo…Layout layout = moe_router_descriptor_layout(expert_count, /*consumer_reads_common_layout=*/false);

The reference implementation now asks the same question the router asks — which layout does the consumer read — instead of taking the default. That is the right repair for a mismatch: not "relax the comparison so both pass", but "call the function with the argument that describes this consumer", and it keeps the CPU reference comparable to the kernel that will be checked against it.

It touches the same file as #467, so whichever lands second rebases; no conflict in substance, and both are test-side.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 64cd4cc: READY

This is the one-call compile fix for the open engine#3129 — "tests: hrx-backend-test has not compiled since #438 (one stale call)" — and the argument it adds is the right one:

tip    tests/hrx-backend-test.cpp:368   moe_router_descriptor_layout(expert_count)                        ← 1 arg
tip    dispatch-moe-routing-layout.h:61 moe_router_descriptor_layout(int64_t, bool consumer_reads_common_layout)   ← 2, no default

so the file could not compile at the pin, and this PR supplies the missing argument with /*consumer_reads_common_layout=*/false.

The value is correct for every expert count this row uses, which is the part worth checking rather than assuming: the function is

if (!consumer_reads_common_layout && expert_count <= kMoeRoutingQwenLayoutMaxExpertCount)  return { "127","7","13","128", … };
return { "511","9","15","512", … };

so false gives the Qwen layout at ≤128 experts and the common layout above that — exactly the pick the router makes for these rows, and exactly what the header's own docstring says the argument means ("the layout has to be the one the CONSUMER decodes, not the one that follows from the expert count … the writer cannot satisfy both and must ask who is reading (engine#2861)"). The comment added above the call restates both regimes, so a future reader cannot set it to true without seeing why not.

Nothing to change. One merge note: this is a test-only fix, so it will not change any device behaviour — its whole value is that the reference now compiles and agrees with the layout the qwen routed kernels decode (engine#2381's reason for sharing the router's layout instead of re-deriving it).

@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 64cd4cc: READY

A one-argument call site that engine#2861's new parameter left behind — and the missed parameter here is not cosmetic, it decides which descriptor table the plan writes.

The change

-  const ggml::hrx::MoeRoutingDescriptorLayout layout = ggml::hrx::moe_router_descriptor_layout(expert_count);
+  const ggml::hrx::MoeRoutingDescriptorLayout layout =
+      ggml::hrx::moe_router_descriptor_layout(expert_count, /*consumer_reads_common_layout=*/false);

And the second argument has no default:

inline MoeRoutingDescriptorLayout moe_router_descriptor_layout(int64_t expert_count, bool consumer_reads_common_layout)

So this is a build break, not a silent behaviour change — the loud kind, which is the one worth having: a signature that gained a parameter and a call site that was missed fails to compile, rather than quietly picking a layout.

Why false is the right answer here, from the function's own comment

"The layout has to be the one the CONSUMER decodes, not the one that follows from the expert count. The qwen fused routed kernels decode the Qwen layout and only run at 128 experts; the common mul_mat_id decodes the common layout and runs for 1..512 experts. A plan carries one table per route-ids value, so the writer cannot satisfy both and must ask who is reading (engine#2861)."

This reference is the table the qwen routed kernels decode, and the new comment in the test says exactly that — "the same pick the router makes for these rows" — so the row now builds its reference with the layout the consumer will use, instead of the one the expert count would have implied. The 127/7/13 vs 511/9/15 split is not a preference: "the two layouts place the partition and row-count fields at different bit offsets, so a table written with one and read with the other yields a wrong expert index." A wrong expert index is a wrong answer that looks like a plausible one, which is why the comment on the predicate exists.

What the test is

tests/hrx-backend-test.cpp's MoE reference, and 5/1 is the whole diff — the third time tonight that the smallest PR had the clearest defect: a signature change is only as complete as its last call site, and hrx-backend-test builds in the CPU CI, so this would have been a red build check rather than a subtle wrong number.

I have not run it — hrx-backend-test needs the HRX tree — but a missing required argument cannot compile, so the check that matters is the one CI runs on every PR.

@bong-water-water-bong

Copy link
Copy Markdown
Author

The one semantic risk a one-line fix like this carries — "does it change an expected value?" — is now closed by reading the function this call site was written against, and it is closed for every expert count, not just the ones the fixtures use.

The parent of a7fd21ac9 (#438) is the last tree where this call site compiled, and at that sha the function had one argument:

inline MoeRoutingDescriptorLayout moe_router_descriptor_layout(int64_t expert_count) {
    if (expert_count <= kMoeRoutingQwenLayoutMaxExpertCount) return { "127", "7", "13", "128", 127, 7, 13 };
    return { "511", "9", "15", "512", 511, 9, 15 };
}

and today's is if (!consumer_reads_common_layout && expert_count <= 128) … qwen …; return … common …. With false the two are the same function — identical for every expert_count, including above 128 — so this commit restores exactly the behaviour the file had before it stopped compiling, and cannot move any value the cases compare. That is stronger than "the expectation at :8574 agrees": it holds even for a fixture the suite does not have.

And #438's own diff shows how the call site was missed rather than changed:

$ git show --stat --oneline a7fd21ac9
 .../common/dispatch-moe-routing-layout.h   |  8 ++++--
 .../qwen/dispatch-moe-router.cpp           | 31 +++++++++++++++++-----
 tests/test-hrx-moe-routing-layout.cpp      | 16 ++++++++---
$ git show --name-only --format='' a7fd21ac9 | grep -c tests/hrx-backend-test.cpp
0

The header, the router and the layout self-test were all updated; tests/hrx-backend-test.cpp was not touched, so its one-argument call survived the arity change. That also explains why the break is confined to this file: at a7fd21ac9 the only one-argument call left in the tree was this one (the other two call sites are in the router, both with the flag, and the self-test uses both values).

Body updated with the same two facts under "Why false".

@bong-water-water-bong
bong-water-water-bong merged commit 3829f5a into 1bit/hrx-vulkan-patched Nov 21, 2026
@bong-water-water-bong
bong-water-water-bong deleted the os3/3129-backend-test-consumer branch November 21, 2026 05:04
bong-water-water-bong added a commit that referenced this pull request Nov 21, 2026
…r is green (engine#3129) (#474)

`qwen_flash_attention_dispatch` was baselined as [ggml-org#2392 add-on plans this node] expecting
`ggml_flash_attention_decode_split_f32_f16_wmma_next_q8`; it now passes on the add-on path, so the runner
reports it as an UNEXPECTED-PASS and returns 1. The table's own rule says what to do about that -- "A row is
removed when its mechanism's fix lands: the case then passes on the add-on path (UNEXPECTED-PASS)" -- so
the row goes, with the measurement recorded in its place.

Measured at the current pin, built fresh, run with no device (the configuration this file's no-device
branch describes):
  before: host: 76 passed, 0 failed, 22 known-fail, 1 unexpected-pass, 99 total   rc 1
  after:  host: 77 passed, 0 failed, 22 known-fail, 0 unexpected-pass, 99 total   rc 0

What made it visible: nothing in CI selects these rows (`LABELS "hrx"` vs the workflows' `ctest -L main`,
and this target had not even compiled since #438 until #468), so the baseline drifted unwatched. That is
engine#3129's thesis, and this is the one edit that makes the target green before anyone spends runner
time gating it.

Co-authored-by: pi-i679 <[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