108 Star 363 Fork 420

MindSpore / mindformers

 / 详情

全参微调qwen-7b时,会报优化器与模型并行分片不相等错误

DONE
Question
创建于  
2024-03-28 19:12

全参微调qwen-7b时,设置dp1 tp4 pp2,请问该如何解决
报错如下:
ValueError: The optimizer sharding step 1 is not equal to the model parallel sharding size 4.
mindspore:2.2.11
mindformers:v1.0.1

评论 (2)

hsy495675954 创建了Question

修改 qwen_model.py 中 lm_head 的切分策略即可解决此问题

@@ -189,7 +196,7 @@ class QwenForCausalLM(QwenPreTrainedModel):
         if parallel_config.vocab_emb_dp:
             self.lm_head.shard(strategy_matmul=((dp, 1), (1, 1)))
         else:
-            self.lm_head.shard(strategy_matmul=((1, 1), (dp * mp, 1)))
+            self.lm_head.shard(strategy_matmul=((dp, 1), (mp, 1)))

不过根据目前的测试效果,单机8卡上面dp1 mp4 pp2还要开重计算才能拉起全参微调任务,而且训练速度大概只有dp8的一半

zyw_hw 任务状态TODO 修改为DONE

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
Python
1
https://gitee.com/mindspore/mindformers.git
git@gitee.com:mindspore/mindformers.git
mindspore
mindformers
mindformers

搜索帮助