peft
aac7722b - Add adapter error handling (#800)

Commit
2 years ago
Add adapter error handling (#800) When a user tries to add a 2nd adapter, Lora and AdaLora make some checks to ensure the new adapter is compatible with existing adapters. Currently, that check is performed halfway through the method. This means that if the check fails, the new adapter is partially applied, leaving the model in a bad state. The main purpose of this PR is to ensure that the model state is correct after such a failure is encountered. Tests were added to catch this potential bug. While working on this, I also did some related, but not strictly necessary changes to the add_adapter methods: - Previously, the peft_config from the PeftModel was passed to the base model. This meant that sometimes, the base model would hold a reference to PeftModel.peft_config, but not always, as some base models would create new dicts. This is problematic, because some code would rely on the objects being the same. Now, they are never the same, leading to more consistency. - I think that the check if multiple adapters have biases (which is not supported) was accidentally removed by #749. It is added back in. - Add some type annotations - Extend docstrings to contain adapter_name
Parents
Loading