verl icon indicating copy to clipboard operation
verl copied to clipboard

将qwen3-30B-A3B的huggingface模型转化为megatron分布式检查点卡死(不动)。Convert the huggingface model of qwen3-30B-A3B to megatron distributed checkpoint stuck (not moving)

Open dagongge opened this issue 1 year ago • 3 comments

我在运行示例脚本:examples/grpo_trainer/run_qwen3moe-30b_megatron.sh的时候,第一步是

`HF_MODEL_PATH=Qwen/Qwen3-30B-A3B DIST_CKPT_PATH=${DIST_CKPT_PATH}

python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH`

最后的输出日志如下:

[WARNING] Converting GQA model pp_rank=0 global_layer_idx=0 layer_idx=0 numel=934285568 numel this layer=623120640 pp_rank=0 global_layer_idx=1 layer_idx=1 numel=1557406208 numel this layer=623120640 pp_rank=0 global_layer_idx=2 layer_idx=2 numel=2180526848 numel this layer=623120640 pp_rank=0 global_layer_idx=3 layer_idx=3 numel=2803647488 numel this layer=623120640 pp_rank=0 global_layer_idx=4 layer_idx=4 numel=3426768128 numel this layer=623120640 pp_rank=0 global_layer_idx=5 layer_idx=5 numel=4049888768 numel this layer=623120640 pp_rank=0 global_layer_idx=6 layer_idx=6 numel=4673009408 numel this layer=623120640 pp_rank=0 global_layer_idx=7 layer_idx=7 numel=5296130048 numel this layer=623120640 pp_rank=0 global_layer_idx=8 layer_idx=8 numel=5919250688 numel this layer=623120640 pp_rank=0 global_layer_idx=9 layer_idx=9 numel=6542371328 numel this layer=623120640 pp_rank=0 global_layer_idx=10 layer_idx=10 numel=7165491968 numel this layer=623120640 pp_rank=0 global_layer_idx=11 layer_idx=11 numel=7788612608 numel this layer=623120640 pp_rank=0 global_layer_idx=12 layer_idx=12 numel=8411733248 numel this layer=623120640 pp_rank=0 global_layer_idx=13 layer_idx=13 numel=9034853888 numel this layer=623120640 pp_rank=0 global_layer_idx=14 layer_idx=14 numel=9657974528 numel this layer=623120640 pp_rank=0 global_layer_idx=15 layer_idx=15 numel=10281095168 numel this layer=623120640 pp_rank=0 global_layer_idx=16 layer_idx=16 numel=10904215808 numel this layer=623120640 pp_rank=0 global_layer_idx=17 layer_idx=17 numel=11527336448 numel this layer=623120640 pp_rank=0 global_layer_idx=18 layer_idx=18 numel=12150457088 numel this layer=623120640 pp_rank=0 global_layer_idx=19 layer_idx=19 numel=12773577728 numel this layer=623120640 pp_rank=0 global_layer_idx=20 layer_idx=20 numel=13396698368 numel this layer=623120640 pp_rank=0 global_layer_idx=21 layer_idx=21 numel=14019819008 numel this layer=623120640 pp_rank=0 global_layer_idx=22 layer_idx=22 numel=14642939648 numel this layer=623120640 pp_rank=0 global_layer_idx=23 layer_idx=23 numel=15266060288 numel this layer=623120640 pp_rank=0 global_layer_idx=24 layer_idx=24 numel=15889180928 numel this layer=623120640 pp_rank=0 global_layer_idx=25 layer_idx=25 numel=16512301568 numel this layer=623120640 pp_rank=0 global_layer_idx=26 layer_idx=26 numel=17135422208 numel this layer=623120640 pp_rank=0 global_layer_idx=27 layer_idx=27 numel=17758542848 numel this layer=623120640 pp_rank=0 global_layer_idx=28 layer_idx=28 numel=18381663488 numel this layer=623120640 pp_rank=0 global_layer_idx=29 layer_idx=29 numel=19004784128 numel this layer=623120640 pp_rank=0 global_layer_idx=30 layer_idx=30 numel=19627904768 numel this layer=623120640 pp_rank=0 global_layer_idx=31 layer_idx=31 numel=20251025408 numel this layer=623120640 pp_rank=0 global_layer_idx=32 layer_idx=32 numel=20874146048 numel this layer=623120640 pp_rank=0 global_layer_idx=33 layer_idx=33 numel=21497266688 numel this layer=623120640 pp_rank=0 global_layer_idx=34 layer_idx=34 numel=22120387328 numel this layer=623120640 pp_rank=0 global_layer_idx=35 layer_idx=35 numel=22743507968 numel this layer=623120640 pp_rank=0 global_layer_idx=36 layer_idx=36 numel=23366628608 numel this layer=623120640 pp_rank=0 global_layer_idx=37 layer_idx=37 numel=23989749248 numel this layer=623120640 pp_rank=0 global_layer_idx=38 layer_idx=38 numel=24612869888 numel this layer=623120640 pp_rank=0 global_layer_idx=39 layer_idx=39 numel=25235990528 numel this layer=623120640 pp_rank=0 global_layer_idx=40 layer_idx=40 numel=25859111168 numel this layer=623120640 pp_rank=0 global_layer_idx=41 layer_idx=41 numel=26482231808 numel this layer=623120640 pp_rank=0 global_layer_idx=41 layer_idx=41 numel=26482231808 numel this layer=623120640 pp_rank=0 global_layer_idx=42 layer_idx=42 numel=27105352448 numel this layer=623120640 pp_rank=0 global_layer_idx=43 layer_idx=43 numel=27728473088 numel this layer=623120640 pp_rank=0 global_layer_idx=44 layer_idx=44 numel=28351593728 numel this layer=623120640 pp_rank=0 global_layer_idx=45 layer_idx=45 numel=28974714368 numel this layer=623120640 pp_rank=0 global_layer_idx=46 layer_idx=46 numel=29597835008 numel this layer=623120640 pp_rank=0 global_layer_idx=47 layer_idx=47 numel=30220955648 numel this layer=623120640

