Skip to content

Commit 9f35cc6

Browse files
committed
[Refactor] Deduplicate next_tokens assignment in attention_v1
Moved next_tokens=0 out of the if else branches to a unified initialization. Signed-off-by: vv <939082363@qq.com>
1 parent 1a4091f commit 9f35cc6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

vllm_ascend/attention/attention_v1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,16 @@ def full_graph_fia(
619619
input_layout = "TND"
620620
attn_mask = attn_metadata.attn_mask
621621

622+
# next_tokens only takes effect when sparse_mode=4 (sliding window attention);
623+
# for other sparse modes it is ignored, so we set it to 0 by default.
624+
next_tokens = 0
622625
if self.sliding_window is not None:
623626
sparse_mode = 4
624627
pre_tokens = self.sliding_window
625-
next_tokens = 0
628+
626629
else:
627630
sparse_mode = 3 if attn_metadata.causal else 0
628631
pre_tokens = SWA_INT_MAX
629-
next_tokens = 0
630632

631633
extra_args = {}
632634
if self.enable_c8_quant:

0 commit comments

Comments
 (0)