Skip to content

Instantly share code, notes, and snippets.

@wassname
Last active August 28, 2024 01:30
Show Gist options
  • Save wassname/e85018faa3fc9ad6980ace5b47bb07d8 to your computer and use it in GitHub Desktop.
Save wassname/e85018faa3fc9ad6980ace5b47bb07d8 to your computer and use it in GitHub Desktop.
Given a peft model work out is adapters are enabled or disabled"
from peft.peft_model import BaseTunerLayer, PeftModel
from peft.utils.other import ModulesToSaveWrapper
def adapter_is_disabled(model: PeftModel) -> bool:
"""Given a peft model work out is adapters are enabled or disabled"""
for module in model.model.modules():
if isinstance(module, (BaseTunerLayer, ModulesToSaveWrapper)):
# print(help(module.enable_adapters))
return module._disable_adapters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment