[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lora] push_to_hub() save_pretrained() errors and potential inconsistencies #57

Closed
sayakpaul opened this issue Feb 7, 2023 · 2 comments

Comments

@sayakpaul
Copy link
Member

Related to #56.

@younesbelkada @pacman100

Consider the following LoraModel instance:

from transformers import AutoModelForImageClassification, TrainingArguments, Trainer
from peft import LoraConfig, LoraModel


model_checkpoint = "google/vit-base-patch16-224-in21k" 
model = AutoModelForImageClassification.from_pretrained(
    model_checkpoint,
    label2id=label2id,
    id2label=id2label,
    ignore_mismatched_sizes=True,  # provide this in case you're planning to fine-tune an already fine-tuned checkpoint
)

config = LoraConfig(
    r=16,
    lora_alpha=16,
    target_modules=["query", "value"],
    lora_dropout=0.1,
    bias="none",
    modules_to_save=["classifier"],
)
lora_model = LoraModel(config, model)

If I call lora_model.save_pretrained("lora_vit"), I see that the state_dict is about the same size as that of model. Is this expected?

I would have expected to only see the LoRA trainable parameters alongside the modules_to_save ones. This would help reduce the size of the state dict and would also help with portability, especially for very large models. This is also how it's implemented in diffusers.

Also, PeftConfig is somehow unable to find the config.json here whereas it's clearly there as we can see. What am I missing out on?

This currently blocks the inference and sharing section of the notebook.

@pacman100
Copy link
Contributor

Hello Sayak, for hf hub utils, you need to create object of PeftModel. In the notebook example that I have shared offline, these changes have been shown.

@sayakpaul
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants