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 onnx config for RoFormer #16861

Merged
merged 5 commits into from
Apr 26, 2022
Merged

Conversation

skrsna
Copy link

@skrsna skrsna commented Apr 20, 2022

What does this PR do?

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@chainyo
Copy link
Contributor

chainyo commented Apr 20, 2022

Hey nice PR! Did you try to convert one RoFormer model with your add ?
If so you could add the converted model to the ONNXConfig for all organization, it would be awesome!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 20, 2022

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

@skrsna
Copy link
Author

skrsna commented Apr 20, 2022

Hey nice PR! Did you try to convert one RoFormer model with your add ? If so you could add the converted model to the ONNXConfig for all organization, it would be awesome!

python -m transformers.onnx -m junnyu/roformer_chinese_sim_char_ft_small onnx/model.onnx
Validating ONNX model...
	-[✓] ONNX model output names match reference model ({'last_hidden_state'})
	- Validating ONNX Model output "last_hidden_state":
		-[✓] (2, 8, 384) matches (2, 8, 384)
		-[✓] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx

:)

@chainyo
Copy link
Contributor

chainyo commented Apr 20, 2022

It seems that there is 2x sequence-classification for features

All good, model saved at: onnx/model.onnx

Nice news!

@LysandreJik LysandreJik requested a review from lewtun April 20, 2022 21:32
Copy link
Member

@lewtun lewtun 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 adding RoFormer @skrsna and thank you to @chainyo for the review!

I agree with @chainyo's suggestions and would also like to see this included in the slow tests if possible. Could you add a roformer checkpoint to text_onnx_v2.py please, e.g. maybe this works well: https://huggingface.co/junnyu/roformer_chinese_base

Then please run

RUN_SLOW=1 pytest tests/onnx/test_onnx_v2.py -s -k "roformer"

@skrsna
Copy link
Author

skrsna commented Apr 26, 2022

Thanks for adding RoFormer @skrsna and thank you to @chainyo for the review!

I agree with @chainyo's suggestions and would also like to see this included in the slow tests if possible. Could you add a roformer checkpoint to text_onnx_v2.py please, e.g. maybe this works well: https://huggingface.co/junnyu/roformer_chinese_base

Then please run

RUN_SLOW=1 pytest tests/onnx/test_onnx_v2.py -s -k "roformer"

Thanks for the review @chainyo and @lewtun, I added roformer to the onnx test case

tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_65_roformer_causal_lm If you want to use `RoFormerForCausalLM` as a standalone, add `is_decoder=True.`
PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_66_roformer_default PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_67_roformer_masked_lm PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_68_roformer_multiple_choice PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_69_roformer_question_answering PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_70_roformer_sequence_classification PASSED
tests/onnx/test_onnx_v2.py::OnnxExportTestCaseV2::test_pytorch_export_71_roformer_token_classification PASSED

Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

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

Great, thanks for adding the slow test and checking that it works!

This LGTM so gently pinging @sgugger for final approval

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.

Thanks for your PR!

@lewtun lewtun merged commit aaee403 into huggingface:main Apr 26, 2022
@skrsna skrsna deleted the roformer/add-onnx-config branch April 26, 2022 14:52
chamidullinr pushed a commit to chamidullinr/transformers that referenced this pull request Apr 28, 2022
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
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.

5 participants