Skip to content

Commit c1e3571

Browse files
committed
[CI] Fix broken CI
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
1 parent 2b726d8 commit c1e3571

File tree

3 files changed

+109
-8
lines changed

3 files changed

+109
-8
lines changed

vllm_ascend/attention/attention_v1.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from vllm_ascend.ops.attention import vanilla_chunked_prefill
3333
from vllm_ascend.utils import (ACL_FORMAT_FRACTAL_NZ, aligned_16, is_310p,
34-
nd_to_nz_2d, nd_to_nz_spec)
34+
nd_to_nz_2d, nd_to_nz_spec, vllm_version_is)
3535

3636

3737
class AscendAttentionBackend(AttentionBackend):
@@ -43,6 +43,8 @@ def get_name() -> str:
4343

4444
@staticmethod
4545
def get_impl_cls() -> Type["AscendAttentionBackendImpl"]:
46+
if vllm_version_is("0.9.2"):
47+
return AscendAttentionBackendImpl092
4648
return AscendAttentionBackendImpl
4749

4850
@staticmethod
@@ -222,7 +224,6 @@ def __init__(
222224
alibi_slopes: Optional[List[float]],
223225
sliding_window: Optional[int],
224226
kv_cache_dtype: str,
225-
blocksparse_params: Optional[Dict[str, Any]] = None,
226227
logits_soft_cap: Optional[float] = None,
227228
attn_type: str = AttentionType.DECODER,
228229
kv_sharing_target_layer_name: Optional[str] = None,
@@ -437,6 +438,38 @@ def forward(
437438
return output.view(num_tokens, self.hidden_size)
438439

439440

441+
class AscendAttentionBackendImpl092(AscendAttentionBackendImpl):
442+
443+
def __init__(
444+
self,
445+
num_heads: int,
446+
head_size: int,
447+
scale: float,
448+
num_kv_heads: int,
449+
alibi_slopes: Optional[List[float]],
450+
sliding_window: Optional[int],
451+
kv_cache_dtype: str,
452+
blocksparse_params: Optional[Dict[str, Any]] = None,
453+
logits_soft_cap: Optional[float] = None,
454+
attn_type: str = AttentionType.DECODER,
455+
kv_sharing_target_layer_name: Optional[str] = None,
456+
use_irope: bool = False,
457+
) -> None:
458+
super().__init__(
459+
num_heads=num_heads,
460+
head_size=head_size,
461+
scale=scale,
462+
num_kv_heads=num_kv_heads,
463+
alibi_slopes=alibi_slopes,
464+
sliding_window=sliding_window,
465+
kv_cache_dtype=kv_cache_dtype,
466+
logits_soft_cap=logits_soft_cap,
467+
attn_type=attn_type,
468+
kv_sharing_target_layer_name=kv_sharing_target_layer_name,
469+
use_irope=use_irope,
470+
)
471+
472+
440473
def unified_ascend_attention_with_output(
441474
query: torch.Tensor,
442475
key: torch.Tensor,

vllm_ascend/attention/attention_v1_torchair.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from vllm_ascend.attention.attention_v1 import AscendAttentionState
3131
from vllm_ascend.utils import (ACL_FORMAT_FRACTAL_NZ, aligned_16, is_310p,
32-
nd_to_nz_2d)
32+
nd_to_nz_2d, vllm_version_is)
3333

3434

3535
class AscendAttentionTorchairBackend(AttentionBackend):
@@ -41,6 +41,8 @@ def get_name() -> str:
4141

4242
@staticmethod
4343
def get_impl_cls() -> Type["AscendAttentionTorchairBackendImpl"]:
44+
if vllm_version_is("0.9.2"):
45+
return AscendAttentionTorchairBackendImpl092
4446
return AscendAttentionTorchairBackendImpl
4547

4648
@staticmethod
@@ -333,7 +335,6 @@ def __init__(
333335
alibi_slopes: Optional[List[float]],
334336
sliding_window: Optional[int],
335337
kv_cache_dtype: str,
336-
blocksparse_params: Optional[Dict[str, Any]] = None,
337338
logits_soft_cap: Optional[float] = None,
338339
attn_type: str = AttentionType.DECODER,
339340
kv_sharing_target_layer_name: Optional[str] = None,
@@ -501,3 +502,35 @@ def forward(
501502
"to use ascend scheduler.")
502503

503504
return output.view(num_tokens, self.hidden_size)
505+
506+
507+
class AscendAttentionTorchairBackendImpl092(AscendAttentionTorchairBackendImpl):
508+
509+
def __init__(
510+
self,
511+
num_heads: int,
512+
head_size: int,
513+
scale: float,
514+
num_kv_heads: int,
515+
alibi_slopes: Optional[List[float]],
516+
sliding_window: Optional[int],
517+
kv_cache_dtype: str,
518+
blocksparse_params: Optional[Dict[str, Any]] = None,
519+
logits_soft_cap: Optional[float] = None,
520+
attn_type: str = AttentionType.DECODER,
521+
kv_sharing_target_layer_name: Optional[str] = None,
522+
use_irope: bool = False,
523+
) -> None:
524+
super().__init__(
525+
num_heads=num_heads,
526+
head_size=head_size,
527+
scale=scale,
528+
num_kv_heads=num_kv_heads,
529+
alibi_slopes=alibi_slopes,
530+
sliding_window=sliding_window,
531+
kv_cache_dtype=kv_cache_dtype,
532+
logits_soft_cap=logits_soft_cap,
533+
attn_type=attn_type,
534+
kv_sharing_target_layer_name=kv_sharing_target_layer_name,
535+
use_irope=use_irope,
536+
)

vllm_ascend/attention/mla_v1.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from dataclasses import dataclass
2-
from typing import TYPE_CHECKING, Any, Optional, Tuple, Type, TypeVar
2+
from typing import (TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type,
3+
TypeVar)
34

45
import numpy as np
56
import torch
67
import torch_npu
78
from vllm.attention.backends.abstract import (AttentionBackend, AttentionLayer,
8-
AttentionMetadata,
9+
AttentionMetadata, AttentionType,
910
MLAAttentionImpl)
1011
from vllm.attention.backends.utils import PAD_SLOT_ID
1112
from vllm.config import get_current_vllm_config
@@ -20,7 +21,8 @@
2021
from vllm_ascend.multistream.context import get_multistream_comm_context
2122
from vllm_ascend.multistream.ms_split import model_input_split_v1_mla_attn
2223
from vllm_ascend.ops.attention import vanilla_chunked_prefill_mla
23-
from vllm_ascend.utils import npu_prefetch, npu_stream_switch, npu_wait_tensor
24+
from vllm_ascend.utils import (npu_prefetch, npu_stream_switch,
25+
npu_wait_tensor, vllm_version_is)
2426
from vllm_ascend.worker.npu_input_batch import InputBatch
2527

2628
if TYPE_CHECKING:
@@ -66,6 +68,8 @@ def get_kv_cache_shape(num_blocks: int, block_size: int, num_kv_heads: int,
6668

6769
@staticmethod
6870
def get_impl_cls() -> Type["MLAAttentionImpl"]:
71+
if vllm_version_is("0.9.2"):
72+
return AscendMLAImpl092
6973
return AscendMLAImpl
7074

7175

@@ -533,7 +537,6 @@ def __init__(
533537
alibi_slopes: Optional[list[float]],
534538
sliding_window: Optional[int],
535539
kv_cache_dtype: str,
536-
blocksparse_params: Optional[dict[str, Any]],
537540
logits_soft_cap: Optional[float],
538541
attn_type: str,
539542
kv_sharing_target_layer_name: Optional[str] = None,
@@ -1226,3 +1229,35 @@ def forward(
12261229
output[:num_decode_tokens] = output_decode
12271230

12281231
return output_padded
1232+
1233+
1234+
class AscendMLAImpl092(AscendMLAImpl):
1235+
1236+
def __init__(
1237+
self,
1238+
num_heads: int,
1239+
head_size: int,
1240+
scale: float,
1241+
num_kv_heads: int,
1242+
alibi_slopes: Optional[List[float]],
1243+
sliding_window: Optional[int],
1244+
kv_cache_dtype: str,
1245+
blocksparse_params: Optional[Dict[str, Any]] = None,
1246+
logits_soft_cap: Optional[float] = None,
1247+
attn_type: str = AttentionType.DECODER,
1248+
kv_sharing_target_layer_name: Optional[str] = None,
1249+
use_irope: bool = False,
1250+
) -> None:
1251+
super().__init__(
1252+
num_heads=num_heads,
1253+
head_size=head_size,
1254+
scale=scale,
1255+
num_kv_heads=num_kv_heads,
1256+
alibi_slopes=alibi_slopes,
1257+
sliding_window=sliding_window,
1258+
kv_cache_dtype=kv_cache_dtype,
1259+
logits_soft_cap=logits_soft_cap,
1260+
attn_type=attn_type,
1261+
kv_sharing_target_layer_name=kv_sharing_target_layer_name,
1262+
use_irope=use_irope,
1263+
)

0 commit comments

Comments
 (0)