From e6dbc81569ac56d3a6973579263b53c69a815fa5 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 10 Nov 2025 16:17:09 +0200 Subject: [PATCH] metal : cap threadgroups size of set_rows --- ggml/src/ggml-metal/ggml-metal-ops.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ggml/src/ggml-metal/ggml-metal-ops.cpp b/ggml/src/ggml-metal/ggml-metal-ops.cpp index 7a85edbdcd..5a8f150a71 100644 --- a/ggml/src/ggml-metal/ggml-metal-ops.cpp +++ b/ggml/src/ggml-metal/ggml-metal-ops.cpp @@ -1036,6 +1036,11 @@ int ggml_metal_op_set_rows(ggml_metal_op_t ctx, int idx) { nth = std::min(nth, nk0); + if (nth*nrptg > ggml_metal_pipeline_max_theads_per_threadgroup(pipeline)) { + nth = ggml_metal_pipeline_max_theads_per_threadgroup(pipeline); + nrptg = 1; + } + ggml_metal_kargs_set_rows args = { /*.nk0 =*/ nk0, /*.ne01 =*/ ne01,