Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions tests/hrx-backend-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down