openvino.py 1.07 KB
Newer Older
1
2
3
import torch

import vllm.envs as envs
4
from vllm.logger import init_logger
5

6
from .interface import Platform, PlatformEnum, _Backend
7

8
9
logger = init_logger(__name__)

10
11
12

class OpenVinoPlatform(Platform):
    _enum = PlatformEnum.OPENVINO
13
    device_type: str = "openvino"
14

15
16
17
18
19
20
    @classmethod
    def get_default_attn_backend(cls, selected_backend: _Backend) -> _Backend:
        if selected_backend != _Backend.OPENVINO:
            logger.info("Cannot use %s backend on OpenVINO.", selected_backend)
        return _Backend.OPENVINO

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    @classmethod
    def get_device_name(self, device_id: int = 0) -> str:
        return "openvino"

    @classmethod
    def inference_mode(self):
        return torch.inference_mode(mode=True)

    @classmethod
    def is_openvino_cpu(self) -> bool:
        return "CPU" in envs.VLLM_OPENVINO_DEVICE

    @classmethod
    def is_openvino_gpu(self) -> bool:
        return "GPU" in envs.VLLM_OPENVINO_DEVICE

    @classmethod
    def is_pin_memory_available(self) -> bool:
39
        logger.warning("Pin memory is not supported on OpenViNO.")
40
        return False