[NPU] replace 30b-npu script with ray-based launch method#323
[NPU] replace 30b-npu script with ray-based launch method#323floatlibai wants to merge 4 commits into
Conversation
Signed-off-by: flb <floatlibai@gmail.com>
Signed-off-by: flb <floatlibai@gmail.com>
Signed-off-by: flb <floatlibai@gmail.com>
Documentation build overview
43 files changed ·
|
There was a problem hiding this comment.
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:-}" |
There was a problem hiding this comment.
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.
| export PYTHONPATH="/root/Megatron-Bridge/src:/root/Megatron-LM/:${PYTHONPATH:-}" | |
| export PYTHONPATH="/root/Megatron-Bridge/src:/root/Megatron-LM/${PYTHONPATH:+:${PYTHONPATH}}" |
| 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" \ |
There was a problem hiding this comment.
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.
| 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>
|
#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 | |||
There was a problem hiding this comment.
Make sense, pg_collection rename matches upstream Megatron API. @Meihan-chen @miracle0517 , please check it.
pg_collectionpatamater mismatch erroralready tested in #269