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

Cannot export Deberta to TorchScript #20815

Open
2 of 4 tasks
SohamTamba opened this issue Dec 18, 2022 · 16 comments · May be fixed by #27734
Open
2 of 4 tasks

Cannot export Deberta to TorchScript #20815

SohamTamba opened this issue Dec 18, 2022 · 16 comments · May be fixed by #27734
Assignees

Comments

@SohamTamba
Copy link

SohamTamba commented Dec 18, 2022

System Info

transformers-cli env

- `transformers` version: 4.10.2
- Platform: Linux-3.10.0-1127.18.2.el7.x86_64-x86_64-with-glibc2.23
- Python version: 3.9.13
- PyTorch version (GPU?): 1.9.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

Who can help?

@sgugger

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

I am trying to convert the Deberta Model to TorchScript using the instructions provided in the HF tutorial.

Code:

import torch
from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("microsoft/deberta-base")
model = AutoModel.from_pretrained("microsoft/deberta-base", torchscript=True)

tokenized_dict = tokenizer(
    ["Is this working",], ["Not yet",], 
    return_tensors="pt"
)
input_tuple = (tokenized_dict['input_ids'], tokenized_dict['attention_mask'])

traced_model = torch.jit.trace(model, input_tuple)
torch.jit.save(traced_model, "compiled_deberta.pt")

Error Message:
From torch.jit.save:

Could not export Python function call 'XSoftmax'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__:

Expected behavior

The Traced model should be successfully saved. After loading, it should have the same functional behavior as the model it was traced from.

@sgugger
Copy link
Collaborator

sgugger commented Dec 19, 2022

Yes, this model is not compatible with torchscript, cc @ArthurZucker

@ArthurZucker
Copy link
Collaborator

Thanks, will take that into account when refactoring

@ArthurZucker ArthurZucker self-assigned this Dec 19, 2022
@huggingface huggingface deleted a comment from github-actions bot Jan 17, 2023
@SohamTamba
Copy link
Author

Go away stalebot

@huggingface huggingface deleted a comment from github-actions bot Feb 15, 2023
@jinuhwang
Copy link

jinuhwang commented Mar 11, 2023

Any update here?

@ArthurZucker
Copy link
Collaborator

Just started working on this! 😉

@huggingface huggingface deleted a comment from github-actions bot Apr 5, 2023
@github-actions github-actions bot closed this as completed May 7, 2023
@huggingface huggingface deleted a comment from github-actions bot May 23, 2023
@ArthurZucker ArthurZucker reopened this May 23, 2023
@huggingface huggingface deleted a comment from github-actions bot Jun 19, 2023
@ArthurZucker
Copy link
Collaborator

Sorry! Seem like I had to postpone this! If anyone want to take over feel free to do it, otherwise will be my priority once #23909 is merge!

@huggingface huggingface deleted a comment from github-actions bot Jul 20, 2023
@ArthurZucker
Copy link
Collaborator

ArthurZucker commented Jul 20, 2023

More delays given the recent sprints! But I think it should calm down during this summer! 😉

@huggingface huggingface deleted a comment from github-actions bot Aug 16, 2023
@huggingface huggingface deleted a comment from github-actions bot Sep 13, 2023
@dustinaxman
Copy link

Any update on this?

@LysandreJik
Copy link
Member

I'll add a good first issue tag on this! Slightly more involved than a documentation change, but should be possible by someone willing to put a cycle into it.

@dustinaxman
Copy link

Thanks a ton!

@riyasachdeva04
Copy link

i would like to work on this

@LysandreJik
Copy link
Member

Go ahead @riyasachdeva04, feel free to open a PR

@amannagarkar
Copy link

Can I take a crack at it too? @LysandreJik

@Szustarol
Copy link

Hey, I have noticed this issue has been silent for a while. I would like to start contributing, can I have a look at it? @LysandreJik @ArthurZucker

@LysandreJik
Copy link
Member

First come first served, please feel free to open a PR and link this issue and we'll be happy to review!

@Szustarol Szustarol linked a pull request Nov 27, 2023 that will close this issue
5 tasks
@dustinaxman
Copy link

How is everyone doing with this? Is it worth it for me to give it a shot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants