Skip to content

Commit 392791b

Browse files
authored
[hardware] feat: Auto set device_name to npu for Ascend NPU (verl-project#4489)
### What does this PR do? > Add **concise** overview of what this PR aims to achieve or accomplish. Reference related GitHub issues and PRs that help with the review. For Ascend NPU, **maintaining consistency between the currently developed test cases and the GPU test cases in the verl community is crucial for ongoing maintenance.** However, the scripts for NPU and GPU differ in their handling of the trainer.device parameter. **Heavy reliance on this parameter forces the NPU side to separately archive corresponding test scripts, making it impossible to directly reuse existing GPU scripts or future additions.** To address this, this PR plans to **automatically set device_name to `npu` on Ascend NPU devices.** Following entrances are equiped with this mechenism: - verl.trainer.main_ppo - verl.trainer.fsdp_sft_trainer - recipe.dapo.main_dapo - recipe.transfer_queue.main_ppo - recipe.one_step_off_policy.main_ppo - recipe.r1_ascend.main_ppo ### Checklist Before Starting - [ ] Search for similar PRs. Paste at least one query link here: ... - [ ] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI) - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data` - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]` - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test` - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title. - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching` ### Test > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc. Not related. ### API and Usage Example > Demonstrate how the API changes if any, and provide usage example(s) if possible. Not related. ### Design & Code Changes > Demonstrate the high-level design if this PR is complex, and list the specific changes. Not related. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always` - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ... - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
1 parent 7deb67c commit 392791b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+72
-60
lines changed

docs/ascend_tutorial/ascend_quick_start.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
Ascend Quickstart
22
===================================
33

4-
Last updated: 12/4/2025.
4+
Last updated: 12/11/2025.
55

66
我们在 verl 上增加对华为昇腾设备的支持。
77

8+
9+
关键更新
10+
----------------------------------
11+
12+
2025/12/11:verl 存量场景目前支持自动识别 NPU 设备类型, GPU 脚本在昇腾上运行,原则上不再需要显式设置 trainer.device=npu 参数,新增特性通过设置 trainer.device 仍可优先使用,逐步适配自动识别能力。
13+
14+
815
硬件支持
916
-----------------------------------
1017

@@ -213,8 +220,7 @@ verl 中昇腾暂不支持生态库如下:
213220
trainer.nnodes=1 \
214221
trainer.save_freq=-1 \
215222
trainer.test_freq=5 \
216-
trainer.total_epochs=1 \
217-
trainer.device=npu $@
223+
trainer.total_epochs=1 $@
218224
219225
220226
算法支持现状

examples/grpo_trainer/run_qwen2_5_32b_grpo_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ python3 -m verl.trainer.main_ppo \
3737
trainer.nnodes=2 \
3838
trainer.save_freq=-1 \
3939
trainer.test_freq=10 \
40-
trainer.total_epochs=15 \
41-
trainer.device=npu $@
40+
trainer.total_epochs=15 $@

examples/grpo_trainer/run_qwen2_5_7b_grpo_discrete_prof_npu.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ python3 -m verl.trainer.main_ppo \
6565
trainer.save_freq=-1 \
6666
trainer.test_freq=5 \
6767
trainer.total_epochs=5 \
68-
trainer.device=npu \
6968
global_profiler.tool=npu \
7069
global_profiler.steps=$PROFILE_STEPS \
7170
global_profiler.save_path=$SAVE_PATH

examples/grpo_trainer/run_qwen2_5_7b_grpo_e2e_prof_npu.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ python3 -m verl.trainer.main_ppo \
6262
trainer.save_freq=-1 \
6363
trainer.test_freq=5 \
6464
trainer.total_epochs=5 \
65-
trainer.device=npu \
6665
global_profiler.tool=npu \
6766
global_profiler.steps=$PROFILE_STEPS \
6867
global_profiler.save_path=$SAVE_PATH

examples/grpo_trainer/run_qwen2_5_7b_grpo_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ python3 -m verl.trainer.main_ppo \
3838
trainer.nnodes=1 \
3939
trainer.save_freq=-1 \
4040
trainer.test_freq=5 \
41-
trainer.total_epochs=5 \
42-
trainer.device=npu $@
41+
trainer.total_epochs=5 $@

examples/grpo_trainer/run_qwen2_5_vl_32b_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ python3 -m verl.trainer.main_ppo \
4848
trainer.nnodes=2 \
4949
trainer.save_freq=-1 \
5050
trainer.test_freq=-1 \
51-
trainer.total_epochs=15 \
52-
trainer.device=npu $@
51+
trainer.total_epochs=15 $@

examples/grpo_trainer/run_qwen2_5_vl_3b_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ python3 -m verl.trainer.main_ppo \
4848
trainer.nnodes=1 \
4949
trainer.save_freq=-1 \
5050
trainer.test_freq=-1 \
51-
trainer.total_epochs=15 \
52-
trainer.device=npu $@
51+
trainer.total_epochs=15 $@

examples/grpo_trainer/run_qwen2_5_vl_7b_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,4 @@ python3 -m verl.trainer.main_ppo \
4848
trainer.nnodes=1 \
4949
trainer.save_freq=-1 \
5050
trainer.test_freq=-1 \
51-
trainer.total_epochs=15 \
52-
trainer.device=npu $@
51+
trainer.total_epochs=15 $@

examples/grpo_trainer/run_qwen3-32b_npu.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,4 @@ python3 -m verl.trainer.main_ppo \
5555
trainer.resume_from_path=checkpoints/ \
5656
trainer.save_freq=500 \
5757
trainer.test_freq=50 \
58-
trainer.total_epochs=50 \
59-
trainer.device=npu $@
58+
trainer.total_epochs=50 $@

examples/grpo_trainer/run_qwen3-8b_npu.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ python3 -m verl.trainer.main_ppo \
4747
trainer.n_gpus_per_node=8 \
4848
trainer.nnodes=1 \
4949
trainer.default_local_dir=${CKPTS_DIR} \
50-
trainer.device=npu \
5150
trainer.resume_mode=auto \
5251
actor_rollout_ref.actor.fsdp_config.forward_prefetch=True \
5352
actor_rollout_ref.ref.fsdp_config.forward_prefetch=True \

0 commit comments

Comments
 (0)