Skip to content

glm5next: avoid soft_max gridDim.y overflow in the indexer - #214

Merged
danielhanchen merged 2 commits into
unslothai:glm5next/upstreamfrom
AIalliAI:fix/glm5next-kpool-softmax-grid-y
Sep 16, 2026
Merged

danielhanchen merged 2 commits into
unslothai:glm5next/upstreamfrom
AIalliAI:fix/glm5next-kpool-softmax-grid-y

Conversation

@AIalliAI

@AIalliAI AIalliAI commented Sep 11, 2026

Copy link
Copy Markdown

Overview

Reshape k-pool indexer gate logits before ggml_soft_max so n_new_max does not map to gridDim.y, which is capped at 65535 on CUDA. During k-pool rebuild at long context (n_kv >= 262144, kpool = 4), n_new_max reaches 65538 and the launch aborts with SOFT_MAX failed.

Fold n_new_max and n_stream into ne1 via ggml_reshape_2d, then reshape back to 4D for downstream mul / sum_rows. Same pattern as qwen4exp.cpp.

Stacked on ggml-org#27754.

Additional information

Related: ggml-org#27773, timkhronos#11, ggml-org#27901

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - assisted implementation and review; I understand the change and can maintain it.

@AIalliAI
AIalliAI requested a review from CISC as a code owner September 11, 2026 02:23
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@danielhanchen
danielhanchen merged commit 86ebfef into unslothai:glm5next/upstream Sep 16, 2026
danielhanchen added a commit that referenced this pull request Sep 16, 2026
#214 landed on glm5next/upstream, so e2738e0 is no longer the head.
86ebfef is that squash on top of it: the k-pool gate logits are reshaped to 2D
before ggml_soft_max so n_new_max stops mapping to gridDim.y, which is capped at
65535 and aborted the launch at n_kv >= 262144 with kpool = 4.

Replayed the resolve loop on b10994: 11 clean, 2 additive, 0 hard fails.
danielhanchen added a commit that referenced this pull request Sep 16, 2026
#214 landed on glm5next/upstream after #216 was cut, so e2738e0 is no
longer the head. 86ebfef is that squash on top of it: the k-pool gate logits are
reshaped to 2D before ggml_soft_max so n_new_max stops mapping to gridDim.y,
which CUDA caps at 65535 and which aborted the launch at n_kv >= 262144 with
kpool = 4.

Replayed the resolve loop on b10994 with the new pin: 11 clean, 2 additive, 0
hard fails; merge_checks clean, all 13 pins intact, llama + mtmd compile gate
passed, test-llama-archs 316 rows 0 failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants