Skip to content

Commit a275f10

Browse files
committed
Fix bug: fix tie breakers
1 parent d4e54a4 commit a275f10

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ggml/src/ggml-cuda/topk-moe.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ __launch_bounds__(4 * WARP_SIZE, 1) __global__ void topk_moe_cuda(const float *
8585
for (int mask = WARP_SIZE / 2; mask > 0; mask /= 2) {
8686
const float val = __shfl_xor_sync(0xFFFFFFFF, max_val, mask, WARP_SIZE);
8787
const int expert = __shfl_xor_sync(0xFFFFFFFF, max_expert, mask, WARP_SIZE);
88-
if (val > max_val) {
88+
if (val > max_val || (val == max_val && expert < max_expert)) {
8989
max_val = val;
9090
max_expert = expert;
9191
}

tests/test-backend-ops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6625,7 +6625,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
66256625

66266626
test_cases.emplace_back(new test_topk_moe({8, 22, 1, 1}, 4));
66276627
test_cases.emplace_back(new test_topk_moe({32, 22, 1, 1}, 8));
6628-
test_cases.emplace_back(new test_topk_moe({128, 19, 1, 1}, 16));
6628+
test_cases.emplace_back(new test_topk_moe({128, 1, 1, 1}, 128));
66296629

66306630
#if 0
66316631
// these tests are disabled to save execution time, sbut they can be handy for debugging

0 commit comments

Comments
 (0)