-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
torch.compile: generate should use call instead of forward #34906
Comments
Hi, so if I understand correctly, the goal of this change is to make the future |
Previous code called |
Hi @SilverSoldier, thanks for opening the issue! Indeed I agree that we should use Also, we introduced the recent changes because it is inefficient to |
I see, it's another API of compile! Thanks! |
System Info
transformers
version: 4.47.0.dev0Who can help?
@ArthurZucker @Cyrilvallez
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
Expected behaviour is that we use the compiled forward function.
When compiling using the
model.compile()
API, the call method uses an internal variable with the compiled forward instead of the uncompiled forward.(I raised a related issue in pytorch, this is the Option 2 there)
So generate, should use the call method instead of the forward to use the compiled version of forward (for this particular case of model.compile).
However, recent changes have changed this call to model.forward() instead of model() for the non-first token :
model_forward should be changed to call model() instead of model.forward()
The text was updated successfully, but these errors were encountered: