Skip to content

[NPU] replace 30b-npu script with ray-based launch method#323

Open
floatlibai wants to merge 4 commits into
vllm-project:ascendfrom
floatlibai:ref/scripts
Open

[NPU] replace 30b-npu script with ray-based launch method#323
floatlibai wants to merge 4 commits into
vllm-project:ascendfrom
floatlibai:ref/scripts

Conversation

@floatlibai

@floatlibai floatlibai commented Jul 8, 2026

Copy link
Copy Markdown
  • replace 30b-npu script with ray-based launch method
  • remove redundant gpu scripts
  • update mindspeed patch to fix pg_collection patamater mismatch error

already tested in #269

Signed-off-by: flb <floatlibai@gmail.com>
Signed-off-by: flb <floatlibai@gmail.com>
Signed-off-by: flb <floatlibai@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the mindspeed patch to rename model_comm_pgs to pg_collection and refactors the NPU training script for Qwen3-30B-A3B to clean up previous runs, structure arguments into arrays, and launch training asynchronously via a Ray job. The review feedback suggests safely appending PYTHONPATH to avoid empty path segments and adding a short delay after starting Ray to ensure the dashboard is ready before submitting the job.

export DISABLE_L2_CACHE=1
export VLLM_ASCEND_ENABLE_NZ=0
export VLLM_USE_AOT_COMPILE=0
export PYTHONPATH="/root/Megatron-Bridge/src:/root/Megatron-LM/:${PYTHONPATH:-}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When PYTHONPATH is empty or unset, the trailing colon in "/root/Megatron-Bridge/src:/root/Megatron-LM/:${PYTHONPATH:-}" results in an empty path segment. In Python, an empty segment in PYTHONPATH is interpreted as the current working directory (.), which can lead to unexpected module shadowing or security risks if the script is executed from a directory containing conflicting filenames.

Use the ${PYTHONPATH:+:${PYTHONPATH}} parameter expansion to safely append the existing PYTHONPATH only if it is non-empty.

Suggested change
export PYTHONPATH="/root/Megatron-Bridge/src:/root/Megatron-LM/:${PYTHONPATH:-}"
export PYTHONPATH="/root/Megatron-Bridge/src:/root/Megatron-LM/${PYTHONPATH:+:${PYTHONPATH}}"

Comment on lines +125 to +127
ray start --head --node-ip-address ${MASTER_ADDR} --disable-usage-stats --dashboard-host=0.0.0.0 --dashboard-port=8265

unset http_proxy
unset https_proxy


SCRIPT_DIR="/root/vime/scripts"
source "${SCRIPT_DIR}/models/qwen3-30B-A3B-npu.sh"
MODEL_ROOT="${MODEL_ROOT:-/root}"

python /root/vime/train.py \
--train-backend megatron \
--actor-num-nodes 1 \
--actor-num-gpus-per-node 8 \
--rollout-num-gpus 8 \
--rollout-num-gpus-per-engine 8 \
${MODEL_ARGS[@]} \
\
--hf-checkpoint ${MODEL_ROOT}/models/Qwen3-30B-A3B/ \
\
--prompt-data ${MODEL_ROOT}/datasets/dapo-math-17k/dapo-math-17k.jsonl \
--input-key prompt \
--label-key label \
--apply-chat-template \
--rollout-shuffle \
--rm-type deepscaler \
\
--rollout-backend vllm \
--vllm-weight-sync-mode native \
--vllm-gpu-memory-utilization 0.7 \
--vllm-enable-expert-parallel \
--vllm-enable-sleep-mode \
--vllm-max-model-len $((1024 * 20)) \
\
--num-rollout 300 \
--rollout-batch-size 32 \
--n-samples-per-prompt 8 \
--rollout-max-response-len $((1024 * 8)) \
--rollout-temperature 1.0 \
--global-batch-size 256 \
--balance-data \
\
--advantage-estimator grpo \
--kl-loss-coef 0.0 \
--kl-loss-type low_var_kl \
--entropy-coef 0.0 \
--eps-clip 0.2 \
--eps-clip-high 0.28 \
\
--optimizer adam \
--lr 1e-6 \
--lr-decay-style constant \
--weight-decay 0.1 \
--adam-beta1 0.9 \
--adam-beta2 0.98 \
--optimizer-cpu-offload \
--overlap-cpu-optimizer-d2h-h2d \
--use-precision-aware-optimizer \
\
--tensor-model-parallel-size 4 \
--sequence-parallel \
--pipeline-model-parallel-size 1 \
--context-parallel-size 1 \
--expert-model-parallel-size 8 \
--expert-tensor-parallel-size 1 \
--recompute-granularity full \
--recompute-method uniform \
--recompute-num-layers 1 \
--use-dynamic-batch-size \
--max-tokens-per-gpu 20480 \
--load ${MODEL_ROOT}/models/Qwen3-30B-A3B/ \
--megatron-to-hf-mode bridge \
\
--attention-dropout 0.0 \
--hidden-dropout 0.0 \
--accumulate-allreduce-grads-in-fp32 \
--attention-softmax-in-fp32 \
--attention-backend flash \
--use-flash-attn \
--no-gradient-accumulation-fusion \
\
--train-memory-margin-bytes 2147483648
ray job submit --address="http://127.0.0.1:8265" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ray start runs in the background and returns immediately. If ray job submit is executed immediately afterward, it may fail with a connection error because the Ray Dashboard (listening on port 8265) has not finished initializing.

Adding a short delay (e.g., sleep 5) ensures the dashboard is fully up and ready to accept job submissions.

Suggested change
ray start --head --node-ip-address ${MASTER_ADDR} --disable-usage-stats --dashboard-host=0.0.0.0 --dashboard-port=8265
unset http_proxy
unset https_proxy
SCRIPT_DIR="/root/vime/scripts"
source "${SCRIPT_DIR}/models/qwen3-30B-A3B-npu.sh"
MODEL_ROOT="${MODEL_ROOT:-/root}"
python /root/vime/train.py \
--train-backend megatron \
--actor-num-nodes 1 \
--actor-num-gpus-per-node 8 \
--rollout-num-gpus 8 \
--rollout-num-gpus-per-engine 8 \
${MODEL_ARGS[@]} \
\
--hf-checkpoint ${MODEL_ROOT}/models/Qwen3-30B-A3B/ \
\
--prompt-data ${MODEL_ROOT}/datasets/dapo-math-17k/dapo-math-17k.jsonl \
--input-key prompt \
--label-key label \
--apply-chat-template \
--rollout-shuffle \
--rm-type deepscaler \
\
--rollout-backend vllm \
--vllm-weight-sync-mode native \
--vllm-gpu-memory-utilization 0.7 \
--vllm-enable-expert-parallel \
--vllm-enable-sleep-mode \
--vllm-max-model-len $((1024 * 20)) \
\
--num-rollout 300 \
--rollout-batch-size 32 \
--n-samples-per-prompt 8 \
--rollout-max-response-len $((1024 * 8)) \
--rollout-temperature 1.0 \
--global-batch-size 256 \
--balance-data \
\
--advantage-estimator grpo \
--kl-loss-coef 0.0 \
--kl-loss-type low_var_kl \
--entropy-coef 0.0 \
--eps-clip 0.2 \
--eps-clip-high 0.28 \
\
--optimizer adam \
--lr 1e-6 \
--lr-decay-style constant \
--weight-decay 0.1 \
--adam-beta1 0.9 \
--adam-beta2 0.98 \
--optimizer-cpu-offload \
--overlap-cpu-optimizer-d2h-h2d \
--use-precision-aware-optimizer \
\
--tensor-model-parallel-size 4 \
--sequence-parallel \
--pipeline-model-parallel-size 1 \
--context-parallel-size 1 \
--expert-model-parallel-size 8 \
--expert-tensor-parallel-size 1 \
--recompute-granularity full \
--recompute-method uniform \
--recompute-num-layers 1 \
--use-dynamic-batch-size \
--max-tokens-per-gpu 20480 \
--load ${MODEL_ROOT}/models/Qwen3-30B-A3B/ \
--megatron-to-hf-mode bridge \
\
--attention-dropout 0.0 \
--hidden-dropout 0.0 \
--accumulate-allreduce-grads-in-fp32 \
--attention-softmax-in-fp32 \
--attention-backend flash \
--use-flash-attn \
--no-gradient-accumulation-fusion \
\
--train-memory-margin-bytes 2147483648
ray job submit --address="http://127.0.0.1:8265" \
ray start --head --node-ip-address ${MASTER_ADDR} --disable-usage-stats --dashboard-host=0.0.0.0 --dashboard-port=8265
# Wait for Ray dashboard to be ready
sleep 5
ray job submit --address="http://127.0.0.1:8265" \

Signed-off-by: flb <floatlibai@gmail.com>
@floatlibai floatlibai changed the title [NPU] replace 30b-npu script with ray method [NPU] replace 30b-npu script with ray-based launch method Jul 8, 2026
@CalvinXKY

CalvinXKY commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

#269 tested direct python train.py, not this Ray-based flow. Please add a short repro note.

@@ -1,3 +1,19 @@
diff --git a/mindspeed/core/fusions/fused_moe_permute.py b/mindspeed/core/fusions/fused_moe_permute.py
index bb007b44..98708a5b 100644

@CalvinXKY CalvinXKY Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, pg_collection rename matches upstream Megatron API. @Meihan-chen @miracle0517 , please check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants