main
py 32 lines 1021 Bytes
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 import torch
5
6 from vllm.logger import init_logger
7 from vllm.platforms.cpu import CpuPlatform
8
9 logger = init_logger(__name__)
10
11
12 class ZenCpuPlatform(CpuPlatform):
13 """CPU platform with AMD Zen (ZenDNN/zentorch) optimizations.
14
15 Model-load time (dispatch_cpu_unquantized_gemm in layers/utils.py):
16 - Routes linear ops to zentorch_linear_unary.
17 - When VLLM_ZENTORCH_WEIGHT_PREPACK=1 (default), eagerly prepacks
18 weights via zentorch_weight_prepack_for_linear.
19 """
20
21 device_name: str = "cpu"
22 device_type: str = "cpu"
23
24 def is_zen_cpu(self) -> bool:
25 # is_cpu() also returns True for this platform (inherited from CpuPlatform).
26 return True
27
28 # Currently, AMD CPUs do not support float16 compute.
29 # Hence explicitly return bfloat16 and float32.
30 @property
31 def supported_dtypes(self) -> list[torch.dtype]:
32 return [torch.bfloat16, torch.float32]