[v0.9.1][Bugfix] Reset all unused positions to prevent out-of-bounds in GatherV3 #1397
+1
−0
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.
What this PR does / why we need it?
Reset all unused positions in
NPUModelRunner
to prevent out-of-bounds asserts in theGatherV3
operator.Currently, in
get_splitfuse_attn_mask
, theposition
tensor may contain values that exceed the dimensions of the attention mask, triggering aGatherV3
boundary check failure. These invalid indices originate from stale “dirty” entries left over inposition
due to padding logic in the ACL graph. Specifically, in_process_reqs
, the variablenum_input_tokens
is always greater than or equal tototal_num_scheduled_tokens
, so any positions not explicitly cleared from a previous batch will persist and cause this sporadic error.BTW, in the original vLLM implementation, masks are constructed internally using other args, so these lingering values do not surface. However, on the Ascend platform—where split-fuse attention requires externally supplied masks—these residual indices become critical and lead to this elusive, hard-to-reproduce failure.
The fix is to explicitly reset or zero out all unused entries in the
position
tensor before passing it toGatherV3
, ensuring that every index lies within the valid range of the attention mask.Does this PR introduce any user-facing change?
How was this patch tested?