From 2dc7307f9eb43778059002462e3f5a18a5c68c58 Mon Sep 17 00:00:00 2001 From: AlliDev <285906080+AIalliAI@users.noreply.github.com> Date: Fri, 11 Sep 2026 02:16:42 +0000 Subject: [PATCH 1/2] glm5next: avoid soft_max gridDim.y overflow in the indexer Assisted-by: Cursor --- src/models/glm5next.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/glm5next.cpp b/src/models/glm5next.cpp index 98922645fd4e..a704b5f580a1 100644 --- a/src/models/glm5next.cpp +++ b/src/models/glm5next.cpp @@ -383,7 +383,9 @@ ggml_tensor * llama_model_glm5next::graph::build_indexer( ggml_tensor * ape = ggml_cont(ctx0, ggml_transpose(ctx0, layer.indexer_comp_ape)); gate_t = ggml_add(ctx0, gate_t, ggml_reshape_4d(ctx0, ape, r, d_idx, 1, 1)); - ggml_tensor * probs = ggml_soft_max(ctx0, gate_t); + // count new pools along ne1: soft_max launches gridDim.y = ne2, capped at 65535, and 262144/4 = 65536 + ggml_tensor * probs = ggml_soft_max(ctx0, ggml_reshape_2d(ctx0, gate_t, r, d_idx*n_new_max*n_stream)); + probs = ggml_reshape_4d(ctx0, probs, r, d_idx, n_new_max, n_stream); cb(probs, "indexer_pool_probs", il); ggml_tensor * pool_new = ggml_sum_rows(ctx0, ggml_mul(ctx0, keys_t, probs)); From d798de9ee6aeaebfe538983c9ea59e9ebb754d06 Mon Sep 17 00:00:00 2001 From: AlliDev <285906080+AIalliAI@users.noreply.github.com> Date: Fri, 11 Sep 2026 02:22:53 +0000 Subject: [PATCH 2/2] glm5next: clarify soft_max gridDim comment Assisted-by: Cursor --- src/models/glm5next.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/glm5next.cpp b/src/models/glm5next.cpp index a704b5f580a1..5b617c02b07e 100644 --- a/src/models/glm5next.cpp +++ b/src/models/glm5next.cpp @@ -383,7 +383,7 @@ ggml_tensor * llama_model_glm5next::graph::build_indexer( ggml_tensor * ape = ggml_cont(ctx0, ggml_transpose(ctx0, layer.indexer_comp_ape)); gate_t = ggml_add(ctx0, gate_t, ggml_reshape_4d(ctx0, ape, r, d_idx, 1, 1)); - // count new pools along ne1: soft_max launches gridDim.y = ne2, capped at 65535, and 262144/4 = 65536 + // soft_max maps ne2/ne3 to gridDim.y/z (65535 cap); fold into ne1 ggml_tensor * probs = ggml_soft_max(ctx0, ggml_reshape_2d(ctx0, gate_t, r, d_idx*n_new_max*n_stream)); probs = ggml_reshape_4d(ctx0, probs, r, d_idx, n_new_max, n_stream); cb(probs, "indexer_pool_probs", il);