[GLM5.1/5.2] Fix acc drop for long prompt#1379
Open
zejunchen-zejun wants to merge 3 commits into
Open
Conversation
Signed-off-by: zejunchen-zejun <zejun.chen@amd.com>
Signed-off-by: zejunchen-zejun <zejun.chen@amd.com>
Signed-off-by: zejunchen-zejun <zejun.chen@amd.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses long-prompt accuracy drops for GLM-5.1/5.2 (and confirms no regression for DeepSeek-V3.2) by fixing multiple issues in sparse MLA prefill/indexing, including causality handling, RoPE application in the indexer path, and correct sparse-mode selection for GLM-5.2 IndexShare “shared” layers.
Changes:
- Fix indexer scoring to apply RoPE to q/k before computing QK scores, and make RoPE style configurable via
rope_interleave. - Fix sparse prefill metadata construction to preserve causality across chunked prefill (per-token virtual decode layout) and generate the required sparse-prefill MLA metadata.
- Ensure GLM-5.2 IndexShare “shared” layers still run sparse MLA by deriving sparsity at the model level (not per-layer
indexer is None).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| atom/models/deepseek_v2.py | Applies RoPE correctly in indexer q/k scoring and propagates model-level sparse settings for IndexShare layers. |
| atom/model_ops/attentions/aiter_mla.py | Builds sparse-prefill per-token causality metadata and allocates/publishes sparse-prefill MLA work buffers. |
| atom/model_ops/attention_mla.py | Adds model-level sparse flag/top-k plumbing and forwards sparse-prefill work metadata into mla_decode_fwd. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+208
to
+216
| ) = get_mla_metadata_info_v1( | ||
| self.max_num_batched_tokens, | ||
| 1, # sparse prefill treats each query token as q_len=1 | ||
| self.padded_num_attention_heads, | ||
| self.dtype_q, | ||
| self.dtype_kv, | ||
| is_sparse=True, | ||
| fast_mode=True, | ||
| ) |
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.
Before fix:
0.9454130.9393480.7800000.7800000.9431390.9438970.0015160.012130After fix:
0.9355572403335860.93176648976497340.94465504169825620.94541319181197880.94162244124336610.94162244124336610.94541319181197880.94541319181197880.95147839272175890.95147839272175890.95299469294920390.9537528430629265How to fix: