8000 [`core`] Correctly passing the kwargs all over the place by younesbelkada · Pull Request #575 · huggingface/peft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[core] Correctly passing the kwargs all over the place #575

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

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

younesbelkada
Copy link
Contributor
@younesbelkada younesbelkada commented Jun 14, 2023

What does this PR do?

Before this PR we were blindly passing the kwargs all over the place, for example the snippet below would fail:

Changes introduced

  • This PR adds new class methods _get_peft_type as the retrieval of the PEFT type is used and call over multiple places
  • Adds a _split_kwargs methods inside PeftModel to filter out kwargs that are used for hf_hub_download

Reproducible snippet

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM

peft_model_id = "ybelkada/test-st-lora" 
tr_model_id = "facebook/opt-350m"

model = AutoModelForCausalLM.from_pretrained(tr_model_id, torch_dtype=torch.bfloat16)
model = PeftModel.from_pretrained(model, peft_model_id, device_map="auto") # it will fail here

This PR fixes that by correctly filtering out the kwargs at different levels

Fixes #564
Fixes #579

@HuggingFaceDocBuilderDev
Copy link
HuggingFaceDocBuilderDev commented Jun 14, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor
@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @younesbelkada for properly handling the kwargs✨. PR #535 also was doing some part of this. Maybe, close that and add them as a co-author here?

Also added a comment

@younesbelkada
Copy link
Contributor Author

Hi @pacman100 , this PR is ready again for review, I now have added some tests

Copy link
Contributor
@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @younesbelkada for adding tests, LGTM! 🚀

@younesbelkada younesbelkada merged commit b519e3f into huggingface:main Jun 15, 2023
@younesbelkada younesbelkada deleted the fix-kwargs branch June 15, 2023 10:23
Guy-Bilitski pushed a commit to Guy-Bilitski/peft that referenced this pull request May 13, 2025
…#575)

* v1 of the fix

* forward contrib credits from discussions

* add tests

---------

Co-authored-by: winglian <winglian@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Peft_config problem when device_map = "auto" TypeError: PeftConfig.init() got an unexpected keyword argument 'device_map'
4 participants
0