-
Notifications
You must be signed in to change notification settings - Fork 487
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 BetterTransformer support for FlavaModel #538
Add BetterTransformer support for FlavaModel #538
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @katiele47 !
Thanks so much for your very clean and great PR! Everything looks perfect 🔥
Regarding FLAVA, I quickly dived into it and the fix seems to be relatively simple. The model has 2 components, image and text encoders. Each of these submodules has its own config file that you can access with .image_config
or .text_config
. I think that the fix that I propose here is fine, as for both sub-config
s the same hyper parameters seems to be used (i.e. same hidden_size
, same hidden_act
, etc.). Check for example this config file
After accepting my suggestion, you can run pytest tests/bettertransformer/test_bettertransformer_vision.py:: BetterTransformersFlavaTest
to make sure the test pass ;)
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Thanks a lot for your insight @younesbelkada! I will run the test and update this PR |
…d-better-transformers-support-for-flava
…ithub.com/katiele47/optimum into add-better-transformers-support-for-flava
The test script now worked with the following output, but I encountered 2 failed tests from
Test script output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for digging into the issue!
I think that there is a problem with the feature extractor in hf-internal-testing/tiny-random-FlavaModel
, can you please try with a new model that I created? (Suggestion below) Thanks!
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
…d-better-transformers-support-for-flava
…ithub.com/katiele47/optimum into add-better-transformers-support-for-flava
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
Thanks again for your time and suggestion @younesbelkada! I have made the changes accordingly, and all tests passed. I'll keep an eye on any arising CircleCI issues in the meantime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @katiele47 !
I left a couple of comments, this should fix the failing tests! ;)
Thanks again
* ORTQuantizer saves model config when possible * Fix docstring * ORTModel can load any name for the ONNX model * Use regex now * Almost ready * modeling_ort * test * Works for ORTModel * Fixed bugs * remove pdb * Remove unnecessary attribute * ORTDecoderModel ready * Fix issue * Make style * fix issues * Rebase and style * Fix * Fix issues * Apply suggestions Co-authored-by: Michael Benayoun <michael@huggingface.co>
* Add IO binding for ORTModelForCustomTasks * Add test * Fix test model * Force inputs to be contiguous * Fix docstring * Nits
* Update README * Change section * Add links to examples * Modify BetterTransformer documentation section name * Add link to the documentation * Rephrasing * Update README.md Co-authored-by: fxmarty <9808326+fxmarty@users.noreply.github.com> * Update readme Co-authored-by: fxmarty <9808326+fxmarty@users.noreply.github.com>
* Fix issues * Fix issues * Apply suggestion Co-authored-by: Michael Benayoun <michael@huggingface.co>
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
…ransformers 4.25.1 (huggingface#561) * Fix wrap * Improve import check * Improve import check
* add clip * style and test * better support * debug * style * support clip vision model * typo * fix test * fix test * add clip in doc * fix test * remove comment * Update optimum/bettertransformer/models/encoder_models.py Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com> * fix style Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
* fix flaky test * fix flaky
…nx` in `ORTDecoder` (huggingface#554) * add support * cleaning * remove useless import * remove print * styling post merge * Update optimum/onnxruntime/modeling_decoder.py Co-authored-by: Michael Benayoun <mickbenayoun@gmail.com> * simplify multiple ONNX export * fix path * avoid code duplicate, better doc * fix and simplify test Co-authored-by: Michael Benayoun <mickbenayoun@gmail.com>
* enable FP16Optimizer for fp16 deepspeed training * wrap apex optimizer * Update optimum/onnxruntime/trainer.py Co-authored-by: Jingya HUANG <44135271+JingyaHuang@users.noreply.github.com> * Update optimum/onnxruntime/trainer.py Co-authored-by: Jingya HUANG <44135271+JingyaHuang@users.noreply.github.com> * formating trainer.py * reformat using black 22.6 Co-authored-by: Jingya HUANG <44135271+JingyaHuang@users.noreply.github.com> Co-authored-by: Adam Louly <adamlouly@microsoft.com@orttrainingdev9.d32nl1ml4oruzj4qz3bqlggovf.px.internal.cloudapp.net>
@younesbelkada Sorry for the multiple file changes, I think it's due to merging conflicts with upstream main, but I'm not entirely sure. Please let me know if this affect the original flava changes. |
Hi @younesbelkada I have created a new PR here that replaces this outdated PR. Please review and let me know if I should close this one. Thanks a lot! |
What does this PR do?
Fixes #20372
Before submitting
make style
Questions
BetterTransformersFlavaTest
or should I reuseBetterTransformersViltTest
for FlavaModel? If so, should I update the name toBetterTransformersVisionTextTest
?FlavaModel
with bothpytest
and running this scriptError:
I couldn't find where the
self.act_fn
get defined inside theforward
method after following this guide. Would appreciate any help!