Open iakoster opened 7 months ago
Hey, can you try upgrade/downgrade peft?
@NanoCode012 Yes, I downgraded the peft
version to 0.9.0
, but then it raises TypeError: LoraConfig.__init__() got an unexpected keyword argument 'layer_replication'
, I didn't try further. I also consistently downgraded transformers
to 0.37.0
and it didn't help.
Ah yes, I believe that was another bug in peft. Can you go lower or higher?
Are you on the same version as in requirements?
Ah yes, I believe that was another bug in peft. Can you go lower or higher?
I have the same error on peft
version up to 0.7.0
. On version 0.6.2
I have the error ImportError: cannot import name 'LoftQConfig' from 'peft' (/home/jupyter/.local/lib/python3.10/site-packages/peft/__init__.py)
. I can't go higher than that as I used the latest version.
Are you on the same version as in requirements?
Yes, at the time of model training and the first merge everything was in compliance with the requirements.
I can't go higher than that as I used the latest version.
My mistake. Now I tested it with peft
from github repo - same error.
Have you been able to merge before this? Any change since?
@NanoCode012 No. This is my first experience using the library.
I think I see a key difference: your "base_model" is an adapter, not full model. I don't know if we have a test for this.
However, when I checked the code, this should've not been a problem.
@NanoCode012 I also saw the following warning [peft.tuners.tuners_utils.__init__:154] [PID:10053] Already found a 'peft_config' attribute in the model. This will lead to having multiple adapters in the model. Make sure to know what you are doing!
in the logs. Maybe this will help.
Any idea what I should fix to make it work?
Can you perhaps add a print statement before this merge statement? I assume it should run: https://github.com/OpenAccess-AI-Collective/axolotl/blob/132eb740f036eff0fa8b239ddaf0b7a359ed1732/src/axolotl/utils/models.py#L671-L672 . if this is not run, then, your warning makes sense.
@NanoCode012 I don't have access to the interpreter (I work in cloud), so I'll fork the repo, make the changes, reinstall the library and test tomorrow.
You can nano axolotl/src/axolotl/utils/models.py
and make the changes. You won't need to reinstall nor fork. It should be loaded automatically.
@NanoCode012 I work using jupyter (jupyter is isolated from the OS and with reduced permissions), so it won't help me, unfortunately (at least I don't know the ways)
I added print statements before and in the if clause.
LOG.info("-" * 27 + "before merge and unload" + "-" * 26)
if isinstance(model, (PeftModel, PeftModelForCausalLM)) and not qlora_fsdp:
LOG.info("-" * 30 + "merge and unload" + "-" * 30)
model = model.merge_and_unload()
And you were right, the code under the condition is not executed.
I also did a test with the base model (modified part of the config - below) and everything was fine, the final model merges successfully.
base_model: Open-Orca/Mistral-7B-OpenOrca
model_type: MistralForCausalLM
tokenizer_type: LlamaTokenizer
Ahh, that can possibly be it. Would you be an able to print the model
variable to see its class? For the short term, you may be able to move the merge out of the if condition just to get your current merge working.
@NanoCode012 model
variable class is transformers.models.mistral.modeling_mistral.MistralForCausalLM
Sorry, I forgot to get back. ~Can you temporarily move the merge out of the if condition? Does that work?~
Edit: It seems that it would error.
Hm, I could not reproduce this issue. I tried
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel, PeftModelForCausalLM, LoraConfig
peft_model_id = "ybelkada/opt-350m-lora"
# load model via lora
model = AutoModelForCausalLM.from_pretrained(peft_model_id)
# add new adapter
lora_config = LoraConfig(
target_modules=["q_proj", "k_proj"],
init_lora_weights=False
)
model.add_adapter(lora_config, adapter_name="adapter_1")
model.save_pretrained("test")
It doesn't error on the save stage.
Sorry, I forgot to get back. ~Can you temporarily move the merge out of the if condition? Does that work?~
Edit: It seems that it would error.
Yeah, there's gonna be an error. I changed the code as follows:
LOG.info("-" * 27 + "before merge and unload" + "-" * 26)
model = model.merge_and_unload()
LOG.info("-" * 30 + "merge and unload" + "-" * 30)
And got the error AttributeError: 'MistralForCausalLM' object has no attribute 'merge_and_unload'
Could this error be specific to the mistral model?
No, it's as expected. That function belongs to PeftModel which that object is not.
At this point, can you try, load the base model then use the merge lora feature with your current base IlyaGusev/saiga_mistral_7b_lora
. Then, load that new base and merge it with your current trained model?
Please check that this issue hasn't been reported before.
Expected Behavior
Merged model
Current behaviour
When I call the command
python3 -m axolotl.cli.merge_lora configs/config.yaml --lora_model_dir="./lora-out"
, an error occurs after a whileSteps to reproduce
accelerate launch -m axolotl.cli.train configs/config.yaml
python3 -m axolotl.cli.merge_lora configs/config.yaml --lora_model_dir="./lora-out"
Config yaml
Possible solution
I found the issue in
transformer
repo, but there is no solution there (other than correct usage).Which Operating Systems are you using?
Python Version
3.10
axolotl branch-commit
main/5ed2939
Acknowledgements