Skip to content

Commit d9b6860

Browse files
committed
vulkan: fix matmul pipeline selection for small n values
Change mul_mat and mul_mat_id pipeline selection heuristic to prevent Intel Arc GPU hangs. The previous logic would select the small pipeline (mul_mat_id_s) when one dimension was small, causing hangs on Intel Arc when, e.g. m=512 and n=23 as it happens with IBM Granite 4. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent 0e4a0cf commit d9b6860

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,10 +5826,10 @@ static vk_pipeline ggml_vk_guess_matmul_pipeline(ggml_backend_vk_context * ctx,
58265826
return aligned ? mmp->a_s : mmp->s;
58275827
}
58285828

5829-
if ((ctx->device->mul_mat_s[src0_type] && (m <= 32 || n <= 32)) || (!ctx->device->mul_mat_m[src0_type] && !ctx->device->mul_mat_l[src0_type])) {
5829+
if ((ctx->device->mul_mat_s[src0_type] && (m * n <= 32 * 32)) || (!ctx->device->mul_mat_m[src0_type] && !ctx->device->mul_mat_l[src0_type])) {
58305830
return aligned ? mmp->a_s : mmp->s;
58315831
}
5832-
if ((ctx->device->mul_mat_m[src0_type] && (m <= 64 || n <= 64)) || !ctx->device->mul_mat_l[src0_type]) {
5832+
if ((ctx->device->mul_mat_m[src0_type] && (m * n <= 64 * 64)) || !ctx->device->mul_mat_l[src0_type]) {
58335833
return aligned ? mmp->a_m : mmp->m;
58345834
}
58355835
return aligned ? mmp->a_l : mmp->l;
@@ -5892,10 +5892,10 @@ static vk_pipeline ggml_vk_guess_matmul_id_pipeline(ggml_backend_vk_context * ct
58925892
return aligned ? mmp->a_s : mmp->s;
58935893
}
58945894

5895-
if ((ctx->device->mul_mat_id_s[src0_type] && (m <= 32 || n <= 32)) || (!ctx->device->mul_mat_id_m[src0_type] && !ctx->device->mul_mat_id_l[src0_type])) {
5895+
if ((ctx->device->mul_mat_id_s[src0_type] && (m * n <= 32 * 32)) || (!ctx->device->mul_mat_id_m[src0_type] && !ctx->device->mul_mat_id_l[src0_type])) {
58965896
return aligned ? mmp->a_s : mmp->s;
58975897
}
5898-
if ((ctx->device->mul_mat_id_m[src0_type] && (m <= 64 || n <= 64)) || !ctx->device->mul_mat_id_l[src0_type]) {
5898+
if ((ctx->device->mul_mat_id_m[src0_type] && (m * n <= 64 * 64)) || !ctx->device->mul_mat_id_l[src0_type]) {
58995899
return aligned ? mmp->a_m : mmp->m;
59005900
}
59015901
return aligned ? mmp->a_l : mmp->l;

0 commit comments

Comments
 (0)