|
| 1 | +# ROLL x Ascend |
| 2 | + |
| 3 | +Last updated: 08/15/2025. |
| 4 | + |
| 5 | +我们在 ROLL 上增加对华为昇腾设备的支持。 |
| 6 | + |
| 7 | +## 硬件支持 |
| 8 | + |
| 9 | +Atlas 200T A2 Box16 |
| 10 | + |
| 11 | +Atlas 900 A2 PODc |
| 12 | + |
| 13 | + |
| 14 | +## 安装 |
| 15 | + |
| 16 | + |
| 17 | +### 基础环境准备 |
| 18 | + |
| 19 | +| software | version | |
| 20 | +|-----------|-------------| |
| 21 | +| Python | 3.10 | |
| 22 | +| CANN | 8.1.RC1 | |
| 23 | + |
| 24 | +### 创建 conda 环境 |
| 25 | + |
| 26 | + |
| 27 | +使用以下命令在 Miniconda 中创建新的 conda 环境: |
| 28 | + |
| 29 | +``` |
| 30 | +conda create --name roll python=3.10 |
| 31 | +conda activate roll |
| 32 | +``` |
| 33 | + |
| 34 | +### 安装 torch & torch_npu: |
| 35 | + |
| 36 | + |
| 37 | +为了能在 ROLL 中正常使用 torch 和 torch_npu,需使用以下命令安装 torch 和 torch_npu。请注意根据机器类型区分安装方式。 |
| 38 | + |
| 39 | +``` |
| 40 | +# 安装 torch 的 CPU 版本 |
| 41 | +pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu |
| 42 | +
|
| 43 | +# 安装 torch_npu |
| 44 | +pip install torch_npu==2.5.1 |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | +### 安装vllm & vllm-ascend: |
| 49 | + |
| 50 | +为了能够在 ROLL 中正常使用 vllm,需使用以下命令编译安装 vllm 和 vllm-ascend。请注意根据机器类型区分安装方式。 |
| 51 | + |
| 52 | +``` |
| 53 | +# vllm |
| 54 | +git clone -b v0.8.4 --depth 1 https://github.com/vllm-project/vllm.git |
| 55 | +cd vllm |
| 56 | +
|
| 57 | +VLLM_TARGET_DEVICE=empty pip install -v -e . |
| 58 | +cd .. |
| 59 | +``` |
| 60 | + |
| 61 | +``` |
| 62 | +# vllm-ascend |
| 63 | +git clone -b v0.8.4rc2 --depth 1 https://github.com/vllm-project/vllm-ascend.git |
| 64 | +cd vllm-ascend |
| 65 | +
|
| 66 | +export COMPILE_CUSTOM_KERNELS=1 |
| 67 | +pip install -e . |
| 68 | +cd .. |
| 69 | +``` |
| 70 | + |
| 71 | +如果在安装 vllm-ascend 时遇到类似以下问题: |
| 72 | + |
| 73 | +``` |
| 74 | +RuntimeError: CMake configuration failed: Command '['/pathto/miniconda3/envs/roll/bin/python3.10', '-m', 'pybind11', '--cmake']' returned non-zero exit status 2. |
| 75 | +``` |
| 76 | + |
| 77 | +可尝试在 vllm-ascend 目录下 setup.py 文件 151-158 行进行如下修改并重新进行编译: |
| 78 | + |
| 79 | +``` |
| 80 | +try: |
| 81 | + # if pybind11 is installed via pip |
| 82 | + pybind11_cmake_path = (subprocess.check_output( |
| 83 | + [python_executable, "-m", "pybind11", |
| 84 | + "--cmakedir"]).decode().strip()) |
| 85 | +except subprocess.CalledProcessError as e: |
| 86 | + # else specify pybind11 path installed from source code on CI container |
| 87 | + raise RuntimeError(f"CMake configuration failed: {e}") |
| 88 | +``` |
| 89 | + |
| 90 | +### 安装 ROLL |
| 91 | + |
| 92 | +``` |
| 93 | +git clone https://github.com/alibaba/ROLL.git |
| 94 | +cd ROLL |
| 95 | +pip install -r requirements_common.txt |
| 96 | +pip install deepspeed==0.16.0 |
| 97 | +cd .. |
| 98 | +``` |
| 99 | + |
| 100 | +### 其他三方库说明 |
| 101 | + |
| 102 | +| software | description | |
| 103 | +|-------------------------------|---------------| |
| 104 | +| transformers | v4.52.4 | |
| 105 | +| flash_attn | not supported | |
| 106 | +| tensordict | 0.8.3 (ARM) | |
| 107 | +| transformer-engine[pytorch] | not supported | |
| 108 | + |
| 109 | +1. 支持通过 transformers 使能 --flash_attention_2, transformers 需大于等于 4.52.0版本。 |
| 110 | +2. 不支持通过 flash_attn 使能 flash attention 加速。 |
| 111 | +3. 针对 ARM 服务器,tensordict 要求 0.8.3,可在依赖安装完成后再手动安装 tensordict。 |
| 112 | +4. 暂不支持 transformer-engine[pytorch] |
| 113 | + |
| 114 | +``` |
| 115 | +pip install transformers==4.52.4 |
| 116 | +pip install tensordict==0.8.3 |
| 117 | +``` |
| 118 | + |
| 119 | +## 快速开始,单节点部署指引 |
| 120 | + |
| 121 | +正式使用前,建议您通过对单节点流水线的训练尝试以检验环境准备和安装的正确性。 |
| 122 | +由于目前暂不支持 Megatron-LM 训练,请首先将对应文件中 |
| 123 | +strategy_args 参数修改为 deepspeed 选项。 |
| 124 | + |
| 125 | +1. 使用 shell 执行单节点流水线 |
| 126 | + |
| 127 | +``` |
| 128 | +bash examples/agentic_demo/run_agentic_pipeline_frozen_lake_single_node_demo.sh |
| 129 | +``` |
| 130 | + |
| 131 | +2. 使用配置文件执行 agentic pipeline |
| 132 | + |
| 133 | +``` |
| 134 | +# 确保当前位于ROLL项目目录的根目录下 |
| 135 | +# export PYTHONPATH=$(pwd):$PYTHONPATH |
| 136 | +
|
| 137 | +python examples/start_agentic_pipeline.py \ |
| 138 | + --config_path qwen2.5-0.5B-agentic \ |
| 139 | + --config_name agentic_val_sokoban |
| 140 | +
|
| 141 | +- ``--config_path`` – 包含您的YAML配置文件的目录。 |
| 142 | +- ``--config_name`` – 文件名(不含.yaml后缀)。 |
| 143 | +``` |
| 144 | + |
| 145 | +## 支持现状 |
| 146 | + |
| 147 | + |
| 148 | +**表1** NPU 已通过流水线验证 |
| 149 | + |
| 150 | +| pipeline | hardware | |
| 151 | +|---------------------------------------------------------------|---------------------| |
| 152 | +| examples/qwen2.5-0.5B-agentic/run_agentic_pipeline_sokoban.sh | Atlas 900 A2 PODc | |
| 153 | +| examples/qwen2.5-0.5B-agentic/run_agentic_rollout_sokoban.sh | Atlas 900 A2 PODc | |
| 154 | +| examples/qwen2.5-1.5B-distill_ds/run_distill_pipeline.sh | Atlas 900 A2 PODc | |
| 155 | +| examples/qwen2.5-3B-dpo_megatron/run_dpo_pipeline.sh | Atlas 900 A2 PODc | |
| 156 | +| examples/qwen2.5-7B-rlvr_megatron/run_rlvr_pipeline.sh | Atlas 900 A2 PODc | |
| 157 | + |
| 158 | +**表2** NPU 待流水线验证 |
| 159 | + |
| 160 | +| pipeline | hardware | |
| 161 | +|---------------------------------------------------------------|---------------------| |
| 162 | +| examples/qwen2.5-vl-7B-distill/run_distill_vl_ds_pipeline.sh | Atlas 900 A2 PODc | |
| 163 | +| examples/qwen2.5-vl-7B-rlvr/run_rlvr_pipeline.sh | Atlas 900 A2 PODc | |
| 164 | + |
| 165 | +## 后续计划 |
| 166 | + |
| 167 | + |
| 168 | +分别按照以下规则进行与 GPU 的精度与吞吐量的对比 |
| 169 | +精度对比: |
| 170 | +根据经验,对于 Agentic 和 RLVR 等 RL 类算法,我们期望在相同配置下华为昇腾设备与 A100 的 rewards 平均绝对误差 <= 4%,计算方式参考下公式。 |
| 171 | +``` |
| 172 | +$ Mean Error = \frac{\sum_{i=1}^{N} |reward_i^{npu} - reward_{i}^{gpu}|}{N} \leq 0.04 $ |
| 173 | +``` |
| 174 | +对于 DPO 和 Distill 等类算法,我们期望在相同配置下华为昇腾设备与 A100 的 loss 相对误差 <= 4%,计算方式参考下公式。 |
| 175 | +``` |
| 176 | +$ Mean Error = \frac{\sum_{i=1}^{N} |loss_i^{npu} - loss_{i}^{gpu}|}{N} \leq 0.04 $ |
| 177 | +``` |
| 178 | + |
| 179 | +吞吐对比:Ascend npu 和 A100 分别取日志中前4个 step 的 throughput 的 tpu 值 做平均, tpu ratio = npu 平均值 / A100 平均值。 |
| 180 | + |
| 181 | + |
| 182 | +## 声明 |
| 183 | +----------------------------------- |
| 184 | +ROLL 中提供的 Ascend 支持代码皆为参考样例,商业使用请通过官方正式途径沟通,谢谢。 |
0 commit comments