Open meteoryet opened 1 week ago
你要注明是哪个模型,哪个教程,方便我们浮现,另外还要有报错的截图
模型:基于llama2的多模态大模型
微调方式:Lora
问题描述:当前在使用Lora微调RadFM模型时,在运行到trainer.py中的"loss.backward()"这一行时,会出现报错"element 0 of tensors does not require grad and does not have a grad_fn"。当前使用单卡、fsdp多卡并行、deepspeed多卡并行三种方式微调均存在该问题。目前尝试使用了以下尝试但没有解决:在loss.backward()前插入loss.requires_grad(),此时不再报错,但反向传播后grad_fn全为None,并且训练时参数也不再更新。
问题截图:
额,这不是本仓库的教程吧?建议去对应仓库提交issue
在使用Lora微调模型时,在执行Trainer中反向传播函数loss.backward()时会报错"element 0 of tensors does not require grad and does not have a grad_fn",查询相关教程有说在该该句前添加loss.requires_grad(True),这样做后确实不再报错,但参数也不再更新,请问有什么解决方案吗?