Skip to content

Commit 55945d2

Browse files
authored
ggml: fix CUDA grid launch condition for large block_nums.y in binbcast (ggml-org#16742)
* Fix CUDA grid launch condition for large block_nums.y * add backend ops test * reduce test repetitions
1 parent 0bcb40b commit 55945d2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

ggml/src/ggml-cuda/binbcast.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void launch_bin_bcast_pack(const ggml_tensor * src0, const ggml_tensor *
272272
const uint3 ne12 = init_fastdiv_values((uint32_t) cne1[2]);
273273
const uint3 ne13 = init_fastdiv_values((uint32_t) cne1[3]);
274274

275-
if (block_nums.z > 65535) {
275+
if (block_nums.z > 65535 || block_nums.y > 65535) {
276276
int block_num = (ne0 * ne1 * ne2 * ne3 + block_size - 1) / block_size;
277277
const uint3 prod_012 = init_fastdiv_values((uint32_t) (ne0 * ne1 * ne2));
278278
const uint3 prod_01 = init_fastdiv_values((uint32_t) (ne0 * ne1));

tests/test-backend-ops.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6407,6 +6407,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
64076407
add_test_bin_bcast(type, {1, 1, 640, 1}, {32, 32, 1, 1});
64086408
add_test_bin_bcast(type, {5120, 1, 1, 1}, {1, 256, 1, 1});
64096409
add_test_bin_bcast(type, {640, 1, 1, 1}, {1, 1, 1, 1});
6410+
add_test_bin_bcast(type, {64, 262144, 1, 1}, {1, 1, 1, 1});
64106411
//add_test_bin_bcast(type, {3, 3, 2560, 1280}, {1, 1, 1, 1});
64116412
//add_test_bin_bcast(type, {3, 3, 2560, 1280}, {2, 1, 1, 1});
64126413
}

0 commit comments

Comments
 (0)