Skip to content

Commit

Permalink
FIX Pass HF token when calling PeftModel.from_pretrained (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
elyxlz authored Nov 28, 2023
1 parent e586f96 commit 64c8d1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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
5 changes: 5 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,16 @@ 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=token,
)
use_safetensors = has_remote_safetensors_file

Expand Down

0 comments on commit 64c8d1d

Please sign in to comment.