Skip to content

Commit c12b0cf

Browse files
[ci, megatron] test: Add Qwen3 Megatron+Mindspeed Ascend NPU CI (#3465)
### What does this PR do? Add Qwen3 Megatron+Mindspeed Ascend NPU CI ### Checklist Before Starting - [x] Search for similar PRs. Paste at least one query link here: ... - [x] 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. ### Checklist Before Submitting > [!IMPORTANT] > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review. - [x] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md). - [x] 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). - [x] 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 59049a6 commit c12b0cf

File tree

4 files changed

+154
-3
lines changed

4 files changed

+154
-3
lines changed

.github/workflows/e2e_ascend.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# - `special_sanity`: a suite of quick sanity tests
1313
# - `special_standalone`: a set of test that are designed to run in dedicated environments
1414

15-
# Accelerators for tests
15+
# Accelerators for tests
1616
# - By default tests are run with GPU available, except for the ones under `special_npu`, and any test script whose name ends with `on_cpu.py`.
1717
# - For test scripts with `on_cpu.py` name suffix would be tested on CPU resources in linux environment.
1818

@@ -69,7 +69,7 @@ jobs:
6969
if: github.repository_owner == 'volcengine'
7070
name: verl Ascend test (self-host)
7171
runs-on: [self-hosted, npu-0]
72-
timeout-minutes: 45 # Increase this timeout value as needed
72+
timeout-minutes: 60 # Increase this timeout value as needed
7373
container:
7474
image: quay.io/ascend/verl:verl-8.3.rc1-910b-ubuntu22.04-py3.11-latest
7575
volumes:
@@ -90,7 +90,7 @@ jobs:
9090
--network host
9191
--privileged
9292
--shm-size 16g
93-
env:
93+
env:
9494
HTTP_PROXY: ${{ secrets.PROXY_HTTP }}
9595
HTTPS_PROXY: ${{ secrets.PROXY_HTTPS }}
9696
NO_PROXY: "localhost,127.0.0.1,hf-mirror.com"
@@ -142,6 +142,11 @@ jobs:
142142
ray stop --force
143143
bash tests/special_npu/run_qwen2_5_05b_dapo.sh
144144
rm -rf $HOME/ckpts
145+
- name: Running gsm8k e2e qwen3 MoE training tests with DAPO MindSpeed on ASCEND NPU
146+
run: |
147+
ray stop --force
148+
export PYTHONPATH=$PYTHONPATH:/Megatron-LM
149+
USE_DIST_CKPT=True USE_DUMMY_MODEL=True DUMMY_MODEL_CONFIG_PATH=tests/special_e2e/ppo_trainer/expert_parallel/qwen3moe_minimal.json DUMMY_MODEL_PATH=$HOME/dist_ckpt/qwen3_30b_dapo_mindspeed bash tests/special_npu/run_qwen3_30b_dapo_mindspeed.sh
145150
- name: Running gsm8k e2e training tests with GRPO MindSpeed on ASCEND NPU
146151
run: |
147152
ray stop --force

recipe/dapo/run_dapo_qwen3_moe_30b_megatron_npu.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ offload=True
5858

5959
max_num_batched_tokens=$((max_prompt_length + max_response_length))
6060

61+
# vllm
62+
gen_tp=4
63+
6164
# Megatron backen
6265
train_tp=4
6366
train_ep=2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"num_hidden_layers": 2,
3+
"max_window_layers": 2
4+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/usr/bin/env bash
2+
set -xeuo pipefail
3+
4+
export VLLM_ASCEND_ENABLE_NZ=0
5+
6+
MODEL_ID=${MODEL_ID:-Qwen/Qwen3-30B-A3B-Instruct-2507}
7+
MODEL_PATH=${MODEL_PATH:-${HOME}/models/${MODEL_ID}}
8+
USE_DIST_CKPT=${USE_DIST_CKPT:-False}
9+
DIST_CKPT_PATH=${DIST_CKPT_PATH:-${HOME}/dist_ckpt/qwen3_30b_dapo_mindspeed}
10+
11+
# use dummy model
12+
if [[ "$USE_DUMMY_MODEL" == "True" ]]; then
13+
DUMMY_MODEL_PATH=${DUMMY_MODEL_PATH:-${HOME}/models_dummy/${MODEL_ID}}
14+
if [ -z "${DUMMY_MODEL_CONFIG_PATH}" ]; then
15+
echo "[ERROR] DUMMY_MODEL_CONFIG_PATH not set"
16+
exit 1
17+
fi
18+
19+
# make sure the path is empty
20+
if [[ -d $DUMMY_MODEL_PATH && $DUMMY_MODEL_PATH != "/" ]]; then
21+
rm -rf $DUMMY_MODEL_PATH
22+
fi
23+
24+
# init model
25+
python scripts/init_random_model.py \
26+
--hf_model_path "${MODEL_PATH}" \
27+
--new_config_path "${DUMMY_MODEL_CONFIG_PATH}" \
28+
--output_path "${DUMMY_MODEL_PATH}"
29+
30+
# replace model path
31+
MODEL_PATH=$DUMMY_MODEL_PATH
32+
fi
33+
34+
# convert to megatron
35+
if [[ "$USE_DIST_CKPT" == "True" ]]; then
36+
37+
if [[ "$USE_DUMMY_MODEL" == "True" ]]; then
38+
DIST_CKPT_PATH=${HOME}/dist_ckpt/qwen3_30b_dapo_mindspeed_dummy
39+
40+
if [[ -d $DIST_CKPT_PATH && $DIST_CKPT_PATH != "/" ]];then
41+
rm -rf $DIST_CKPT_PATH
42+
fi
43+
fi
44+
45+
torchrun --nproc_per_node 2 --nnodes 1 scripts/converter_hf_to_mcore.py \
46+
--hf_model_path "${MODEL_PATH}" \
47+
--output_path "${DIST_CKPT_PATH}"
48+
fi
49+
50+
exp_name='Qwen3-30B-A3B-DAPO-MindSpeed'
51+
52+
max_prompt_length=512
53+
max_response_length=1024
54+
55+
train_prompt_bsz=16
56+
57+
actor_ppo_max_token_len=$(((max_prompt_length + max_response_length)))
58+
infer_ppo_max_token_len=$(((max_prompt_length + max_response_length)))
59+
60+
python3 -m recipe.dapo.main_dapo \
61+
--config-name="dapo_megatron_trainer" \
62+
data.train_files=${HOME}/data/gsm8k/train.parquet \
63+
data.val_files=${HOME}/data/gsm8k/test.parquet \
64+
data.train_batch_size=${train_prompt_bsz} \
65+
data.max_prompt_length=${max_prompt_length} \
66+
data.max_response_length=${max_response_length} \
67+
data.filter_overlong_prompts=True \
68+
data.shuffle=False \
69+
data.truncation='left' \
70+
data.gen_batch_size=${train_prompt_bsz} \
71+
algorithm.adv_estimator=grpo \
72+
algorithm.use_kl_in_reward=False \
73+
algorithm.filter_groups.enable=False \
74+
algorithm.filter_groups.max_num_gen_batches=10 \
75+
algorithm.filter_groups.metric=acc \
76+
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \
77+
actor_rollout_ref.rollout.enable_chunked_prefill=False \
78+
actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
79+
actor_rollout_ref.rollout.name=vllm \
80+
actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
81+
actor_rollout_ref.rollout.n=8 \
82+
actor_rollout_ref.rollout.temperature=1.0 \
83+
actor_rollout_ref.rollout.top_p=1.0 \
84+
actor_rollout_ref.rollout.top_k=-1 \
85+
actor_rollout_ref.rollout.enforce_eager=True \
86+
actor_rollout_ref.rollout.free_cache_engine=True \
87+
actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len} \
88+
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
89+
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \
90+
actor_rollout_ref.actor.strategy=megatron \
91+
actor_rollout_ref.actor.kl_loss_coef=0.0 \
92+
actor_rollout_ref.actor.clip_ratio_low=0.2 \
93+
actor_rollout_ref.actor.clip_ratio_high=0.28 \
94+
actor_rollout_ref.actor.clip_ratio_c=10.0 \
95+
actor_rollout_ref.actor.ppo_epochs=1 \
96+
actor_rollout_ref.actor.use_dynamic_bsz=True \
97+
actor_rollout_ref.model.path="${MODEL_PATH}" \
98+
actor_rollout_ref.actor.optim.lr=1e-6 \
99+
actor_rollout_ref.actor.ppo_mini_batch_size=16 \
100+
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \
101+
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True \
102+
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True \
103+
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \
104+
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \
105+
actor_rollout_ref.actor.megatron.expert_model_parallel_size=2 \
106+
actor_rollout_ref.actor.megatron.use_dist_checkpointing=${USE_DIST_CKPT} \
107+
actor_rollout_ref.actor.megatron.dist_checkpointing_path=${DIST_CKPT_PATH} \
108+
actor_rollout_ref.actor.use_kl_loss=False \
109+
actor_rollout_ref.actor.loss_agg_mode="token-mean" \
110+
actor_rollout_ref.ref.strategy=megatron \
111+
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \
112+
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \
113+
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \
114+
actor_rollout_ref.ref.megatron.expert_model_parallel_size=2 \
115+
actor_rollout_ref.ref.megatron.use_dist_checkpointing=${USE_DIST_CKPT} \
116+
actor_rollout_ref.ref.megatron.dist_checkpointing_path=${DIST_CKPT_PATH} \
117+
reward_model.reward_manager=dapo \
118+
algorithm.kl_ctrl.kl_coef=0.0 \
119+
trainer.logger=['console'] \
120+
trainer.project_name='verl_gsm8k_example' \
121+
trainer.experiment_name='qwen3_30b_a3b_cut_gsm8k_mindspeed' \
122+
trainer.n_gpus_per_node=16 \
123+
trainer.nnodes=1 \
124+
trainer.save_freq=-1 \
125+
trainer.test_freq=-1 \
126+
trainer.total_epochs=1 \
127+
trainer.total_training_steps=2 \
128+
trainer.device=npu \
129+
actor_rollout_ref.actor.use_torch_compile=False \
130+
actor_rollout_ref.ref.use_torch_compile=False \
131+
+actor_rollout_ref.actor.megatron.override_transformer_config.use_flash_attn=True $@
132+
133+
# clean up
134+
if [[ "$USE_DUMMY_MODEL" == "True" ]]; then
135+
rm -rf $DUMMY_MODEL_PATH
136+
if [[ "$USE_DIST_CKPT" == "True" ]]; then
137+
rm -rf $DIST_CKPT_PATH
138+
fi
139+
fi

0 commit comments

Comments
 (0)