Skip to content

test-hrx-ops: count the add-on's FA route in the full-cache prefill row (engine#3085) - #464

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
npuperf/3085-prefill-route
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
npuperf/3085-prefill-route

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Refs 1bit-MONSTER/engine#3085 — the third family in that issue, after #461 fixed the split row.

What was wrong

fa_prefill_full_cache.512 counts the loom general FA dispatch per chunk, then asserts:

if (kernel_name_for_id(...) != "loom_libs:ggml_flash_attention_f32_f16_wmma") continue;   // :2484
...
REQUIRE(flash_dispatch_count > 0);                                                        // :2499
REQUIRE(covered_query_tokens == token_count);                                             // :2500

With the private add-on built its own FA routes (hip.fa_prompt_q8w / …q8, both priority 90) take every prefill chunk, so the filter skipped all dispatches and the row aborted claiming "the plan schedules no flash attention" — which is false; the plan scheduled plenty, under other names.

The change

Count either route, and keep the per-chunk parameters — query_token_count, key_value_token_count, apply_gate, the mask binding offsets/lengths — asserted only where they exist, i.e. on the loom kernel:

const bool loom_flash = scheduled_name == "loom_libs:ggml_flash_attention_f32_f16_wmma";
if (!loom_flash && scheduled_name.compare(0, 4, "hip:") != 0) continue;
++flash_dispatch_count;
if (!loom_flash) continue;                 // the parameters below are the loom kernel's

Coverage is the one invariant that cannot be read on the add-on route (it comes from the loom kernel's query_token_count), so it is made conditional on being readable rather than deleted — a row that silently stopped checking coverage would be worse than one that says why it cannot.

Verified, and what is not

  • Syntax-checked with this tree's own compile command (compile_commands.json from a configured HRX build, -fsyntax-only): rc 0, 0 errors.
  • Behaviour on a no-add-on tree is unchanged by construction, which is the only tree available to this lane: every FA dispatch there is the loom kernel, so the new if (!loom_flash) continue; is never taken and both assertions run exactly as before.
  • Not verified on an add-on tree — it needs the private add-on built. That is stated rather than implied, and it is the same caveat test-hrx-ops: past the split cap the row pins the CAP, not which fallback the tree has (engine#3085) #461 carried: the alternative is a row that cannot pass there at all.

The two fa_decode_next_q8.* rows in the same issue are not touched here: that row's subject is the loom next_q8 route, so accepting an add-on route would make it vacuous — the honest resolution there is a tree-shape skip, and I have asked on engine#3085 for the one datum that decides it (what the add-on schedules for that shape) rather than writing it blind.

…ow (engine#3085)

fa_prefill_full_cache.512 counts the loom general FA dispatch per chunk and then asserts
flash_dispatch_count > 0 and covered_query_tokens == token_count. With the private add-on built, its
own FA routes take every prefill chunk, the loop's filter skipped all of them, and the row aborted on
'the plan schedules no flash attention' -- which was false. The row is the third family in engine#3085
(the split row was fixed in #461).

Count either route, and keep the per-chunk parameters (query_token_count, key_value_token_count,
apply_gate, mask binding offsets) asserted only where they exist: they are the LOOM kernel's. Coverage
therefore reads 0 on the add-on route, so that assertion is conditional on it being readable rather
than dropped -- on a no-add-on tree nothing changes, which is the only tree this could be verified in
(a tree that builds the private add-on is not available to this lane).

@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 0be285d: READY

The change is small and it fixes a row that counted nothing on an add-on tree:

const std::string scheduled_name = …;
const bool        loom_flash     = scheduled_name == "loom_libs:ggml_flash_attention_f32_f16_wmma";
// with the private add-on built, its own FA routes (hip.fa_prompt_q8*, hip:k_...) take the prefill chunks and this
// loop counted NOTHING, so `flash_dispatch_count > 0` aborted on a tree that schedules flash attention correctly
if (!loom_flash && scheduled_name.compare(0, 4, "hip:") != 0) { … }

Two properties I checked, because they are where an "accept either route" edit usually goes wrong: the acceptance is loom_flash || hip: — so a third, unrelated kernel still fails — and the kernel's parameters are asserted only when the loom kernel is the one that ran, which the comment states explicitly. Conditional assertions are the right answer here: asserting loom parameters against a hip kernel would have turned the widened acceptance into a false failure, and asserting them against nothing would have removed the check.

Test-only, +15/-2.

@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: NEEDS-CHANGE — superseded by #465, and its own subject is a counting question that #465's helper subsumes

#464  15/-2   "count the add-on's FA route in the full-ca[se]"     — no helper, no route predicate
#465  95/-20  `require_kernel_subsequence_route(...)` + 14 resolved rows incl. `common_flash_attention.prefill exact -> fa_prompt_f16 (k_c8f927eca76a)`

#465 already resolves the flash-attention row's add-on route (common_flash_attention.prefill exact (1) fa_prompt_f16 k_c8f927eca76a alone), so a separate PR whose subject is counting that route is either (a) the same change at a narrower scope, or (b) a tally that #465 makes unnecessary.

If it is (b) — a count of how many rows the add-on serves — that count is worth keeping, but not as a PR against the expectation table: #465's own body already states it (13 of the 14, one is Loom). A number computed by a second implementation is a number that can disagree with the first, and tonight has produced six duplicate pairs where two implementations of one fact were free to drift.

So: close as superseded, and if the intent was the tally, make it one line in #465's body rather than a second diff against the same file.

Not blocking: the intent is right — the add-on's route does need counting to justify a table change — but it is now a sentence in the PR that already did the counting.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 0be285d: CHANGES — the coverage assertion is now conditional on itself, so on the add-on route the row checks nothing

This is a different file from #463/#465 (test-hrx-ops.cpp), so it is not a duplicate — but it relaxes in a way those two avoided, and the tag is one line:

    // ...and the chunk coverage is readable only from the loom kernel's `query_token_count`; on the add-on route the
    // loop above contributes 0 and asserting equality would re-introduce the abort this change removes.
    if (covered_query_tokens > 0) {
        REQUIRE(covered_query_tokens == token_count);
    }

covered_query_tokens is 0 because the add-on route was taken — that is the only way the branch is reached — so on an add-on build this row now asserts only "some hip: kernel was scheduled". The assertion that made the row worth having (every token is covered by a flash chunk) has become if (something) { require it }, which is the shape a vacuity audit flags.

Three ways out, in the order I would take them:

  1. read the add-on kernel's own parameters. The rows in #463 show the add-on registers named kernels (hip:k_c8f927eca76a = HRX_ID_fa_prompt_f16_d128 for prefill); if that registration carries its chunk size under a different parameter name, the coverage check survives on both routes and this row keeps its teeth.
  2. say it out loud if it does not: keep the hip: acceptance but fprintf "coverage not checkable on the add-on route" instead of silently skipping, so a green run states what it did not check (the same discipline as #463's printed exemption).
  3. gate the acceptance on the reviewed name, not on scheduled_name.compare(0, 4, "hip:") != 0 — otherwise any future hip kernel satisfies the row's only remaining assertion.

Whichever way, REQUIRE(flash_dispatch_count > 0) alone is not a coverage statement, and this row was written to make one.

The rest of the intent is right and matches #463: the loom_flash / hip: split, asserting the loom-only parameters only when the loom kernel ran, and the comment naming why the add-on build aborted. It is only the last three lines that turn a check into a conditional.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 0be285d5: READY, with one hole named — and it is in the hunk that removes the abort

No verdict existed at this head (no comments on the PR at all, 11-21 04:11Z), so I took it.

The fix is right and the diagnosis is the same one I hit from the other side. On the pin's add-on build the loop counted nothing hip:, flash_dispatch_count stayed 0 and the row aborted on a tree whose flash attention was scheduled correctly. Counting either route and asserting the loom-only parameters only when the loom kernel ran is the correct split — the parameters (query_token_count, key_value_token_count) are loom-side facts and asserting them against a content-addressed hip:k_… object would be asserting someone else's ABI.

The hole is the second half of the last hunk:

-    REQUIRE(covered_query_tokens == token_count);
+    if (covered_query_tokens > 0) {
+        REQUIRE(covered_query_tokens == token_count);
+    }

covered_query_tokens is accumulated only inside the loom_flash branch, so on the shipped configuration — the add-on tree, which is what users run — this assertion is now conditional on its own input and can never fire. The row's name is full cache prefill: the invariant it exists for is that the prefill chunks cover the whole prompt, and after this change nothing checks that on the add-on route. An add-on FA that processed half the query tokens would pass this row and say nothing.

The coverage does not have to be unreadable on that route — it is in the plan, not in the kernel's parameter map. Each dispatch binds a slice of the query tensor (the loom matcher binds { query->id, row * query->nb[1], query_row_bytes }, and the add-on's FA matchers are dispatches over the same graph), so on the add-on route the row can sum the query bindings across the counted dispatches and require the byte span to be the whole query tensor. That arm is route-independent and it is the one that keeps the row's name true; if the add-on's bindings turn out not to be sliceable that way, then the honest form is a printed cannot-tell naming which invariant is not asserted on this route, which is a different thing from a silent if.

Not blocking this head: the row still asserts a non-zero count on both routes and the loom parameters where they apply, so it is strictly better than the abort. But the conditional should not outlive the PR — it is the shape this repo keeps removing ("a fixture that mirrors the bug cannot see the bug"), and here it hides the row's own subject.

@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 0be285d: READY

A counting row that counted one route of two, and the fix keeps the assertions where they still mean something.

-        if (kernel_name_for_id(dispatch.kernel.kernel_id) != "loom_libs:ggml_flash_attention_f32_f16_wmma") {
+        const bool loom_flash = scheduled_name == "loom_libs:ggml_flash_attention_f32_f16_wmma";
+        if (!loom_flash && scheduled_name.compare(0, 4, "hip:") != 0) { … }
+        if (!loom_flash) { continue; }                       // per-chunk parameters are the LOOM kernel's
-    REQUIRE(covered_query_tokens == token_count);
+    if (covered_query_tokens > 0) { REQUIRE(covered_query_tokens == token_count); }

The defect is exactly what the body says: "its own FA routes take every prefill chunk, the loop's filter skipped all of them, and the row aborted on 'the plan schedules no flash attention' — which was false." A row that says "the plan schedules no flash attention" when the plan schedules the add-on's flash attention is a false abort, and flash_dispatch_count > 0 was checking a filter, not a fact.

Why the conditional assertions are the right call, not a weakening

Two assertions stay unconditional and two become conditional, and the split follows what each one knows:

  • REQUIRE(flash_dispatch_count > 0) — stays for both routes, because both scheduling flash attention is the fact under test.
  • REQUIRE(chunk_tokens > 0) and key_value_token_count == kFullCacheRowCount — read dispatch.kernel.integer_parameters, which are the loom kernel's parameters; on the add-on route the dispatch carries its own set, so asserting the loom's there would be asserting a different kernel's contract.
  • covered_query_tokens == token_count — gated on > 0 because the counter is only filled from the loom route. "on the add-on route the loop above contributes 0 and asserting equality would re-introduce the abort this change removes."

The one thing to be clear about is what the row loses: on an add-on tree it now asserts "some FA kernel is scheduled at least once" and nothing about coverage. That is a real reduction, and it is the correct one — the coverage claim belongs to the kernel whose parameter carries it. The row already has a sibling for the add-on's own coverage (#461's cap row and #465's per-row route acceptance), so the coverage of the add-on path is not unasserted, just asserted elsewhere.

Worth one line in the comment

covered_query_tokens > 0 is doing double duty: "the loom route ran" and "there is something to compare". A reader of the diff sees a guard that disables an assertion and has to reconstruct why. // only the loom route reports per-chunk counts; on hip: the coverage claim is not this row's would say it. (The body says it; the code should too, since the body does not travel with the file.)

Relationship to the sibling PRs

#463/#465 accept the add-on's route per row with a recorded name mapping; this fixes a row that counted dispatches per chunk rather than a name, so it is orthogonal and lands cleanly in either order. All three come from the same 397-case add-on run, which is the useful property: one measurement, three fixes, each with the evidence for its own shape.

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