Ascend Infra
Ascend集群上的基本配置,和华子斗智斗勇(其一)。
环境配置
创建环境:
1 | # conda环境(实测3.11也可以,但是verl依赖3.10) |
CANN
按照vllm依赖安装CANN(来源vllm-ascend文档):
1 | # Install required python packages. |
两个source可以添加到~/.bashrc
中,进入终端自动加载环境。
vLLM
安装vllm和vllm-ascend:
1 | # 安装编译依赖 |
安装vllm-ascend
会使torch版本为2.7.1+cpu
,但是会正常使用npu运行。
如果编译有报错类似
Command '['cmake', '--build', '.', '-j=192', '--target=_C']' returned non-zero exit status 1
,是因为默认用所有的核编译导致崩溃,限制MAX_JOBS=32
或更少即可。
附vllm的依赖:
Software | Supported version | Note |
---|---|---|
CANN | >= 8.2.RC1 | Required for vllm-ascend and torch-npu |
torch-npu | >= 2.7.1.dev20250724 | Required for vllm-ascend, No need to install manually, it will be auto installed in below steps |
torch | >= 2.7.1 | Required for torch-npu and vllm |
verl
在已有vllm
和vllm-ascend
的情况下:
1 | git clone https://github.com/volcengine/verl.git |
附verl的依赖,只能尽可能取最大交集,CANN和torch版本能向下兼容。
software | version |
---|---|
Python | == 3.10 |
CANN | == 8.1.RC1 |
torch | == 2.5.1 |
torch_npu | == 2.5.1.RC1 |
最小化测试
安装verl后可以进行GRPO训练的测试:
1 | # 下载数据集 |
疑难杂症
在通过Python API使用vllm时(常见于自定义模型的推理或verl等使用vllm的其他库),在某个
from vllm import xxx
上产生报错:1
ValueError: infer_schema(func): Parameter block_size has unsupported type list[int]. The valid types are: dict_keys([<class 'torch.Tensor'>, typing.Optional[torch.Tensor], typing.Sequence[torch.Tensor], typing.List[torch.Tensor], typing.Sequence[typing.Optional[torch.Tensor]], typing.List[typing.Optional[torch.Tensor]], <class 'int'>, typing.Optional[int], typing.Sequence[int], typing.List[int], typing.Optional[typing.Sequence[int]], typing.Optional[typing.List[int]], <class 'float'>, typing.Optional[float], typing.Sequence[float], typing.List[float], typing.Optional[typing.Sequence[float]], typing.Optional[typing.List[float]], <class 'bool'>, typing.Optional[bool], typing.Sequence[bool], typing.List[bool], typing.Optional[typing.Sequence[bool]], typing.Optional[typing.List[bool]], <class 'str'>, typing.Optional[str], typing.Union[int, float, bool], typing.Union[int, float, bool, NoneType], typing.Sequence[typing.Union[int, float, bool]], typing.List[typing.Union[int, float, bool]], <class 'torch.dtype'>, typing.Optional[torch.dtype], <class 'torch.device'>, typing.Optional[torch.device]]). Got func with signature (input: torch.Tensor, weight: torch.Tensor, block_size: list[int], weight_scale: torch.Tensor, input_scale: Optional[torch.Tensor] = None, bias: Optional[torch.Tensor] = None, cutlass_block_fp8_supported: bool = False, use_aiter_and_is_supported: bool = False) -> torch.Tensor)
原因是
list[int]
应为List[Int]
,这一兼容本来应当被vllm_ascend
自动完成。可参考issues#2564在报错行(或者所有vllm相关的import前面)添加:1
2from vllm_ascend.patch import platform
from vllm_ascend.patch import worker手动patch后没有问题。
import vllm相关库时报错:
ValueError: 'aimv2' is already used by a Transformers config, pick another name
这个是
vllm
的bug,参考这个issue和新的commit vllm-project/vllm@3fc9644修改vllm/transformers_utils/configs/ovis.py
即可。
Ascend Infra