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

Test more architectures in ORTModel #675

Merged
merged 14 commits into from
Jan 16, 2023

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Jan 5, 2023

A lot of architectures were untested up to now.

Fixes #664

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jan 5, 2023

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

"bloom",
"codegen",
"bigbird_pegasus",
"bart",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you put bart, mbart and marian here? They are seq2seq models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just copy paste, basically because of

image

As I understand reading modeling_mbart.py, there is a MBartForCausalLM that does not use the encoder, and a MBartForConditionalGeneration that does. I guess that's because of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JingyaHuang So I removed these models from the CausalLM test. There is an asymmetry because transformers AutoModelForCausalLM (that may have an encoder) and ORTModelForCausalLM (that may not), we may want to fix this later but I'm not sure it's worth it.

@fxmarty
Copy link
Contributor Author

fxmarty commented Jan 13, 2023

One remaining issue is that models are exported in many different subtests, so we can expect this test to be super slow now. I'll fix as well in this PR.

Edit: done

@fxmarty fxmarty changed the title Test all architectures in ORTModel Test more architectures in ORTModel Jan 13, 2023
optimum/exporters/tasks.py Outdated Show resolved Hide resolved
tests/onnxruntime/test_modeling.py Outdated Show resolved Hide resolved
"xlm_roberta",
]

ARCH_MODEL_MAP = {
Copy link
Member

Choose a reason for hiding this comment

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

What's the use of ARCH_MODEL_MAP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some architectures like perceiver can't have the same model used for different tasks (e.g. sequence classification and image classification). It is similar to

"perceiver": {
"hf-internal-testing/tiny-random-language_perceiver": ["masked-lm", "sequence-classification"],
"hf-internal-testing/tiny-random-vision_perceiver_conv": ["image-classification"],

Currently this is not used because perceiver does not work with ORTModel but it can be useful in the future.

Comment on lines +1660 to +1675
SUPPORTED_ARCHITECTURES = [
"beit",
"convnext",
"data2vec_vision",
"deit",
"levit",
"mobilenet_v1",
"mobilenet_v2",
"mobilevit",
# "perceiver",
"poolformer",
"resnet",
"segformer",
"swin",
"vit",
]
Copy link
Member

Choose a reason for hiding this comment

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

Is it not possible to infer that list automatically?

Copy link
Contributor Author

@fxmarty fxmarty Jan 13, 2023

Choose a reason for hiding this comment

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

@michaelbenayoun I would propose in a next PR to introduce in optimum/onnxruntime a dict of officially supported (aka tested) architectures for ORTModel (and raise a warning that unexpected behavior may happen if an other architecture is used). We would then use this dict in here. Does this sound good to you? I can as well add it to this PR directly if you prefer.

We can't use the ones from exporters/tasks.py because some of the models supported in the ONNX export are not in ORTModel.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, perfect!

@fxmarty fxmarty merged commit 0032117 into huggingface:main Jan 16, 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.

Test ORTModel.from_pretrained() for all architectures
4 participants