-
Notifications
You must be signed in to change notification settings - Fork 2.1k
FIX X-LoRA forward hook issue during generate #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX X-LoRA forward hook issue during generate #2761
Conversation
There was an issue that forward hooks would accumulate during generation, since one hook per forward step was being registered and generate would call forward multiple times. This is already undesirable, but to make it worse, only the last hook was removed, resulting in hooks accumulating. This PR fixes the issue. See huggingface#1472 (comment)
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
EricLBuehler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
githubnemo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one question about fixing existing code
src/peft/tuners/xlora/model.py
Outdated
| if not self.disabled: | ||
| # TODO(EricLBuehler): If we get a forward exception, we may have multiple forward hooks. | ||
| for handle in handles_to_remove: | ||
| for handle in hook_handles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this todo by wrapping the yield in try: yield; except: raise; finally: remove_hooks?
|
@githubnemo I added |
There was an issue that forward hooks would accumulate during generation, since one hook per forward step was being registered and generate would call
forwardmultiple times. This is already undesirable, but to make it worse, only the last hook was removed, resulting in hooks accumulating.This PR fixes the issue.
See #1472 (comment)