huggingface / optimum-habana

Easy and lightning fast training of 🤗 Transformers on Habana Gaudi processor (HPU)
Apache License 2.0
144 stars 180 forks source link

[PEFT on Gaudi2C] speed of Full-parameter Finetuning is almost equal to that of LoRA #952

Closed intelyoungway closed 2 months ago

intelyoungway commented 4 months ago

Feature request

  1. [Model] chinese-alpaca-2-7b
  2. [Hardware] Gaudi2C
  3. [Method] LoRA and FineTuning
  4. [Related codes] examples/language_modeling
  5. [Test Cmdlines]:

[tmp_finetune.zip](https://github.com/huggingface/optimum-habana/files/15219872/tmp_finetune.zip)

### Motivation

Customer found that, finetuning of full-parameter is 14 train-samples-per-second, which is similar to that of LoRA (16 train-samples-per-second).
Please see details in feature request and check if there is any possible way to optimize LoRA for better performance.
LeoZhao-Intel commented 4 months ago

can you attach training logs to ease analysis?

intelyoungway commented 4 months ago

Sure, I am asking for customer's feedback.

yafshar commented 3 months ago

@intelyoungway, the attached script is also doing LoRA finetuning. Would you clarify what is the exact issue/request?

intelyoungway commented 3 months ago

customer said they modified the original LoRA script to do finetune (see in the attached files). And the issue is, the speed is too close between LoRA and finetuning (their modified scripts), which is strange cause LoRA should be significantly faster in theory. So the solution is simple: (1) if the attached file is correct finetuning, then please provide a LoRA script optimized so that it could be significantly faster than finetuning. (2) if incorrect, then please feedback that the script that customer modified is not a correct implementation of finetuning, and I will tell customer this message and close the ticket.

yafshar commented 2 months ago

@intelyoungway, Thanks for the comment. From what you said, the goal is to compare the full parameter model fine-tuning with Lora fine-tuning.

As per the original Lora paper from Microsoft, https://arxiv.org/abs/2106.09685, it's theoretically understood that full parameter and Lora fine-tuning should not yield the same performance, mainly when low ranks are used in Lora. The disparity in the number of parameters used for training is a key factor here.

From the attached script, I see you are using the same run_lora_clm.py script with some minor modifications for both full parameters and Lora fine-tuning. If the performance is the same, the script might have an issue. It would help if you used run_clm.py for full parameter fine-tuning and run_lora_clm.py for Lora fine-tuning.

For me or anyone else to be able to help, I need more details, especially log files, number of parameters, etc.

intelyoungway commented 2 months ago

Thanks for the explanation. I think this can fulfill the need. The issue should be closed now.