Negative KV sequence length error in Attention op#4316
Open
jinminxi104 wants to merge 1 commit intoInternLM:mainfrom
Open
Negative KV sequence length error in Attention op#4316jinminxi104 wants to merge 1 commit intoInternLM:mainfrom
jinminxi104 wants to merge 1 commit intoInternLM:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a dp>1 decoding failure (negative KV sequence length) by ensuring num_ignored_history does not retain stale/incorrect values when sliding-window attention is disabled.
Changes:
- When
cache_config.window_size <= 0,create_model_inputs_delta()now emits a zeronum_ignored_historytensor (instead ofNone) so downstream decoding-input updates reset ignore history to 0.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
grimoire
approved these changes
Feb 3, 2026
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.
While testing on the Ascend platform, the attention operator encountered an error due to a negative KV sequence length.
(shareGPT case with 10k prompt + qwen-235B)
Root Cause: The issue occurs when ignore_history is too large in a dp configuration where dp > 1.
Error Logs:
This behavior was introduced in #4265; versions prior to this PR do not exhibit the bug.