From 6835d1abbbf1fab8852b863684cd37791914343b Mon Sep 17 00:00:00 2001 From: bcloud Date: Sat, 14 Nov 2026 16:46:34 -0400 Subject: [PATCH 1/2] hrx-backend-test: label q4k_aligned_prefill_layout.stored_copy on the add-on path (gpu-kernels#84) gpu-kernels#84 registered a matcher at priority 306 that claims "a 256-aligned batch of a Q4_K weight Loom reads STORED" and routes it to hip.dense_prefill.mm_q4k_stored -- the +25-28 % prefill change. That is exactly this case's stored-copy arm, which asserts the Loom q5_k/iq4_xs form instead: tests/hrx-backend-test.cpp:3712: name == "loom_libs:ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256" So with the add-on at the pin the case is red, and the loom-only build is untouched. Measured, in this order: add-on gk-b0ed206 (before #84) [PASS] add-on 6105368 (the pin) [FAIL] :3712 ... with GGML_HRX_HIP_DENSE_PREFILL_Q4K_STORED=0 [PASS] <- gpu-kernels#85's own opt-out bisects it A label rather than a rewritten assertion because the alternative is not reachable in-process: the policy knobs are read into static storage once per process (swiglu-tile-probe documents the same constraint for its two runs), so the case cannot flip the opt-out mid-run. Doing it properly needs a child process per policy -- what llama.cpp#383 just established for the arch table -- and that is a follow-up, not a reason to leave the suite red. The `expect` fragment is the :3712 requirement itself, so any OTHER failure in this case still surfaces as UNEXPECTED-FAIL instead of being absorbed by the label. Arm-scoping is hip_addon_dispatch_active(), which is why the loom-only row still asserts the Loom kernel; 22 labels already exist and the loom row reports 0 known-fail, so that gate is demonstrably working. Verified on the add-on build at the pin: one case: 1 known-fail, 0 unexpected-pass full host tier: 68 passed, 0 failed, 24 known-fail, 0 unexpected-pass of 92, zero UNEXPECTED-FAIL lines (was 68/1/23 of 92 -- the single failure becomes the label, nothing else moves) Refs gpu-kernels#84 (the 306 entry), gpu-kernels#85 (the opt-out used to prove it), engine#2392 (this labelling + UNEXPECTED-FAIL enforcement), gpu-kernels#86 where the failure was first reported as a control arm. --- tests/hrx-backend-test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/hrx-backend-test.cpp b/tests/hrx-backend-test.cpp index b517d04c96c1..f8a0791a322b 100644 --- a/tests/hrx-backend-test.cpp +++ b/tests/hrx-backend-test.cpp @@ -15602,6 +15602,14 @@ static const HipAddonLabel * hip_addon_known_fail(const char * name) { { "packed_layout_follows_weight.q4_k.uploaded", kLayout, "found == 1" }, { "packed_layout_follows_weight.q4_k.file_mapped.tokens6", kLayout, "found == 1" }, { "packed_layout_follows_weight.q4_k.file_mapped.stored_copy", kLayout, "found == 1" }, + // gpu-kernels#84 added the 306 entry that claims a 256-aligned batch of a Q4_K weight Loom reads STORED, which is + // exactly this case's stored-copy arm: the kernel is now hip.dense_prefill.mm_q4k_stored instead of the Loom + // q5_k/iq4_xs form the arm asserts. Measured rather than assumed: the add-on build before #84 (gk-b0ed206) passes the + // case, and at the pin it fails at :3712 unless GGML_HRX_HIP_DENSE_PREFILL_Q4K_STORED=0 -- the opt-out gpu-kernels#85 + // added -- in which case it passes again. The label is arm-scoped by hip_addon_dispatch_active(), which is why the + // loom-only row still asserts the Loom kernel and still passes. + { "q4k_aligned_prefill_layout.stored_copy", kPlan, + "ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256" }, { "packed_layout_follows_weight.q6_k.file_mapped", kLayout, "found == 1" }, { "packed_layout_follows_weight.q6_k.uploaded", kLayout, "found == 1" }, { "packed_layout_follows_weight.q6_k.file_mapped.tokens8", kLayout, "found == 1" }, From c11a4cfd14021460c08204157898747046c72304 Mon Sep 17 00:00:00 2001 From: bcloud Date: Sat, 14 Nov 2026 17:11:59 -0400 Subject: [PATCH 2/2] hrx-backend-test: assert the add-on path in q4k_aligned_prefill_layout.stored_copy instead of labelling it The three reviews of the label asked the right question -- is the expectation change temporary or permanent? It is permanent (gpu-kernels#84's 306 entry claiming a 256-aligned stored-read Q4_K prefill is the shipped +25-28 %, not a stopgap), so the case should say what the add-on path DOES rather than be excused from reaching a verdict. And asking that question found a second, larger thing: with the label the case aborted at its FIRST match (:3712), so nothing ever checked what followed; with the assertions passing, `found` turned out to be 3 on the add-on path and 1 on Loom. `REQUIRE(found == 1)` was arm-blind -- the weight is bound by three dispatches on the add-on path (#84's entry is reached through them) and by one on Loom. The label had been hiding both that invariant and the kernel expectation, for as long as it existed. What the case now asserts, per arm: stored_copy_exists: REQUIRE(binding.layout == kNativeWeightLayout) measured ggml-native on BOTH paths hip_addon_dispatch_active() -> REQUIRE(name starts with "hip:") otherwise -> REQUIRE(name == loom_libs:...q5_k_iq4_xs..._token256) + weight_format == "4" final count: add-on >= 1 (measured 3), Loom == 1 (unchanged) `>= 1` rather than `== 3` deliberately: three is a plan-shape number that moves the next time the add-on materialises differently, while the invariant this case protects -- the weight is bound by the dispatch whose parameters were just asserted -- is enforced per binding in both arms. What the add-on arm cannot do, stated so nobody assumes otherwise: it cannot name the kernel, because add-on ids are hashed by design (#2392) and this one moves with any kernel edit. The specific choice stays pinned by GGML_HRX_HIP_DENSE_PREFILL_Q4K_STORED=0 (gpu-kernels#85's opt-out, which flips the row back to the Loom kernel) and by gpu-kernels' own tile probes. Verified (add-on build at the pin): add-on row [PASS] 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass -loom row [PASS] 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass (GGML_HRX_DISABLE_DISPATCH=hip.) (the hip_addon_known_fail entry is removed: with the case passing in both arms it would report UNEXPECTED-PASS) Refs gpu-kernels#84 (the 306 entry), gpu-kernels#85 (the opt-out and the tile probes), engine#2392 (why add-on ids are hashed, and the UNEXPECTED-PASS rule that retires a stale label), gpu-kernels#86 where the failure was reported. --- tests/hrx-backend-test.cpp | 40 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tests/hrx-backend-test.cpp b/tests/hrx-backend-test.cpp index f8a0791a322b..d949262fc672 100644 --- a/tests/hrx-backend-test.cpp +++ b/tests/hrx-backend-test.cpp @@ -218,6 +218,9 @@ static std::string kernel_name_for_id(uint64_t kernel_id) { return ggml::hrx::kernel_definition_name(*resolved.definition); } +// scopes a case to the add-on path (defined with the label table, further down) +static bool hip_addon_dispatch_active(); + static void require_compile_parameter(const ggml::hrx::Dispatch & dispatch, const char * name, const std::string & value) { @@ -3709,16 +3712,37 @@ static void schedule_q4k_aligned_prefill_layout(bool stored_copy_exists) { } ++found; if (stored_copy_exists) { - REQUIRE(name == "loom_libs:ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256"); - require_compile_parameter(dispatch, "ggml.mul_mat_q8_1_x4.weight_format", "4"); - REQUIRE(binding.layout == ggml::hrx::kNativeWeightLayout); + // gpu-kernels#84's 306 entry claims a 256-aligned batch of a Q4_K weight Loom reads STORED, which is this arm + // exactly, so the add-on path plans hip.dense_prefill.mm_q4k_stored here while the Loom q5_k/iq4_xs form below + // is the loom row's expectation. Asserted per arm rather than left to hip_addon_known_fail: #84's routing is + // permanent, and a label would stop this case checking the add-on path at all. + // + // The kernel id cannot be asserted -- add-on ids are hashed by design (#2392) and this one moves with any + // kernel edit -- so the add-on arm asserts the identifier CLASS plus the layout, which is the property this arm + // was written for. Which add-on kernel is chosen stays pinned by GGML_HRX_HIP_DENSE_PREFILL_Q4K_STORED=0 (the + // opt-out gpu-kernels#85 added, which flips this row back to the Loom kernel) and by gpu-kernels' tile probes. + REQUIRE(binding.layout == ggml::hrx::kNativeWeightLayout); // measured: ggml-native on both paths + if (hip_addon_dispatch_active()) { + REQUIRE(name.rfind("hip:", 0) == 0); + } else { + REQUIRE(name == "loom_libs:ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256"); + require_compile_parameter(dispatch, "ggml.mul_mat_q8_1_x4.weight_format", "4"); + } } else { REQUIRE(name == "loom_libs:ggml_mul_mat_q4_k_f16_wmma_prefill_wave32"); REQUIRE(binding.layout != ggml::hrx::kNativeWeightLayout); } } } - REQUIRE(found == 1); + // The weight-reference count is arm-specific, measured: 1 on the Loom path (one kernel binds it), 3 on the add-on + // path, where #84's dense-prefill entry is reached through the dispatches that also bind the weight. The old + // `found == 1` was arm-blind -- and ipso facto unreachable on the add-on path once the case stopped aborting at its + // first match, which is what the known-fail label had hidden. + if (hip_addon_dispatch_active()) { + REQUIRE(found >= 1); + } else { + REQUIRE(found == 1); + } ggml_backend_buffer_free(buffer); ggml_free(ctx); } @@ -15602,14 +15626,6 @@ static const HipAddonLabel * hip_addon_known_fail(const char * name) { { "packed_layout_follows_weight.q4_k.uploaded", kLayout, "found == 1" }, { "packed_layout_follows_weight.q4_k.file_mapped.tokens6", kLayout, "found == 1" }, { "packed_layout_follows_weight.q4_k.file_mapped.stored_copy", kLayout, "found == 1" }, - // gpu-kernels#84 added the 306 entry that claims a 256-aligned batch of a Q4_K weight Loom reads STORED, which is - // exactly this case's stored-copy arm: the kernel is now hip.dense_prefill.mm_q4k_stored instead of the Loom - // q5_k/iq4_xs form the arm asserts. Measured rather than assumed: the add-on build before #84 (gk-b0ed206) passes the - // case, and at the pin it fails at :3712 unless GGML_HRX_HIP_DENSE_PREFILL_Q4K_STORED=0 -- the opt-out gpu-kernels#85 - // added -- in which case it passes again. The label is arm-scoped by hip_addon_dispatch_active(), which is why the - // loom-only row still asserts the Loom kernel and still passes. - { "q4k_aligned_prefill_layout.stored_copy", kPlan, - "ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256" }, { "packed_layout_follows_weight.q6_k.file_mapped", kLayout, "found == 1" }, { "packed_layout_follows_weight.q6_k.uploaded", kLayout, "found == 1" }, { "packed_layout_follows_weight.q6_k.file_mapped.tokens8", kLayout, "found == 1" },