Skip to content

Commit e362ffa

Browse files
jeffbolznvMinh141120
authored andcommitted
vulkan: Split large mul_mat_id to fit in shared memory (ggml-org#14451)
1 parent 3c0d890 commit e362ffa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10161,9 +10161,15 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggm
1016110161
ggml_type src0_type = op->src[0]->type;
1016210162
ggml_backend_vk_device_context * ctx = (ggml_backend_vk_device_context *)dev->context;
1016310163
const vk_device& device = ggml_vk_get_device(ctx->device);
10164-
if (op->op == GGML_OP_MUL_MAT_ID && !device->mul_mat_id_s[src0_type] && !device->mul_mat_id_m[src0_type] && !device->mul_mat_id_l[src0_type]) {
10165-
// If there's not enough shared memory for row_ids and the result tile, fallback to CPU
10166-
return false;
10164+
if (op->op == GGML_OP_MUL_MAT_ID) {
10165+
if (!device->mul_mat_id_s[src0_type] && !device->mul_mat_id_m[src0_type] && !device->mul_mat_id_l[src0_type]) {
10166+
// If there's not enough shared memory for row_ids and the result tile, fallback to CPU
10167+
return false;
10168+
}
10169+
// Check against size of shared memory variable
10170+
if (op->src[2]->ne[0] > 4096) {
10171+
return false;
10172+
}
1016710173
}
1016810174
switch (src0_type) {
1016910175
case GGML_TYPE_F32:

0 commit comments

Comments
 (0)