2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

 / 详情

[ST][MS][llama175B] llama2 不支持float32初始化,报错:RuntimeError: For 'load_param_into_net'

DONE
Bug-Report
创建于  
2024-03-18 19:52
name about labels
Bug Report Use this template for reporting a bug kind/bug

Describe the current behavior / 问题描述 (Mandatory / 必填)

llama2 不支持float32初始化,报错
RuntimeError: For 'load_param_into_net', model.layers.0.attention.wq.weight in the argument 'net' should have the same type as model.layers.0.attention.wq.weight in the argument 'parameter_dict'. but got its type Float32 in the argument 'net' and type BFloat16 in the argument 'parameter_dict'.May you need to check whether the checkpoint you loaded is correct.

Environment / 环境信息 (Mandatory / 必填)

  • Hardware Environment(Ascend/GPU/CPU) / 硬件环境:

Please delete the backend not involved / 请删除不涉及的后端:
/device ascend/GPU/CPU/kirin/等其他芯片

  • Software Environment / 软件环境 (Mandatory / 必填):
    -- MindSpore version (e.g., 1.7.0.Bxxx) :
    -- Python version (e.g., Python 3.7.5) :
    -- OS platform and distribution (e.g., Linux Ubuntu 16.04):
    -- GCC/Compiler version (if compiled from source):

  • Excute Mode / 执行模式 (Mandatory / 必填)(PyNative/Graph):

Please delete the mode not involved / 请删除不涉及的模式:
/mode pynative
/mode graph

Related testcase / 关联用例 (Mandatory / 必填)

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

Describe the expected behavior / 预期结果 (Mandatory / 必填)

Related log / screenshot / 日志 / 截图 (Mandatory / 必填)

Special notes for this issue/备注 (Optional / 选填)

评论 (4)

wenli 创建了Bug-Report
wenli 添加了
 
kind/bug
标签
wenli 添加了
 
v2.2.12
标签
wenli 添加了
 
sig/frontend
标签
wenli 添加了
 
attr/function
标签
wenli 添加了
 
stage/func-debug
标签
wenli 添加了
 
user/enterprise
标签
wenli 添加协作者duanjiali
展开全部操作日志

Please assign maintainer to check this issue.
请为此issue分配处理人。
@fangwenyi @chengxiaoli @Shawny

感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:

  1. 如果您刚刚接触MindSpore,或许您可以在教程找到答案
  2. 如果您是资深Pytorch用户,您或许需要:
  1. 如果您遇到动态图问题,可以设置set_context(pynative_synchronize=True)查看报错栈协助定位
  2. 模型精度调优问题可参考官网调优指南
  3. 如果您反馈的是框架BUG,请确认您在ISSUE中提供了MindSpore版本、使用的后端类型(CPU、GPU、Ascend)、环境、训练的代码官方链接以及可以复现报错的代码的启动方式等必要的定位信息
  4. 如果您已经定位出问题根因,欢迎提交PR参与MindSpore开源社区,我们会尽快review

根因

ckpt模糊匹配的时候不支持nf16

解决方案

load ckpt时加上bf16类型转换逻辑

无需添加测试用例
!66627:ckpt_type_convert_add_bf16

i-robot 添加了
 
gitee
标签
changzherui 移除了
 
gitee
标签
changzherui 添加了
 
rca/others
标签
changzherui 添加了
 
rct/bugfix
标签
changzherui 添加了
 
ctl/codereview
标签
changzherui 任务状态TODO 修改为VALIDATION
changzherui 添加协作者changzherui
changzherui 负责人changzherui 修改为wenli
changzherui 负责人wenli 修改为duanjiali
changzherui 取消协作者duanjiali
changzherui 添加协作者wenli

回归时间:2024.3.19
回归版本:MindSpore 2.2.12.B004
回归步骤:llama2网络,bf16训练保存ckpt,fp32的网络加载ckpt训练
回归结果:

