OpenBMB / MiniCPM-V

MiniCPM-Llama3-V 2.5: A GPT-4V Level Multimodal LLM on Your Phone
Apache License 2.0
7.82k stars 543 forks source link

[BUG] <title>LORA微调后保存的权重没有vpm_resampler_embedtokens.pt #272

Closed 1SingleFeng closed 2 weeks ago

1SingleFeng commented 2 weeks ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

https://github.com/OpenBMB/MiniCPM-V/tree/main/finetune#lora-finetuning 根据这个链接下的信息,按理说lora微调训练后保存的权重应该有vpm_resampler_embedtokens.pt,但是在我的训练结果下并没有发现

期望行为 | Expected Behavior

lora微调训练后保存的权重应该有vpm_resampler_embedtokens.pt

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA (`python -c 'import torch; print(torch.version.cuda)'`):

备注 | Anything else?

No response

1SingleFeng commented 2 weeks ago

我是在zero3配置下训练的结果

1SingleFeng commented 2 weeks ago

我是在zero3配置下训练的结果

在训练脚本里,我也开启了 --tune_vision true

whyiug commented 2 weeks ago

the same issue #243 I don't know why it took so long to fix it.

1SingleFeng commented 2 weeks ago

the same issue #243 I don't know why it took so long to fix it.

你好,最新版的代码貌似解决了这个问题,我还在验证

whyiug commented 2 weeks ago

the same issue #243 I don't know why it took so long to fix it.

你好,最新版的代码貌似解决了这个问题,我还在验证

still not fixed. using zero2. ping @qyc-98

1SingleFeng commented 2 weeks ago

the same issue #243 I don't know why it took so long to fix it.

你好,最新版的代码貌似解决了这个问题,我还在验证

still not fixed. using zero2. ping @qyc-98

你好,我使用了zero3解决了这个问题

LDLINGLINGLING commented 16 hours ago

import torch

文件路径

file_path = '/root/ld/ld_project/pull_request/MiniCPM-V/finetune/output/output_minicpmv2_lora/checkpoint-10/vpm_resampler_embedtokens.pt'

使用torch.load加载文件

checkpoint = torch.load(file_path, map_location=torch.device('cpu')) # 或'mcuda:0'如果你在GPU上运行 print(checkpoint.keys()) Using the above script, you can find that the weight of vpm_resampler_embedtokens.pt obtained by lora fine-tuning includes the weights of llm's embedding, vit and resample.

whyiug commented 12 hours ago

@LDLINGLINGLING If you train with zero2, the vpm_resampler_embedtokens.pt file is saved as 1000B in size, i.e. it's empty!

whyiug commented 12 hours ago

@LDLINGLINGLING Here's why, even if you don't use zero3's lora finetune, you'll still get here. See code , and only keep the lora parameter.