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

Add Support for DeBERTaV2 #207

Closed
sam-h-bean opened this issue Jun 2, 2022 · 6 comments · Fixed by #217
Closed

Add Support for DeBERTaV2 #207

sam-h-bean opened this issue Jun 2, 2022 · 6 comments · Fixed by #217
Labels
feature-request New feature or request

Comments

@sam-h-bean
Copy link
Contributor

sam-h-bean commented Jun 2, 2022

I would like to use DeBERTaV2 for sequence classification as a quantized model. Please let me know what needs to be done to open a PR to add this support!

@sam-h-bean sam-h-bean changed the title Add Support for DeBERTaV3 Add Support for DeBERTaV2 Jun 2, 2022
@JingyaHuang
Copy link
Contributor

Hi @sam-h-bean,

Before quantizing a DeBERTaV2 model, you need to be able to export it to the ONNX format, which is not supported yet. To do so, you could implement a custom OnnxConfig in transformers and add "sequence-classification" feature(if it is the only one that you are looking for) with following steps.

Feel free to reach out if you have any other question!

@sam-h-bean
Copy link
Contributor Author

@JingyaHuang I opened a PR here! Excited to get to the quantizing once this makes its way into main. Or is there a way I can begin that work using my local copy of transformers?

@JingyaHuang
Copy link
Contributor

@sam-h-bean Sure, feel free to test ORTQuantizer with your copy of transformers, I can also add the support of DeBERTa-V2 for ORTOptimizer in case you want to do some graph optimizations.

@JingyaHuang
Copy link
Contributor

Closed as completed.

P.S. As DeBERTa tokenizers output token_type_ids by default and ORT doesn't take invalid inputs, token_type_ids should be removed from inputs before inference.

tokenizer = {processor_class}.from_pretrained("{checkpoint}")
model = {model_class}.from_pretrained("{checkpoint}")
-inputs = tokenizer("Optimum is nice.", return_tensors="pt")
+inputs = tokenizer("Optimum is nice.", return_tensors="pt", return_token_type_ids=False)
outputs = model(**inputs)

And for pipeline API, we are working on taking these edge cases into consideration.

@caffeinetoomuch
Copy link

I am getting Exception: Incomplete symbolic shape inference when optimizing DeBERTaV2 with fp16(AutoOptimizationConfig.O4(for_gpu=True)). Do I need to disable specific fusion?

@fxmarty
Copy link
Contributor

fxmarty commented Dec 17, 2022

@ice-americano Hi, could you open a new issue to track down this problem? Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
4 participants