Modules_to_save vs unload() in peft

Recently, I need to use the peft library for LoRA fine-tuning, and at the same time, I want to fine-tune certain layers of my base model directly such as lm_head.
I would like to save the parameters of my fine-tuned base_model. While using modules_to_save=["lm_head"] in LoraConfig is a convenient approach, it results in high GPU memory usage. Alternatively, explicitly setting requires_grad=True for lm_head and saving it after training using unload()and model.save_pretrained ("xxx")leads to lower memory consumption. What are the differences between these two approaches in terms of saving the model?

1 Like

In theory, there doesn’t seem to be much difference in the results, but the behavior may differ significantly in practice.
I think save_pretrained() is most likely to be well maintained.