Skip to content

Commit 3fc83e3

Browse files
MNT Clean up unused method set_auxiliary_adapters (#2876)
During work on #2771, the usage of set_auxiliary_adapters became obsolete, expect in one place, which was missed. This has now been cleaned up and the obsolete method is removed.
1 parent 1985e04 commit 3fc83e3

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

src/peft/tuners/mixed/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
_get_submodules,
2929
get_auto_gptq_quant_linear,
3030
)
31+
from peft.utils.other import _set_adapter
3132

3233

3334
# Collection of constants used for all tuners
@@ -188,7 +189,7 @@ def _create_new_module(config, adapter_name, target, **kwargs):
188189
return new_module
189190

190191
def set_adapter(self, adapter_name: Union[str, list[str]], inference_mode: bool = False) -> None:
191-
self.set_auxiliary_adapters(adapter_name, inference_mode=inference_mode)
192+
_set_adapter(self, adapter_name, inference_mode=inference_mode) # handle auxiliary modules
192193
for module in self.model.modules():
193194
if isinstance(module, Layers):
194195
if module.merged:

src/peft/tuners/tuners_utils.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,21 +1111,6 @@ def unmerge_adapter(self):
11111111
with onload_layer(module):
11121112
module.unmerge()
11131113

1114-
def set_auxiliary_adapters(self, adapter_name: str | list[str], inference_mode: bool) -> None:
1115-
"""
1116-
Sets the active adapter(s) on auxiliary modules.
1117-
1118-
If the subclass (e.g. `LoraModel`) supports auxiliary modules like `modules_to_save`, it should call this
1119-
method in `set_adapter` to ensure that those auxiliary modules are being set correctly.
1120-
1121-
Args:
1122-
adapter_name (`str` or `list[str]`):
1123-
The name(s) of the adapter(s) to be set as active. The adapters must be loaded first.
1124-
inference_mode (bool, optional):
1125-
Whether the activated adapter should be frozen (i.e. `requires_grad=False`). Default is False.
1126-
"""
1127-
_set_adapter(self, adapter_name, inference_mode=inference_mode)
1128-
11291114
def set_adapter(self, adapter_name: str | list[str], inference_mode: bool = False) -> None:
11301115
"""Set the active adapter(s).
11311116

0 commit comments

Comments
 (0)