Fix: interleaved RoPE application for MLA and Support Index Cache DSA indexer skip-topk sharing for GLM5 - #46372
Merged
Merged
Conversation
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Member
ArthurZucker
reviewed
Jun 4, 2026
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
reviewed offline! 🤗
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
ArthurZucker
approved these changes
Jun 5, 2026
Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: glm_moe_dsa |
ArthurZucker
approved these changes
Jun 8, 2026
ArthurZucker
left a comment
Collaborator
There was a problem hiding this comment.
Ty!
We discussed offline can’t use rotation one weights as this would break nope/rope that follows
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
khushali9
pushed a commit
to khushali9/transformers
that referenced
this pull request
Jun 8, 2026
… indexer skip-topk sharing for GLM5 (huggingface#46372) * Fix error attributes mapping Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix: Support interleaved RoPE for MLA Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove redundant fields Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove portentially codepath Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Optimize code Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> --------- Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
louzongzhi
pushed a commit
to louzongzhi/transformers
that referenced
this pull request
Jun 10, 2026
… indexer skip-topk sharing for GLM5 (huggingface#46372) * Fix error attributes mapping Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix: Support interleaved RoPE for MLA Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove redundant fields Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove portentially codepath Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Optimize code Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> --------- Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
louzongzhi
pushed a commit
to louzongzhi/transformers
that referenced
this pull request
Jun 10, 2026
… indexer skip-topk sharing for GLM5 (huggingface#46372) * Fix error attributes mapping Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix: Support interleaved RoPE for MLA Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove redundant fields Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove portentially codepath Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Optimize code Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> --------- Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
6 tasks
stevhliu
pushed a commit
to stevhliu/transformers
that referenced
this pull request
Jul 30, 2026
… indexer skip-topk sharing for GLM5 (huggingface#46372) * Fix error attributes mapping Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix: Support interleaved RoPE for MLA Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove redundant fields Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Fix tests Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Remove portentially codepath Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> * Optimize code Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com> --------- Signed-off-by: Shijin Zhang <75300765+Dovis01@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix interleaved RoPE for MLA and add MoE/DSA indexer cache to accelerate Sparse Attention
Summary
This PR fixes several correctness issues in GlmMoeDsa around RoPE application. It also adds DSA indexer cache / skip-topk support for GLM5: on
sharedlayers, attention reuses the previous full indexer layer’s top-k indices instead of recomputing them, reducing repeated top-k computation and accelerating Sparse Attention.This feature is inspired by the index cache technique described in this paper
Index cache, and adapts the idea to the GLM5 MoE/DSA attention path.