Skip to content

Support GLM DSA IndexShare layers - #897

Merged
i386 merged 1 commit into
mainfrom
feat/reverse-stage-transport-main
Jun 23, 2026
Merged

Support GLM DSA IndexShare layers#897
i386 merged 1 commit into
mainfrom
feat/reverse-stage-transport-main

Conversation

@i386

@i386 i386 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add the GLM DSA IndexShare llama.cpp patch to the mesh-llm patch queue
  • mark GLM DSA indexer tensors optional so layers without local indexer weights can load
  • reuse the previous sparse-layer top-k for IndexShare layers and assert that attention receives one

Validation

  • LLAMA_WORKDIR="/tmp/mesh-llm-llama.bTs460" scripts/prepare-llama.sh pinned

Summary by CodeRabbit

  • Bug Fixes

    • Fixed GLM DSA layer handling to properly support sparse attention configurations and improved tensor requirement validation.
  • Performance

    • Optimized tensor allocation by making indexer tensors conditional rather than required for all layers, reducing memory overhead.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new patch adds support for GLM DSA "IndexShare" layers where some transformer layers lack indexer tensors. The loader marks indexer_* tensors as TENSOR_NOT_REQUIRED, the graph builder tracks a shared_top_k from fully-indexed layers and reuses it for indexer-less layers, and the attention builder gains a non-null assertion on top_k.

Changes

GLM DSA IndexShare Layer Support

Layer / File(s) Summary
Mark GLM DSA indexer tensors as optional
third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch (glm-dsa.cpp hunk)
indexer_* tensors are created with TENSOR_NOT_REQUIRED, allowing layers without sparse indexer weights to load without error.
shared_top_k reuse and non-null assertion
third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch (deepseek32.cpp and llama-graph.cpp hunks)
Graph construction stores top_k as shared_top_k when indexer tensors are present and reuses it (with a distinct callback label) for layers that lack them, guarded by an assert. build_attn adds an assert that top_k is non-null before proceeding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Support GLM DSA IndexShare layers' directly describes the primary change—adding support for GLM DSA IndexShare layer configurations in the mesh-llm project.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/reverse-stage-transport-main

Comment @coderabbitai help to get the list of available commands.

@i386
i386 force-pushed the feat/reverse-stage-transport-main branch from 1064cf8 to 0870fbf Compare June 23, 2026 01:56
@i386 i386 changed the title Fix GLM split serving support Support GLM DSA IndexShare layers Jun 23, 2026
@i386
i386 marked this pull request as ready for review June 23, 2026 02:00
@github-actions
github-actions Bot requested a review from michaelneale June 23, 2026 02:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch (1)

60-63: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Renaming the shared top_k node every layer may obscure graph inspection.

cb(top_k, "top_k_shared", il) re-labels the same tensor node produced in an earlier layer, so each indexer-less layer overwrites the node's name. Debug/inspection tooling that relies on stable tensor names will only ever see the last il. Consider skipping the rename on the shared path (the original cb(top_k, "top_k", il) name from the seeding layer is sufficient), or only attaching a view.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch`
around lines 60 - 63, The callback invocation `cb(top_k, "top_k_shared", il)` is
being executed for every layer in the DSA IndexShare path, which repeatedly
overwrites the name of the shared top_k tensor node. This prevents debugging and
inspection tools from having a stable tensor name across layers. Remove the
callback invocation on the shared path, or modify it to preserve the original
tensor name from the seeding layer instead of relabeling it for each subsequent
layer that reuses the shared tensor.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch`:
- Around line 60-63: The callback invocation `cb(top_k, "top_k_shared", il)` is
being executed for every layer in the DSA IndexShare path, which repeatedly
overwrites the name of the shared top_k tensor node. This prevents debugging and
inspection tools from having a stable tensor name across layers. Remove the
callback invocation on the shared path, or modify it to preserve the original
tensor name from the seeding layer instead of relabeling it for each subsequent
layer that reuses the shared tensor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 651f3924-e6ad-4f7e-990d-db3bd6271a4c

📥 Commits

Reviewing files that changed from the base of the PR and between e30ab68 and 0870fbf.

📒 Files selected for processing (1)
  • third_party/llama.cpp/patches/0110-Support-GLM-DSA-IndexShare-layers.patch

@i386
i386 merged commit 3e6805d into main Jun 23, 2026
50 of 60 checks passed
@i386
i386 deleted the feat/reverse-stage-transport-main branch June 23, 2026 02:35
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.

1 participant