Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/transformers/integrations/peft.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def load_adapter(
low_cpu_mem_usage: bool = False,
is_trainable: bool = False,
hotswap: bool | Literal["auto"] = "auto",
local_files_only: bool = False,
adapter_kwargs: dict[str, Any] | None = None,
) -> None:
"""
Expand Down Expand Up @@ -278,6 +279,7 @@ def load_adapter(
adapter_config_file = find_adapter_config_file(
peft_model_id,
token=token,
local_files_only=local_files_only,
**adapter_kwargs,
)

Expand All @@ -290,6 +292,7 @@ def load_adapter(
peft_config = PeftConfig.from_pretrained(
peft_model_id,
token=token,
local_files_only=local_files_only,
**adapter_kwargs,
)
peft_config.inference_mode = not is_trainable
Expand All @@ -306,6 +309,8 @@ def load_adapter(
self._hf_peft_config_loaded = True

if peft_model_id is not None:
if "local_files_only" not in adapter_kwargs:
adapter_kwargs["local_files_only"] = local_files_only
adapter_state_dict = load_peft_weights(peft_model_id, token=token, device=device, **adapter_kwargs)

# We need to pre-process the state dict to remove unneeded prefixes - for backward compatibility
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,14 @@ def pipeline(

code_revision = kwargs.pop("code_revision", None)
commit_hash = kwargs.pop("_commit_hash", None)
local_files_only = kwargs.get("local_files_only", False)

hub_kwargs = {
"revision": revision,
"token": token,
"trust_remote_code": trust_remote_code,
"_commit_hash": commit_hash,
"local_files_only": local_files_only
}

if task is None and model is None:
Expand Down