这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@BenjaminBossan
Copy link
Member

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 #1472 (comment)

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)
@HuggingFaceDocBuilderDev

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.

Copy link
Member

@EricLBuehler EricLBuehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@githubnemo githubnemo left a 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

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:
Copy link
Collaborator

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?

@BenjaminBossan
Copy link
Member Author

@githubnemo I added try ... finally

@BenjaminBossan BenjaminBossan merged commit 5ef8e85 into huggingface:main Sep 8, 2025
25 of 27 checks passed
@BenjaminBossan BenjaminBossan deleted the fix-xlora-forward-hook-issue-during-generate branch September 8, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants