Skip to content
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

adjust overriding of model's forward function #1492

Merged

Conversation

prathikr
Copy link
Contributor

@prathikr prathikr commented May 31, 2023

During ONNX Runtime optimization, the forward function's signature is inspected to perform downstream tasks. The current way of overriding the model's forward function results in the following error:

AttributeError: 'function' object has no attribute '__func__'

This PR improves the function signature override by using types.MethodType which doesn't impact the function signature for downstream tasks.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 31, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

LGTM but would love to have @muellerzr have a look as well.

Edit: looks like this breaks in mixed precision settings.

@prathikr prathikr requested a review from sgugger May 31, 2023 21:50
Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

The solution/idea presented here makes sense, but let's make sure tests pass before we can merge please :) (And then I'll give the ✅ 😉 )

@prathikr prathikr requested a review from muellerzr June 1, 2023 19:26
Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Thanks for this! Great work! Let's do a quick make style; make quality to ensure that the quality tests pass, then we're good to merge :)

@prathikr prathikr requested a review from muellerzr June 1, 2023 20:30
@sgugger sgugger merged commit b7d5d90 into huggingface:main Jun 2, 2023
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