2024-03-19 12:35:24,349 - mindformers[mindformers/core/callback/callback.py:259] - WARNING - pipeline stages: 2 > 1, the loss on the last card is valid.
2024-03-19 12:35:24,350 - mindformers[mindformers/core/callback/callback.py:339] - INFO - { Epoch:[  1/  1], step:[   34/  200], loss: 9.903, per_step_time: 15583ms, lr: 4.9373055e-05, overflow cond: True, loss_scale: 1.0, TFLOPs:  1.74, global_norm: [2.3966413]
2024-03-19 12:35:24,351 - mindformers[mindformers/core/callback/callback.py:347] - INFO -   17.0% |████████                                          | 0.13 samples/s/p  0:43:06 }
2024-03-19 12:35:24,413 - mindformers[mindformers/core/callback/callback.py:582] - INFO - ......Saving ckpt......
2024-03-19 12:35:50,803 - mindformers[mindformers/core/callback/callback.py:259] - WARNING - pipeline stages: 2 > 1, the loss on the last card is valid.
2024-03-19 12:35:50,804 - mindformers[mindformers/core/callback/callback.py:339] - INFO - { Epoch:[  1/  1], step:[   36/  200], loss: 9.918, per_step_time: 11873ms, lr: 4.9373055e-05, overflow cond: True, loss_scale: 1.0, TFLOPs:  2.28, global_norm: [2.3488748]
2024-03-19 12:35:50,806 - mindformers[mindformers/core/callback/callback.py:347] - INFO -   18.0% |█████████                                         | 0.17 samples/s/p  0:32:27 }
2024-03-19 12:35:50,806 - mindformers[mindformers/core/callback/callback.py:582] - INFO - ......Saving ckpt......
2024-03-19 12:36:17,182 - mindformers[mindformers/core/callback/callback.py:259] - WARNING - pipeline stages: 2 > 1, the loss on the last card is valid.
2024-03-19 12:36:17,183 - mindformers[mindformers/core/callback/callback.py:339] - INFO - { Epoch:[  1/  1], step:[   38/  200], loss: 9.907, per_step_time: 11904ms, lr: 4.9373055e-05, overflow cond: True, loss_scale: 1.0, TFLOPs:  2.28, global_norm: [2.3897629]
2024-03-19 12:36:17,184 - mindformers[mindformers/core/callback/callback.py:347] - INFO -   19.0% |█████████                                         | 0.17 samples/s/p  0:32:08 }
2024-03-19 12:36:17,185 - mindformers[mindformers/core/callback/callback.py:582] - INFO - ......Saving ckpt......
2024-03-19 12:36:43,389 - mindformers[mindformers/core/callback/callback.py:259] - WARNING - pipeline stages: 2 > 1, the loss on the last card is valid.
2024-03-19 12:36:43,390 - mindformers[mindformers/core/callback/callback.py:339] - INFO - { Epoch:[  1/  1], step:[   40/  200], loss: 9.899, per_step_time: 11989ms, lr: 4.9373055e-05, overflow cond: True, loss_scale: 1.0, TFLOPs:  2.26, global_norm: [2.441086]
2024-03-19 12:36:43,392 - mindformers[mindformers/core/callback/callback.py:347] - INFO -   20.0% |██████████                                        | 0.17 samples/s/p  0:31:58 }
2024-03-19 12:36:43,393 - mindformers[mindformers/core/callback/callback.py:582] - INFO - ......Saving ckpt......
2024-03-19 12:37:09,711 - mindformers[mindformers/core/callback/callback.py:259] - WARNING - pipeline stages: 2 > 1, the loss on the last card is valid.
2024-03-19 12:37:09,712 - mindformers[mindformers/core/callback/callback.py:339] - INFO - { Epoch:[  1/  1], step:[   42/  200], loss: 9.908, per_step_time: 12002ms, lr: 4.9373055e-05, overflow cond: True, loss_scale: 1.0, TFLOPs:  2.26, global_norm: [2.3874996]
2024-03-19 12:37:09,713 - mindformers[mindformers/core/callback/callback.py:347] - INFO -   21.0% |██████████                                        | 0.17 samples/s/p  0:31:36 }
2024-03-19 12:37:09,714 - mindformers[mindformers/core/callback/callback.py:582] - INFO - ......Saving ckpt......
``
回归结论:回归通过
duanjiali 任务状态VALIDATION 修改为DONE
duanjiali 修改了标题
duanjiali 修改了标题

登录 后才可以发表评论

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

搜索帮助