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

Fix issue where you cannot call PeftModel.from_pretrained with a private adapter #1076

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/peft/peft_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def from_pretrained(
revision=kwargs.get("revision", None),
cache_dir=kwargs.get("cache_dir", None),
use_auth_token=kwargs.get("use_auth_token", None),
token=kwargs.get("token", None),
)
].from_pretrained(model_id, **kwargs)
elif isinstance(config, PeftConfig):
Expand Down
6 changes: 6 additions & 0 deletions src/peft/utils/save_and_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ def load_peft_weights(model_id: str, device: Optional[str] = None, **hf_hub_down
filename = os.path.join(path, WEIGHTS_NAME)
use_safetensors = False
else:

token = hf_hub_download_kwargs.get("token", None)
if token is None:
token = hf_hub_download_kwargs.get("use_auth_token", None)

has_remote_safetensors_file = file_exists(
repo_id=model_id,
filename=SAFETENSORS_WEIGHTS_NAME,
revision=hf_hub_download_kwargs.get("revision", None),
repo_type=hf_hub_download_kwargs.get("repo_type", None),
token=hf_hub_download_kwargs.get("token", None),
BenjaminBossan marked this conversation as resolved.
Show resolved Hide resolved
)
use_safetensors = has_remote_safetensors_file

Expand Down
Loading