-
Notifications
You must be signed in to change notification settings - Fork 231
[OpenVINO] fix: Respect trust_remote_code in export and improve safety for multimodal configs FIXES #1668
#1673
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
base: main
Are you sure you want to change the base?
Changes from all commits
05536a7
8954d32
c42bf7f
12fd48e
ec03941
6b79aac
e74f020
6890261
b20b34f
42695cf
0fbf8ee
07e3dd4
aad0ac3
91359e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,6 @@ | |
| from optimum.utils import logging | ||
| from optimum.utils.save_utils import maybe_load_preprocessors | ||
|
|
||
|
|
||
| logger = logging.get_logger() | ||
|
|
||
|
|
||
|
|
@@ -125,6 +124,7 @@ class ExportModelTest(unittest.TestCase): | |
| SUPPORTED_ARCHITECTURES.update({"qwen3": OVModelForFeatureExtraction}) | ||
|
|
||
| GENERATIVE_MODELS = ("pix2struct", "t5", "bart", "gpt2", "whisper", "llava", "speecht5") | ||
| OV_MULTIMODAL_REMOTE_CODE_MODELS = ("llava-qwen2", "phi3_v") | ||
|
|
||
| def _openvino_export( | ||
| self, | ||
|
|
@@ -334,6 +334,29 @@ def test_compare_openvino_onnx_supported_architectures(self): | |
| if len(only_onnx) > 0: | ||
| logger.warning(f"The following architectures export {only_onnx} is supported by ONNX but not OpenVINO") | ||
|
|
||
| @parameterized.expand(OV_MULTIMODAL_REMOTE_CODE_MODELS) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have a list of all trust remote code models. May be we can parameterize this test using this list.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the models in that list donot support trust remote code propogation at openvino level , they handle it at hugging face level so running this test over all those models will throw TypeError for unexpected argument and fail these tests . |
||
| def test_export_requires_trust_remote_code_for_multimodal_models(self, model_type): | ||
|
|
||
| model = MODEL_NAMES[model_type] | ||
| task = "image-text-to-text" | ||
| with TemporaryDirectory() as tmpdirname: | ||
| with self.assertRaises(ValueError) as ctx: | ||
| main_export( | ||
| model_name_or_path=model, | ||
| task=task, | ||
| output=Path(tmpdirname), | ||
| trust_remote_code=False, | ||
| ) | ||
|
|
||
| self.assertIn("trust_remote_code", str(ctx.exception)) | ||
|
|
||
| main_export( | ||
| model_name_or_path=model, | ||
| task=task, | ||
| output=Path(tmpdirname), | ||
| trust_remote_code=True, | ||
| ) | ||
|
|
||
|
|
||
| class CustomExportModelTest(unittest.TestCase): | ||
| def test_custom_export_config_model(self): | ||
|
|
||
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.
Why is
trust_remote_codeflag propagated here only for "llava-qwen2" and "phi3_v"? Maybe we need to do it unconditionally?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.
other models do require
trust_remote_codeat the Transformers level but their corresponding OpenVINO config classes do not accept this parameter yet . So the condition is requiredpropagating
trust_remote_codeunconditionally, leads to :