diff --git a/tests/hrx-backend-test.cpp b/tests/hrx-backend-test.cpp index b37d0ac9e3ab..93598f3e00ad 100644 --- a/tests/hrx-backend-test.cpp +++ b/tests/hrx-backend-test.cpp @@ -1,3 +1,4 @@ +#include "dispatch_registration/common/dispatch-moe-routing-layout.h" // engine#2381: one layout, not two #include "testing_suite.h" #include "ggml-cpu.h" #include "backend-buffer-binding.h" @@ -357,7 +358,13 @@ static std::vector make_qwen_partition_table_reference(const std::vecto if (row_count > 32) { row_count = 32; } - const int32_t descriptor = static_cast(expert) | (partition << 9) | ((row_count - 1) << 15); + // engine#2381: share the router's own layout instead of re-deriving it. The router emits the Qwen layout + // (shift 7/13) at <= 128 experts because that is what the qwen3_moe routed kernels decode; hard-coding the + // common layout (9/15) here made every entry of a 128-expert table disagree with a correct device result. + const ggml::hrx::MoeRoutingDescriptorLayout layout = ggml::hrx::moe_router_descriptor_layout(expert_count); + const int32_t descriptor = static_cast(expert) | + (partition << std::atoi(layout.partition_shift)) | + ((row_count - 1) << std::atoi(layout.row_count_shift)); partition_table[static_cast(1 + partition_count)] = descriptor; ++partition_count; } diff --git a/tests/test-hrx-ops.cpp b/tests/test-hrx-ops.cpp index c9afe389c98a..5e660dde2018 100644 --- a/tests/test-hrx-ops.cpp +++ b/tests/test-hrx-ops.cpp @@ -5201,7 +5201,14 @@ static void run_decode_routed_moe_scheduling_case(ggml_type down_weight_type, bo const bool gate_up_routed = test_sequence_has(sequence, "qwen3_moe:qwen3_moe_routed_gate_up_swiglu_q4k_q8_1_x4_next_q8") || test_sequence_has(sequence, "qwen3_moe:qwen3_moe_routed_gate_up_swiglu_q4k_q8") || - test_sequence_has(sequence, "loom_libs:ggml_mul_mat_id_swiglu_f32_f32_wmma"); + test_sequence_has(sequence, "loom_libs:ggml_mul_mat_id_swiglu_f32_f32_wmma") || + // engine#2374: after #118 factored the monolith into composable kernels, the registration + // "common.mul_mat_id_swiglu.f32_f32_wmma" selects the tiled/skinny *pair-input publish* kernels + // (see mul_mat_id_swiglu_f32_kernel(): skinny at token_count <= 5, tiled above). Those are the same + // routed gate/up SwiGLU computation under the composable names, so the intent of this check -- + // "a routed mul_mat_id SwiGLU kernel is in the plan" -- is satisfied by either naming. + test_sequence_has(sequence, "loom_libs:ggml_mul_mat_id_skinny_pair_input_f32_swiglu_publish_f32") || + test_sequence_has(sequence, "loom_libs:ggml_mul_mat_id_tiled_pair_input_f32_swiglu_publish_f32"); REQUIRE(gate_up_routed); require_kernel_subsequence(sequence, { "qwen3_moe:qwen3_moe_router_projection_top8_fused_decode_f32",