"vllm/vscode:/vscode.git/clone" did not exist on "f91808ae0ddf750acfdeb351fa072c91d4d678fc"
neuron.py 1.39 KB
Newer Older
1
from typing import TYPE_CHECKING, Optional
2

3
4
from vllm.logger import init_logger

5
6
from .interface import Platform, PlatformEnum

7
8
9
10
11
if TYPE_CHECKING:
    from vllm.config import VllmConfig
else:
    VllmConfig = None

12
13
logger = init_logger(__name__)

14
15
16

class NeuronPlatform(Platform):
    _enum = PlatformEnum.NEURON
17
    device_name: str = "neuron"
18
    device_type: str = "neuron"
19
    ray_device_key: str = "neuron_cores"
20
    supported_quantization: list[str] = ["neuron_quant"]
21
    device_control_env_var: str = "NEURON_RT_VISIBLE_CORES"
22
23
24
25

    @classmethod
    def get_device_name(cls, device_id: int = 0) -> str:
        return "neuron"
26

27
28
29
30
    @classmethod
    def is_async_output_supported(cls, enforce_eager: Optional[bool]) -> bool:
        return False

31
32
33
34
35
36
    @classmethod
    def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
        parallel_config = vllm_config.parallel_config
        if parallel_config.worker_cls == "auto":
            parallel_config.worker_cls = \
                "vllm.worker.neuron_worker.NeuronWorker"
37

38
39
40
41
42
43
        cache_config = vllm_config.cache_config
        if cache_config:
            # neuron needs block_size = max_model_len
            vllm_config.cache_config.block_size = \
                vllm_config.model_config.max_model_len

44
45
46
47
    @classmethod
    def is_pin_memory_available(cls) -> bool:
        logger.warning("Pin memory is not supported on Neuron.")
        return False