Skip to content

Commit 385c690

Browse files
committed
Fix: Propagate local_files_only to hub_kwargs and PEFT adapter loading
1 parent bdee088 commit 385c690

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/transformers/integrations/peft.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def load_adapter(
106106
low_cpu_mem_usage: bool = False,
107107
is_trainable: bool = False,
108108
hotswap: bool | Literal["auto"] = "auto",
109+
local_files_only: bool = False,
109110
adapter_kwargs: Optional[dict[str, Any]] = None,
110111
) -> None:
111112
"""
@@ -237,6 +238,9 @@ def load_adapter(
237238
if adapter_kwargs is None:
238239
adapter_kwargs = {}
239240

241+
if "local_files_only" not in adapter_kwargs:
242+
adapter_kwargs["local_files_only"] = local_files_only
243+
240244
from peft import PeftConfig, inject_adapter_in_model, load_peft_weights
241245
from peft.utils import set_peft_model_state_dict
242246

@@ -768,6 +772,9 @@ def maybe_load_adapters(
768772
):
769773
if pretrained_model_name_or_path is None or not is_peft_available():
770774
return None, pretrained_model_name_or_path, adapter_kwargs
775+
776+
if "local_files_only" not in adapter_kwargs:
777+
adapter_kwargs["local_files_only"] = download_kwargs.get("local_files_only", False)
771778

772779
token = download_kwargs.get("token")
773780

src/transformers/pipelines/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,14 @@ def pipeline(
687687

688688
code_revision = kwargs.pop("code_revision", None)
689689
commit_hash = kwargs.pop("_commit_hash", None)
690+
local_files_only = kwargs.get("local_files_only", False)
690691

691692
hub_kwargs = {
692693
"revision": revision,
693694
"token": token,
694695
"trust_remote_code": trust_remote_code,
695696
"_commit_hash": commit_hash,
697+
"local_files_only": local_files_only,
696698
}
697699

698700
if task is None and model is None:

0 commit comments

Comments
 (0)