Open
Description
在使用mindnlp.peft进行prefix tuning的时候报错:
Traceback (most recent call last):
File "E:\git\biogpt\finetune.py", line 144, in <module>
loss = grad_fn(**batch)
File "D:\install\anaconda\envs\biogpt\lib\site-packages\mindnlp\core\autograd\function.py", line 35, in value_and_grad_f
values = fn_(*args, **kwargs)
File "E:\git\biogpt\finetune.py", line 131, in forward_fn
outputs = model(**batch)
File "D:\install\anaconda\envs\biogpt\lib\site-packages\mindnlp\core\nn\modules\module.py", line 391, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\install\anaconda\envs\biogpt\lib\site-packages\mindnlp\core\nn\modules\module.py", line 405, in _call_impl
return forward_call(*args, **kwargs)
File "D:\install\anaconda\envs\biogpt\lib\site-packages\mindnlp\peft\peft_model.py", line 557, in forward
prompts = prompts.to(inputs_embeds.dtype)
AttributeError: 'tuple' object has no attribute 'to'
- 硬件环境
Windows+cpu
- 软件环境:
-- MindSpore version (e.g., 1.7.0.Bxxx) :2.5.0
-- Python version (e.g., Python 3.7.5) :3.10
-- OS platform and distribution (e.g., Linux Ubuntu 16.04):windows
-- GCC/Compiler version (if compiled from source):
原因在于get_prompt函数输出为一个元组,根本上是以下代码导致:
if peft_config.num_transformer_submodules == 2:
past_key_values = ops.cat([past_key_values, past_key_values], dim=2)
past_key_values = past_key_values.permute([2, 0, 3, 1, 4]).split(
peft_config.num_transformer_submodules * 2
)
进行split后输出的为元组,没有to方法导致报错。
修改建议:
增加类型转换即可解决
Screenshots/ 日志 / 截图 (Mandatory / 必填)
If applicable, add screenshots to help explain your problem.
Additional context / 备注 (Optional / 选填)
Add any other context about the problem here.