Skip to content

Commit d35e707

Browse files
committed
refactor: simplify sliding window sparse config logic
Streamline the assignment of sparse_mode, pre_tokens, and next_tokens when configuring sliding window attention. Signed-off-by: vv <939082363@qq.com>
1 parent 543ff23 commit d35e707

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

vllm_ascend/attention/attention_v1.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,16 +618,9 @@ def full_graph_fia(
618618
softmax_lse = torch.empty(1, dtype=query.dtype, device=query.device)
619619
input_layout = "TND"
620620
attn_mask = attn_metadata.attn_mask
621-
622-
if self.sliding_window is not None:
623-
sparse_mode = 4
624-
pre_tokens = self.sliding_window
625-
next_tokens = 0
626-
627-
else:
628-
sparse_mode = 3 if attn_metadata.causal else 0
629-
pre_tokens = SWA_INT_MAX
630-
next_tokens = SWA_INT_MAX
621+
sparse_mode = 4 if self.sliding_window else 3 if attn_metadata.causal else 0
622+
pre_tokens = self.sliding_window or SWA_INT_MAX
623+
next_tokens= 0 if self.sliding_window else SWA_INT_MAX
631624

632625
extra_args = {}
633626
if self.enable_c8_quant:

0 commit comments

Comments
 (0)