ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

训练minimax 2.5,保存ckpt时,不正常结束,一直卡住。

Open fj1024 opened this issue 7 months ago • 8 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。

Question Description / 问题描述

训练minimax 2.5,保存ckpt时,不正常结束,一直卡住。

Image 训练脚本: megatron sft \ --model /mnt/public/checkpoints/MiniMax/MiniMax-M2___5 \ --save_safetensors true \ --merge_lora true \ --dataset "${DATASETS[@]}" \ --load_from_cache_file true \ --add_non_thinking_prefix true \ --split_dataset_ratio 0 \ --tuner_type lora \ --lora_rank "${rank}" \ --lora_alpha $((rank * 2)) \ --target_modules all-linear \ --tensor_model_parallel_size 4 \ --pipeline_model_parallel_size 1 \ --expert_tensor_parallel_size 1 \ --expert_model_parallel_size 4 \ --context_parallel_size 1 \ --sequence_parallel true \ --moe_permute_fusion true \ --moe_grouped_gemm true \ --moe_shared_expert_overlap true \ --moe_aux_loss_coeff 1e-3 \ --moe_z_loss_coeff 5e-4 \ --micro_batch_size 4 \ --global_batch_size 8 \ --recompute_granularity full \ --recompute_method uniform \ --recompute_num_layers 1 \ --num_train_epochs 2 \ --finetune true \ --cross_entropy_loss_fusion true \ --lr "${lr}" \ --lr_warmup_fraction 0.05 \ --min_lr 1e-6 \ --output_dir "${OUTPUT_DIR}" \ --max_length 8192 \ --dataloader_num_workers 1 \ --no_save_optim true \ --no_save_rng true \ --dataset_num_proc 8 \ --attention_backend flash \ --use_precision_aware_optimizer true \ --main_grads_dtype bf16 \ --overlap_grad_reduce true \ --overlap_param_gather true \ --loss_scale ignore_empty_think \

fj1024 avatar Apr 13 '26 01:04 fj1024

应该已经保存完了

权重完整嘛

Jintao-Huang avatar Apr 13 '26 07:04 Jintao-Huang

应该已经保存完了

权重完整嘛 权重完整,但是config文件都没有。我手动kill,把基模的confit复制过去,vllm可以正常起服务,但是推理出来的内容全是乱码。

fj1024 avatar Apr 13 '26 07:04 fj1024

显卡是这种状态。

Image

应该已经保存完了

权重完整嘛

fj1024 avatar Apr 13 '26 07:04 fj1024

请问有解决办法吗?@fj1024 @Jintao-Huang

cwszz avatar Apr 21 '26 09:04 cwszz

请问有解决办法吗?@fj1024 @Jintao-Huang

我debug到是陷入了死锁的状态,一个只能rank0进入的代码块又去调用了分布式 DDP 或多进程场景下方法safe_ddp_context,一直处于等待的状态。ms-swift/swift/megatron/init.py这部分代码 with torch.device('meta'): self.hf_model = get_model_processor( args.model_dir, model_type=args.model_type, return_dummy_model=True)[0] 修改成from swift.utils.torch_utils import disable_safe_ddp_context_use_barrier with disable_safe_ddp_context_use_barrier(): with torch.device('meta'): self.hf_model = get_model_processor( args.model_dir, model_type=args.model_type, return_dummy_model=True)[0]

fj1024 avatar Apr 21 '26 09:04 fj1024

我看看 我知道问题了

Jintao-Huang avatar Apr 21 '26 09:04 Jintao-Huang

https://github.com/modelscope/mcore-bridge/pull/47

Jintao-Huang avatar Apr 21 '26 11:04 Jintao-Huang

https://github.com/modelscope/ms-swift/pull/9171

Jintao-Huang avatar Apr 21 '26 11:04 Jintao-Huang