From e40bf886420d9449cee9aab8a417081cde4620d1 Mon Sep 17 00:00:00 2001 From: JamePeng Date: Fri, 7 Aug 2026 12:49:14 +0800 Subject: [PATCH] metal : avoid `threadgroup` matrix array instantiation in kernel_lightning_indexer (#26646) - In MSL, declaring an array of matrix types like `threadgroup half4x4` causes a 'no matching constructor' compilation error because MSL matrix types do not have zero-argument default constructors and threadgroup variables cannot have initializers. - Fix this by declaring a POD `threadgroup half` array instead and casting to `threadgroup half4x4 *` for matrix indexing. Signed-off-by: JamePeng --- ggml/src/ggml-metal/ggml-metal.metal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-metal/ggml-metal.metal b/ggml/src/ggml-metal/ggml-metal.metal index 7d12cb0fe3..92258b7374 100644 --- a/ggml/src/ggml-metal/ggml-metal.metal +++ b/ggml/src/ggml-metal/ggml-metal.metal @@ -11328,8 +11328,8 @@ kernel void kernel_lightning_indexer( const int i_kv_0 = tgpig.x*NK; // first key of this threadgroup const int i_kv = i_kv_0 + sgitg*NKPSG; // first key of this simdgroup - threadgroup half4x4 sk4x4[NK*DK16]; - threadgroup half * sk = (threadgroup half *) sk4x4; + threadgroup half sk[NK * DK16 * 16]; + threadgroup half4x4 * sk4x4 = (threadgroup half4x4 *) sk; for (short i = tiitg; i < NK*DK16; i += NTG) { const short ik = i/DK16;