然后卡死在最后一条,生成路径下只有三个文件:

Image

而且只有GPU0在工作,其余GPU处于空闲状态,但GPU0的使用率也一直为0.

具体我的脚本为: `set -x

HF_MODEL_PATH=/checkpoint-1100 DIST_CKPT_PATH=/Qwen3-30B-A3B-Instruct-2507

python /code/verl/scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH

export CUDA_DEVICE_MAX_CONNECTIONS=1 export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 export HYDRA_FULL_ERROR=1 python3 -m verl.trainer.main_ppo --config-path=config
--config-name='ppo_megatron_trainer.yaml'
algorithm.adv_estimator=grpo
data.train_files=train_dataset.parquet
data.val_files=/test_dataset.parquet
data.train_batch_size=64
data.max_prompt_length=1024
data.max_response_length=2048
data.filter_overlong_prompts=True
data.truncation='error'
actor_rollout_ref.model.path=$HF_MODEL_PATH
actor_rollout_ref.actor.optim.lr=1e-6
actor_rollout_ref.actor.ppo_mini_batch_size=64
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4
actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2
actor_rollout_ref.actor.megatron.tensor_model_parallel_size=4
++actor_rollout_ref.actor.megatron.expert_model_parallel_size=2
++actor_rollout_ref.actor.megatron.use_dist_checkpointing=True
+actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH
actor_rollout_ref.actor.use_kl_loss=True
actor_rollout_ref.actor.kl_loss_coef=0.001
actor_rollout_ref.actor.kl_loss_type=low_var_kl
actor_rollout_ref.actor.entropy_coeff=0
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4
actor_rollout_ref.rollout.tensor_model_parallel_size=4
actor_rollout_ref.rollout.name=vllm
actor_rollout_ref.rollout.gpu_memory_utilization=0.6
actor_rollout_ref.rollout.n=5
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4
actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2
actor_rollout_ref.ref.megatron.tensor_model_parallel_size=4
++actor_rollout_ref.ref.megatron.expert_model_parallel_size=2
++actor_rollout_ref.ref.megatron.use_dist_checkpointing=True
+actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH
++algorithm.use_kl_in_reward=False
trainer.critic_warmup=0
trainer.logger='["console"]'
trainer.project_name='verl_grpo_example_gsm8k_math'
trainer.experiment_name='qwen3_30b_moe_megatron'
trainer.n_gpus_per_node=16
trainer.nnodes=1
trainer.save_freq=20
trainer.test_freq=5
trainer.total_epochs=15 $@`

dagongge avatar Aug 14 '25 04:08 dagongge

You can using mbridge 0.1.13 to avoid checkpoint converting like in this script: https://github.com/volcengine/verl/blob/main/examples/grpo_trainer/run_qwen3-235b_megatron_96gb.sh

techkang avatar Aug 14 '25 11:08 techkang

By the way, should we delete/modify all the checkpoint converting examples? @vermouth1992

techkang avatar Aug 14 '25 11:08 techkang

You can using mbridge 0.1.13 to avoid checkpoint converting like in this script: https://github.com/volcengine/verl/blob/main/examples/grpo_trainer/run_qwen3-235b_megatron_96gb.sh

thanks for your reply. I have solved the problem by referring to the document link:https://verl.readthedocs.io/en/latest/advance/checkpoint.html#convert-fsdp-and-megatron-checkpoints-to-huggingface-format-model. In fact, I just add "--use_cpu_initialization". I wait for some time, then the convert is successful.

dagongge avatar Aug 15 '25 06:08 dagongge